You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -160,27 +161,31 @@ function wrapEntryWithDynamicImport(resolvedSentryConfigPath: string): InputPlug
160
161
}
161
162
162
163
if(source==='import-in-the-middle/hook.mjs'){
164
+
// We are importing "import-in-the-middle" in the returned code of the `load()` function below
165
+
// By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it
166
+
// By importing "import-in-the-middle/hook.mjs", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.
167
+
// Prevents the error "Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'"
// The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix
// concat the query params to mark the file (also attaches names of exports - this is needed for serverless functions to re-export the handler)
188
+
// Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)
184
189
.concat(SENTRY_WRAPPED_ENTRY)
185
190
.concat(
186
191
exportedFunctions?.length
@@ -192,18 +197,21 @@ function wrapEntryWithDynamicImport(resolvedSentryConfigPath: string): InputPlug
192
197
},
193
198
load(id: string){
194
199
if(id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)){
195
-
constentryId=stripQueryPart(id);
200
+
constentryId=removeSentryQueryFromPath(id);
196
201
202
+
// Mostly useful for serverless `handler` functions
// Dynamic import for the previous, actual entry point.
205
-
// import() can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)
210
+
// Dynamic `import()` for the previous, actual entry point.
211
+
// `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)
206
212
`import(${JSON.stringify(entryId)});\n`+
213
+
// By importing "import-in-the-middle/hook.mjs", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.
0 commit comments