@sentry/solidstart 11.11.0 → 11.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/_virtual/_rolldown/runtime.js +34 -0
- package/build/cjs/client/index.js +11 -18
- package/build/cjs/client/sdk.js +19 -20
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/solidrouter.js +8 -16
- package/build/cjs/common/tunnel.js +11 -8
- package/build/cjs/common/tunnel.js.map +1 -1
- package/build/cjs/config/addInstrumentation.js +110 -111
- package/build/cjs/config/addInstrumentation.js.map +1 -1
- package/build/cjs/config/index.js +2 -0
- package/build/cjs/config/withSentry.js +86 -87
- package/build/cjs/config/withSentry.js.map +1 -1
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js +139 -135
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/cjs/index.client.js +12 -18
- package/build/cjs/index.server.js +162 -159
- package/build/cjs/index.server.js.map +1 -1
- package/build/cjs/nitro/tunnelPlugin.js +12 -20
- package/build/cjs/nitro/tunnelPlugin.js.map +1 -1
- package/build/cjs/server/index.js +151 -158
- package/build/cjs/server/middleware.js +26 -37
- package/build/cjs/server/middleware.js.map +1 -1
- package/build/cjs/server/sdk.js +13 -14
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/solidrouter.js +26 -18
- package/build/cjs/server/solidrouter.js.map +1 -1
- package/build/cjs/server/utils.js +32 -27
- package/build/cjs/server/utils.js.map +1 -1
- package/build/cjs/server/withServerActionInstrumentation.js +46 -49
- package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
- package/build/cjs/solidrouter.client.js +9 -16
- package/build/cjs/solidrouter.js +12 -18
- package/build/cjs/solidrouter.server.js +3 -8
- package/build/cjs/vite/buildInstrumentationFile.js +46 -46
- package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
- package/build/cjs/vite/index.js +5 -10
- package/build/cjs/vite/sentrySolidStart.js +86 -39
- package/build/cjs/vite/sentrySolidStart.js.map +1 -1
- package/build/cjs/vite/sentrySolidStartVite.js +32 -35
- package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +117 -152
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/esm/client/index.js +2 -3
- package/build/esm/client/sdk.js +19 -18
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/solidrouter.js +1 -2
- package/build/esm/common/tunnel.js +11 -6
- package/build/esm/common/tunnel.js.map +1 -1
- package/build/esm/config/addInstrumentation.js +107 -109
- package/build/esm/config/addInstrumentation.js.map +1 -1
- package/build/esm/config/index.js +1 -0
- package/build/esm/config/withSentry.js +86 -84
- package/build/esm/config/withSentry.js.map +1 -1
- package/build/esm/config/wrapServerEntryWithDynamicImport.js +139 -133
- package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/esm/index.client.js +3 -3
- package/build/esm/index.server.js +14 -10
- package/build/esm/index.server.js.map +1 -1
- package/build/esm/nitro/tunnelPlugin.js +12 -20
- package/build/esm/nitro/tunnelPlugin.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/index.js +7 -7
- package/build/esm/server/middleware.js +26 -35
- package/build/esm/server/middleware.js.map +1 -1
- package/build/esm/server/sdk.js +13 -12
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/solidrouter.js +25 -16
- package/build/esm/server/solidrouter.js.map +1 -1
- package/build/esm/server/utils.js +32 -25
- package/build/esm/server/utils.js.map +1 -1
- package/build/esm/server/withServerActionInstrumentation.js +46 -47
- package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
- package/build/esm/solidrouter.client.js +2 -2
- package/build/esm/solidrouter.js +3 -3
- package/build/esm/solidrouter.server.js +1 -2
- package/build/esm/vite/buildInstrumentationFile.js +43 -44
- package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
- package/build/esm/vite/index.js +3 -3
- package/build/esm/vite/sentrySolidStart.js +86 -37
- package/build/esm/vite/sentrySolidStart.js.map +1 -1
- package/build/esm/vite/sentrySolidStartVite.js +32 -33
- package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +117 -150
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/types/nitro/tunnelPlugin.d.ts +3 -3
- package/build/types/nitro/tunnelPlugin.d.ts.map +1 -1
- package/package.json +39 -37
- package/build/cjs/client/index.js.map +0 -1
- package/build/cjs/client/solidrouter.js.map +0 -1
- package/build/cjs/index.client.js.map +0 -1
- package/build/cjs/server/index.js.map +0 -1
- package/build/cjs/solidrouter.client.js.map +0 -1
- package/build/cjs/solidrouter.js.map +0 -1
- package/build/cjs/solidrouter.server.js.map +0 -1
- package/build/cjs/vite/index.js.map +0 -1
- package/build/esm/client/index.js.map +0 -1
- package/build/esm/client/solidrouter.js.map +0 -1
- package/build/esm/index.client.js.map +0 -1
- package/build/esm/server/index.js.map +0 -1
- package/build/esm/solidrouter.client.js.map +0 -1
- package/build/esm/solidrouter.js.map +0 -1
- package/build/esm/solidrouter.server.js.map +0 -1
- package/build/esm/vite/index.js.map +0 -1
|
@@ -1,93 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const addInstrumentation = require('./addInstrumentation.js');
|
|
10
|
-
|
|
11
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
1
|
+
const require_tunnel = require("../common/tunnel.js");
|
|
2
|
+
const require_sentrySolidStartVite = require("../vite/sentrySolidStartVite.js");
|
|
3
|
+
const require_addInstrumentation = require("./addInstrumentation.js");
|
|
4
|
+
let _sentry_core = require("@sentry/core");
|
|
5
|
+
let node_url = require("node:url");
|
|
6
|
+
let _sentry_server_utils_orchestrion_config = require("@sentry/server-utils/orchestrion/config");
|
|
7
|
+
let _sentry_server_utils_orchestrion_rollup = require("@sentry/server-utils/orchestrion/rollup");
|
|
8
|
+
// src/config/withSentry.ts
|
|
12
9
|
const IORedisDependencies = ["standard-as-callback"];
|
|
13
|
-
const defaultSentrySolidStartPluginOptions = {
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const defaultSentrySolidStartPluginOptions = { experimental_entrypointWrappedFunctions: [
|
|
11
|
+
"default",
|
|
12
|
+
"handler",
|
|
13
|
+
"server"
|
|
14
|
+
] };
|
|
15
|
+
/**
|
|
16
|
+
* Modifies the passed in Solid Start configuration with build-time enhancements such as
|
|
17
|
+
* building the `instrument.server.ts` file into the appropriate build folder based on
|
|
18
|
+
* build preset.
|
|
19
|
+
*
|
|
20
|
+
* @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`
|
|
21
|
+
* @param sentrySolidStartPluginOptions Options to configure the plugin
|
|
22
|
+
* @returns The modified config to be exported and passed back into `defineConfig`
|
|
23
|
+
*/
|
|
16
24
|
function withSentry(solidStartConfig = {}, sentrySolidStartPluginOptions) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
server: {
|
|
78
|
-
...server,
|
|
79
|
-
externals,
|
|
80
|
-
commonJS,
|
|
81
|
-
modules: [...existingModules, sentryNitroModule],
|
|
82
|
-
// Through `server.plugins`, since vinxi's dev server ignores plugins that Nitro modules add.
|
|
83
|
-
plugins: [...server.plugins || [], getTunnelPluginPath()]
|
|
84
|
-
}
|
|
85
|
-
};
|
|
25
|
+
const sentryPluginOptions = {
|
|
26
|
+
...sentrySolidStartPluginOptions,
|
|
27
|
+
...defaultSentrySolidStartPluginOptions
|
|
28
|
+
};
|
|
29
|
+
const server = solidStartConfig.server || {};
|
|
30
|
+
const tunnelBasePath = (0, _sentry_core._INTERNAL_normalizeTunnelBasePath)(server.baseURL);
|
|
31
|
+
if (tunnelBasePath) _sentry_core.GLOBAL_OBJ[require_tunnel.TUNNEL_BASE_PATH_GLOBAL] = tunnelBasePath;
|
|
32
|
+
const viteConfig = solidStartConfig.vite;
|
|
33
|
+
const vite = typeof viteConfig === "function" ? (...args) => require_sentrySolidStartVite.addSentryPluginToVite(viteConfig(...args), sentryPluginOptions, tunnelBasePath) : require_sentrySolidStartVite.addSentryPluginToVite(viteConfig, sentryPluginOptions, tunnelBasePath);
|
|
34
|
+
const addBuildTimeInstrumentation = sentryPluginOptions.buildTimeInstrumentation !== false;
|
|
35
|
+
const sentryNitroModule = (nitro) => {
|
|
36
|
+
nitro.hooks.hook("rollup:before", async (nitro, rollupConfig) => {
|
|
37
|
+
const sentryRollupConfig = rollupConfig;
|
|
38
|
+
if (tunnelBasePath) sentryRollupConfig.plugins.push({
|
|
39
|
+
name: "sentry-solidstart-tunnel-base-path",
|
|
40
|
+
banner: `globalThis.${require_tunnel.TUNNEL_BASE_PATH_GLOBAL} = ${JSON.stringify(tunnelBasePath)};`
|
|
41
|
+
});
|
|
42
|
+
if (addBuildTimeInstrumentation) sentryRollupConfig.plugins.push((0, _sentry_server_utils_orchestrion_rollup.sentryOrchestrionPlugin)({ buildTimeInstrumentation: sentryPluginOptions.buildTimeInstrumentation }), (0, _sentry_server_utils_orchestrion_rollup.sentryCommonJSInteropPlugin)());
|
|
43
|
+
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "experimental_dynamic-import") {
|
|
44
|
+
await require_addInstrumentation.addDynamicImportEntryFileWrapper({
|
|
45
|
+
nitro,
|
|
46
|
+
rollupConfig: sentryRollupConfig,
|
|
47
|
+
sentryPluginOptions
|
|
48
|
+
});
|
|
49
|
+
sentrySolidStartPluginOptions.debug && _sentry_core.debug.log("Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.");
|
|
50
|
+
} else {
|
|
51
|
+
await require_addInstrumentation.addInstrumentationFileToBuild(nitro);
|
|
52
|
+
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "top-level-import") await require_addInstrumentation.addSentryTopImport(nitro);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const existingModules = server.modules || [];
|
|
57
|
+
let externals = server.externals;
|
|
58
|
+
let commonJS = server.commonJS;
|
|
59
|
+
if (addBuildTimeInstrumentation) {
|
|
60
|
+
const existingInline = externals?.inline || [];
|
|
61
|
+
externals = {
|
|
62
|
+
...externals,
|
|
63
|
+
inline: [.../* @__PURE__ */ new Set([
|
|
64
|
+
...existingInline,
|
|
65
|
+
..._sentry_server_utils_orchestrion_config.INSTRUMENTED_MODULE_NAMES,
|
|
66
|
+
...IORedisDependencies
|
|
67
|
+
])]
|
|
68
|
+
};
|
|
69
|
+
commonJS = {
|
|
70
|
+
...(0, _sentry_server_utils_orchestrion_rollup.commonJSInteropOptions)(),
|
|
71
|
+
...commonJS
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...solidStartConfig,
|
|
76
|
+
vite,
|
|
77
|
+
server: {
|
|
78
|
+
...server,
|
|
79
|
+
externals,
|
|
80
|
+
commonJS,
|
|
81
|
+
modules: [...existingModules, sentryNitroModule],
|
|
82
|
+
plugins: [...server.plugins || [], getTunnelPluginPath()]
|
|
83
|
+
}
|
|
84
|
+
};
|
|
86
85
|
}
|
|
87
86
|
function getTunnelPluginPath() {
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const url = new URL("../nitro/tunnelPlugin.js", require("url").pathToFileURL(__filename).href);
|
|
88
|
+
return url.protocol === "file:" ? (0, node_url.fileURLToPath)(url) : url.pathname;
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
exports.withSentry = withSentry;
|
|
93
|
-
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=withSentry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withSentry.js","sources":["../../../src/config/withSentry.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url';\nimport { debug, GLOBAL_OBJ, _INTERNAL_normalizeTunnelBasePath as normalizeTunnelBasePath } from '@sentry/core';\nimport { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';\nimport {\n commonJSInteropOptions,\n sentryCommonJSInteropPlugin,\n sentryOrchestrionPlugin,\n} from '@sentry/server-utils/orchestrion/rollup';\nimport type { Nitro, NitroConfig } from 'nitropack';\nimport { TUNNEL_BASE_PATH_GLOBAL } from '../common/tunnel';\nimport { addSentryPluginToVite } from '../vite/sentrySolidStartVite';\nimport type { SentrySolidStartPluginOptions } from '../vite/types';\nimport {\n addDynamicImportEntryFileWrapper,\n addInstrumentationFileToBuild,\n addSentryTopImport,\n} from './addInstrumentation';\nimport type { RollupConfig, SolidStartInlineConfig, SolidStartInlineServerConfig } from './types';\n\n// ioredis requires this CommonJS helper to be bundled with it. Leaving it\n// external makes Nitro resolve the default export as a namespace object.\nconst IORedisDependencies = ['standard-as-callback'];\n\nconst defaultSentrySolidStartPluginOptions: Omit<\n SentrySolidStartPluginOptions,\n 'experimental_entrypointWrappedFunctions'\n> &\n Required<Pick<SentrySolidStartPluginOptions, 'experimental_entrypointWrappedFunctions'>> = {\n experimental_entrypointWrappedFunctions: ['default', 'handler', 'server'],\n};\n\n/**\n * Modifies the passed in Solid Start configuration with build-time enhancements such as\n * building the `instrument.server.ts` file into the appropriate build folder based on\n * build preset.\n *\n * @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`\n * @param sentrySolidStartPluginOptions Options to configure the plugin\n * @returns The modified config to be exported and passed back into `defineConfig`\n */\nexport function withSentry(\n solidStartConfig: SolidStartInlineConfig = {},\n sentrySolidStartPluginOptions: SentrySolidStartPluginOptions,\n): SolidStartInlineConfig {\n const sentryPluginOptions = {\n ...sentrySolidStartPluginOptions,\n ...defaultSentrySolidStartPluginOptions,\n };\n\n const server = (solidStartConfig.server || {}) as SolidStartInlineServerConfig;\n // Requests reach the tunnel with `server.baseURL` still in front, so both sides serve it under that.\n const tunnelBasePath = normalizeTunnelBasePath(\n (server as SolidStartInlineServerConfig & { baseURL?: string }).baseURL,\n );\n // vinxi's dev server runs Nitro in this process, so the tunnel plugin can read it from here in dev.\n if (tunnelBasePath) {\n (GLOBAL_OBJ as { [TUNNEL_BASE_PATH_GLOBAL]?: string })[TUNNEL_BASE_PATH_GLOBAL] = tunnelBasePath;\n }\n\n const viteConfig = solidStartConfig.vite;\n const vite =\n typeof viteConfig === 'function'\n ? (...args: Parameters<typeof viteConfig>) =>\n addSentryPluginToVite(viteConfig(...args), sentryPluginOptions, tunnelBasePath)\n : addSentryPluginToVite(viteConfig, sentryPluginOptions, tunnelBasePath);\n\n const addBuildTimeInstrumentation = sentryPluginOptions.buildTimeInstrumentation !== false;\n\n // Use a module so we don't override preset hooks.\n const sentryNitroModule = (nitro: Nitro) => {\n nitro.hooks.hook('rollup:before', async (nitro, rollupConfig) => {\n // Nitro types the `rollup:before` hook's `rollupConfig.plugins` as `string[]` (plugin paths),\n // but at runtime it holds resolved plugin objects we can push onto, so narrow to our own shape.\n const sentryRollupConfig = rollupConfig as unknown as RollupConfig;\n\n if (tunnelBasePath) {\n // The built server runs in another process, so the tunnel plugin reads the base path from the bundle.\n sentryRollupConfig.plugins.push({\n name: 'sentry-solidstart-tunnel-base-path',\n banner: `globalThis.${TUNNEL_BASE_PATH_GLOBAL} = ${JSON.stringify(tunnelBasePath)};`,\n });\n }\n\n if (addBuildTimeInstrumentation) {\n sentryRollupConfig.plugins.push(\n sentryOrchestrionPlugin({ buildTimeInstrumentation: sentryPluginOptions.buildTimeInstrumentation }),\n sentryCommonJSInteropPlugin(),\n );\n }\n\n if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {\n await addDynamicImportEntryFileWrapper({\n nitro,\n rollupConfig: sentryRollupConfig,\n sentryPluginOptions,\n });\n\n sentrySolidStartPluginOptions.debug &&\n debug.log(\n 'Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n } else {\n await addInstrumentationFileToBuild(nitro);\n\n if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'top-level-import') {\n await addSentryTopImport(nitro);\n }\n }\n });\n };\n\n const existingModules = (server as SolidStartInlineServerConfig & { modules?: unknown[] }).modules || [];\n\n // An externalized dependency never passes through the orchestrion code transform, so force-inline\n // the instrumented modules. This has to be set statically on the Nitro config (not in a hook)\n // because externalization is a resolution-time decision made before Rollup normalizes `external`.\n let externals = (server as SolidStartInlineServerConfig & { externals?: { inline?: string[] } }).externals;\n let commonJS = (server as SolidStartInlineServerConfig & { commonJS?: NitroConfig['commonJS'] }).commonJS;\n if (addBuildTimeInstrumentation) {\n const existingInline = externals?.inline || [];\n externals = {\n ...externals,\n inline: [...new Set([...existingInline, ...INSTRUMENTED_MODULE_NAMES, ...IORedisDependencies])],\n };\n\n // The inlined drivers `require()` CommonJS dependencies that stay external. Fix the interop\n // for those requires (see `commonJSInteropOptions`). User-provided options win.\n commonJS = { ...commonJSInteropOptions(), ...commonJS };\n }\n\n return {\n ...solidStartConfig,\n vite,\n server: {\n ...server,\n externals,\n commonJS,\n modules: [...existingModules, sentryNitroModule],\n // Through `server.plugins`, since vinxi's dev server ignores plugins that Nitro modules add.\n plugins: [...(server.plugins || []), getTunnelPluginPath()],\n },\n };\n}\n\nfunction getTunnelPluginPath(): string {\n const url = new URL('../nitro/tunnelPlugin.js', import.meta.url);\n\n // `import.meta.url` is a file URL in the built package, but not in every test environment.\n return url.protocol === 'file:' ? fileURLToPath(url) : url.pathname;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"withSentry.js","names":["normalizeTunnelBasePath","GLOBAL_OBJ","TUNNEL_BASE_PATH_GLOBAL","addSentryPluginToVite","sentryOrchestrionPlugin","sentryCommonJSInteropPlugin","addDynamicImportEntryFileWrapper","debug","addInstrumentationFileToBuild","addSentryTopImport","INSTRUMENTED_MODULE_NAMES","commonJSInteropOptions","fileURLToPath"],"sources":["../../../src/config/withSentry.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url';\nimport { debug, GLOBAL_OBJ, _INTERNAL_normalizeTunnelBasePath as normalizeTunnelBasePath } from '@sentry/core';\nimport { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';\nimport {\n commonJSInteropOptions,\n sentryCommonJSInteropPlugin,\n sentryOrchestrionPlugin,\n} from '@sentry/server-utils/orchestrion/rollup';\nimport type { Nitro, NitroConfig } from 'nitropack';\nimport { TUNNEL_BASE_PATH_GLOBAL } from '../common/tunnel';\nimport { addSentryPluginToVite } from '../vite/sentrySolidStartVite';\nimport type { SentrySolidStartPluginOptions } from '../vite/types';\nimport {\n addDynamicImportEntryFileWrapper,\n addInstrumentationFileToBuild,\n addSentryTopImport,\n} from './addInstrumentation';\nimport type { RollupConfig, SolidStartInlineConfig, SolidStartInlineServerConfig } from './types';\n\n// ioredis requires this CommonJS helper to be bundled with it. Leaving it\n// external makes Nitro resolve the default export as a namespace object.\nconst IORedisDependencies = ['standard-as-callback'];\n\nconst defaultSentrySolidStartPluginOptions: Omit<\n SentrySolidStartPluginOptions,\n 'experimental_entrypointWrappedFunctions'\n> &\n Required<Pick<SentrySolidStartPluginOptions, 'experimental_entrypointWrappedFunctions'>> = {\n experimental_entrypointWrappedFunctions: ['default', 'handler', 'server'],\n};\n\n/**\n * Modifies the passed in Solid Start configuration with build-time enhancements such as\n * building the `instrument.server.ts` file into the appropriate build folder based on\n * build preset.\n *\n * @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`\n * @param sentrySolidStartPluginOptions Options to configure the plugin\n * @returns The modified config to be exported and passed back into `defineConfig`\n */\nexport function withSentry(\n solidStartConfig: SolidStartInlineConfig = {},\n sentrySolidStartPluginOptions: SentrySolidStartPluginOptions,\n): SolidStartInlineConfig {\n const sentryPluginOptions = {\n ...sentrySolidStartPluginOptions,\n ...defaultSentrySolidStartPluginOptions,\n };\n\n const server = (solidStartConfig.server || {}) as SolidStartInlineServerConfig;\n // Requests reach the tunnel with `server.baseURL` still in front, so both sides serve it under that.\n const tunnelBasePath = normalizeTunnelBasePath(\n (server as SolidStartInlineServerConfig & { baseURL?: string }).baseURL,\n );\n // vinxi's dev server runs Nitro in this process, so the tunnel plugin can read it from here in dev.\n if (tunnelBasePath) {\n (GLOBAL_OBJ as { [TUNNEL_BASE_PATH_GLOBAL]?: string })[TUNNEL_BASE_PATH_GLOBAL] = tunnelBasePath;\n }\n\n const viteConfig = solidStartConfig.vite;\n const vite =\n typeof viteConfig === 'function'\n ? (...args: Parameters<typeof viteConfig>) =>\n addSentryPluginToVite(viteConfig(...args), sentryPluginOptions, tunnelBasePath)\n : addSentryPluginToVite(viteConfig, sentryPluginOptions, tunnelBasePath);\n\n const addBuildTimeInstrumentation = sentryPluginOptions.buildTimeInstrumentation !== false;\n\n // Use a module so we don't override preset hooks.\n const sentryNitroModule = (nitro: Nitro) => {\n nitro.hooks.hook('rollup:before', async (nitro, rollupConfig) => {\n // Nitro types the `rollup:before` hook's `rollupConfig.plugins` as `string[]` (plugin paths),\n // but at runtime it holds resolved plugin objects we can push onto, so narrow to our own shape.\n const sentryRollupConfig = rollupConfig as unknown as RollupConfig;\n\n if (tunnelBasePath) {\n // The built server runs in another process, so the tunnel plugin reads the base path from the bundle.\n sentryRollupConfig.plugins.push({\n name: 'sentry-solidstart-tunnel-base-path',\n banner: `globalThis.${TUNNEL_BASE_PATH_GLOBAL} = ${JSON.stringify(tunnelBasePath)};`,\n });\n }\n\n if (addBuildTimeInstrumentation) {\n sentryRollupConfig.plugins.push(\n sentryOrchestrionPlugin({ buildTimeInstrumentation: sentryPluginOptions.buildTimeInstrumentation }),\n sentryCommonJSInteropPlugin(),\n );\n }\n\n if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {\n await addDynamicImportEntryFileWrapper({\n nitro,\n rollupConfig: sentryRollupConfig,\n sentryPluginOptions,\n });\n\n sentrySolidStartPluginOptions.debug &&\n debug.log(\n 'Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n } else {\n await addInstrumentationFileToBuild(nitro);\n\n if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'top-level-import') {\n await addSentryTopImport(nitro);\n }\n }\n });\n };\n\n const existingModules = (server as SolidStartInlineServerConfig & { modules?: unknown[] }).modules || [];\n\n // An externalized dependency never passes through the orchestrion code transform, so force-inline\n // the instrumented modules. This has to be set statically on the Nitro config (not in a hook)\n // because externalization is a resolution-time decision made before Rollup normalizes `external`.\n let externals = (server as SolidStartInlineServerConfig & { externals?: { inline?: string[] } }).externals;\n let commonJS = (server as SolidStartInlineServerConfig & { commonJS?: NitroConfig['commonJS'] }).commonJS;\n if (addBuildTimeInstrumentation) {\n const existingInline = externals?.inline || [];\n externals = {\n ...externals,\n inline: [...new Set([...existingInline, ...INSTRUMENTED_MODULE_NAMES, ...IORedisDependencies])],\n };\n\n // The inlined drivers `require()` CommonJS dependencies that stay external. Fix the interop\n // for those requires (see `commonJSInteropOptions`). User-provided options win.\n commonJS = { ...commonJSInteropOptions(), ...commonJS };\n }\n\n return {\n ...solidStartConfig,\n vite,\n server: {\n ...server,\n externals,\n commonJS,\n modules: [...existingModules, sentryNitroModule],\n // Through `server.plugins`, since vinxi's dev server ignores plugins that Nitro modules add.\n plugins: [...(server.plugins || []), getTunnelPluginPath()],\n },\n };\n}\n\nfunction getTunnelPluginPath(): string {\n const url = new URL('../nitro/tunnelPlugin.js', import.meta.url);\n\n // `import.meta.url` is a file URL in the built package, but not in every test environment.\n return url.protocol === 'file:' ? fileURLToPath(url) : url.pathname;\n}\n"],"mappings":";;;;;;;;AAqBA,MAAM,sBAAsB,CAAC,sBAAsB;AAEnD,MAAM,uCAIuF,EAC3F,yCAAyC;CAAC;CAAW;CAAW;AAAQ,EAC1E;;;;;;;;;;AAWA,SAAgB,WACd,mBAA2C,CAAC,GAC5C,+BACwB;CACxB,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;CACL;CAEA,MAAM,SAAU,iBAAiB,UAAU,CAAC;CAE5C,MAAM,kBAAA,GAAiBA,aAAAA,kCAAAA,CACpB,OAA+D,OAClE;CAEA,IAAI,gBACDC,aAAAA,WAAsDC,eAAAA,2BAA2B;CAGpF,MAAM,aAAa,iBAAiB;CACpC,MAAM,OACJ,OAAO,eAAe,cACjB,GAAG,SACFC,6BAAAA,sBAAsB,WAAW,GAAG,IAAI,GAAG,qBAAqB,cAAc,IAChFA,6BAAAA,sBAAsB,YAAY,qBAAqB,cAAc;CAE3E,MAAM,8BAA8B,oBAAoB,6BAA6B;CAGrF,MAAM,qBAAqB,UAAiB;EAC1C,MAAM,MAAM,KAAK,iBAAiB,OAAO,OAAO,iBAAiB;GAG/D,MAAM,qBAAqB;GAE3B,IAAI,gBAEF,mBAAmB,QAAQ,KAAK;IAC9B,MAAM;IACN,QAAQ,cAAcD,eAAAA,wBAAwB,KAAK,KAAK,UAAU,cAAc,EAAE;GACpF,CAAC;GAGH,IAAI,6BACF,mBAAmB,QAAQ,MAAA,GACzBE,wCAAAA,wBAAAA,CAAwB,EAAE,0BAA0B,oBAAoB,yBAAyB,CAAC,IAAA,GAClGC,wCAAAA,4BAAAA,CAA4B,CAC9B;GAGF,IAAI,+BAA+B,2BAA2B,+BAA+B;IAC3F,MAAMC,2BAAAA,iCAAiC;KACrC;KACA,cAAc;KACd;IACF,CAAC;IAED,8BAA8B,SAC5BC,aAAAA,MAAM,IACJ,qHACF;GACJ,OAAO;IACL,MAAMC,2BAAAA,8BAA8B,KAAK;IAEzC,IAAI,+BAA+B,2BAA2B,oBAC5D,MAAMC,2BAAAA,mBAAmB,KAAK;GAElC;EACF,CAAC;CACH;CAEA,MAAM,kBAAmB,OAAkE,WAAW,CAAC;CAKvG,IAAI,YAAa,OAAgF;CACjG,IAAI,WAAY,OAAiF;CACjG,IAAI,6BAA6B;EAC/B,MAAM,iBAAiB,WAAW,UAAU,CAAC;EAC7C,YAAY;GACV,GAAG;GACH,QAAQ,CAAC,mBAAG,IAAI,IAAI;IAAC,GAAG;IAAgB,GAAGC,wCAAAA;IAA2B,GAAG;GAAmB,CAAC,CAAC;EAChG;EAIA,WAAW;GAAE,IAAA,GAAGC,wCAAAA,uBAAAA,CAAuB;GAAG,GAAG;EAAS;CACxD;CAEA,OAAO;EACL,GAAG;EACH;EACA,QAAQ;GACN,GAAG;GACH;GACA;GACA,SAAS,CAAC,GAAG,iBAAiB,iBAAiB;GAE/C,SAAS,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,oBAAoB,CAAC;EAC5D;CACF;AACF;AAEA,SAAS,sBAA8B;CACrC,MAAM,MAAM,IAAI,IAAI,4BAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,IAA2C;CAG/D,OAAO,IAAI,aAAa,WAAA,GAAUC,SAAAA,cAAAA,CAAc,GAAG,IAAI,IAAI;AAC7D"}
|
|
@@ -1,155 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
let _sentry_core = require("@sentry/core");
|
|
2
|
+
let node_url = require("node:url");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
// src/config/wrapServerEntryWithDynamicImport.ts
|
|
5
|
+
/** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */
|
|
7
6
|
const SENTRY_WRAPPED_ENTRY = "?sentry-query-wrapped-entry";
|
|
8
7
|
const SENTRY_WRAPPED_FUNCTIONS = "?sentry-query-wrapped-functions=";
|
|
9
8
|
const SENTRY_REEXPORTED_FUNCTIONS = "?sentry-query-reexported-functions=";
|
|
10
9
|
const QUERY_END_INDICATOR = "SENTRY-QUERY-END";
|
|
10
|
+
/**
|
|
11
|
+
* `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows
|
|
12
|
+
* paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands
|
|
13
|
+
* filesystem paths. Returns `undefined` for a malformed `file://` URL.
|
|
14
|
+
*
|
|
15
|
+
* **Only exported for testing**
|
|
16
|
+
*/
|
|
11
17
|
function toResolvablePath(source) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
if (!source.startsWith("file://")) return {
|
|
19
|
+
path: source,
|
|
20
|
+
wasFileUrl: false
|
|
21
|
+
};
|
|
22
|
+
if (source === "file://" || source === "file:///") return;
|
|
23
|
+
try {
|
|
24
|
+
const filePath = (0, node_url.fileURLToPath)(source);
|
|
25
|
+
if (!filePath || filePath === "/" || filePath === "\\") return;
|
|
26
|
+
return {
|
|
27
|
+
path: filePath,
|
|
28
|
+
wasFileUrl: true
|
|
29
|
+
};
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
|
-
const CONFIG_EXTENSIONS = [
|
|
34
|
+
const CONFIG_EXTENSIONS = [
|
|
35
|
+
".ts",
|
|
36
|
+
".js",
|
|
37
|
+
".mjs",
|
|
38
|
+
".cjs",
|
|
39
|
+
".mts",
|
|
40
|
+
".cts"
|
|
41
|
+
];
|
|
29
42
|
function isServerConfigFile(sourcePath, resolvedPath, configFileName) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const name = node_path.basename(sourcePath);
|
|
34
|
-
return name === configFileName || CONFIG_EXTENSIONS.some((ext) => name === `${configFileName}${ext}`);
|
|
43
|
+
if (sourcePath === resolvedPath) return true;
|
|
44
|
+
const name = (0, node_path.basename)(sourcePath);
|
|
45
|
+
return name === configFileName || CONFIG_EXTENSIONS.some((ext) => name === `${configFileName}${ext}`);
|
|
35
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
|
|
49
|
+
* by using a regular `import` and load the server after that.
|
|
50
|
+
* This also works with serverless `handler` functions, as it re-exports the `handler`.
|
|
51
|
+
*
|
|
52
|
+
* @param config Configuration options for the Rollup Plugin
|
|
53
|
+
* @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'
|
|
54
|
+
* @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'
|
|
55
|
+
* @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)
|
|
56
|
+
* @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']
|
|
57
|
+
* @param config.debug Whether debug logs are enabled in the build time environment
|
|
58
|
+
*/
|
|
36
59
|
function wrapServerEntryWithDynamicImport(config) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryIdUrl) : "";
|
|
78
|
-
return (
|
|
79
|
-
// Regular `import` of the Sentry config
|
|
80
|
-
`import ${JSON.stringify(configUrl)};
|
|
81
|
-
import(${JSON.stringify(entryIdUrl)});
|
|
82
|
-
${reExportedFunctions}
|
|
83
|
-
`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
60
|
+
const { serverConfigFileName, serverEntrypointFileName, resolvedServerConfigPath, entrypointWrappedFunctions, debug } = config;
|
|
61
|
+
const resolutionIdPrefix = "\0raw";
|
|
62
|
+
return {
|
|
63
|
+
name: "sentry-wrap-server-entry-with-dynamic-import",
|
|
64
|
+
async resolveId(source, importer, options) {
|
|
65
|
+
const resolvable = toResolvablePath(source);
|
|
66
|
+
if (!resolvable) return null;
|
|
67
|
+
const { path: normalizedSource, wasFileUrl } = resolvable;
|
|
68
|
+
if (isServerConfigFile(normalizedSource, resolvedServerConfigPath, serverConfigFileName)) return {
|
|
69
|
+
id: normalizedSource,
|
|
70
|
+
moduleSideEffects: true
|
|
71
|
+
};
|
|
72
|
+
if (options.isEntry && normalizedSource.includes(serverEntrypointFileName) && normalizedSource.includes(".mjs") && !normalizedSource.includes(`.mjs?sentry-query-wrapped-entry`)) {
|
|
73
|
+
const resolution = await this.resolve(normalizedSource, importer, options);
|
|
74
|
+
if (!resolution || resolution?.external) return resolution;
|
|
75
|
+
const moduleInfo = await this.load(resolution);
|
|
76
|
+
moduleInfo.moduleSideEffects = true;
|
|
77
|
+
return resolution.id.includes(`.mjs?sentry-query-wrapped-entry`) ? resolution.id : `${resolutionIdPrefix}${resolution.id.concat(SENTRY_WRAPPED_ENTRY).concat(constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug)).concat(QUERY_END_INDICATOR)}`;
|
|
78
|
+
}
|
|
79
|
+
if (wasFileUrl) {
|
|
80
|
+
const resolved = await this.resolve(normalizedSource, importer, {
|
|
81
|
+
...options,
|
|
82
|
+
isEntry: false
|
|
83
|
+
});
|
|
84
|
+
if (resolved) return resolved;
|
|
85
|
+
return { id: normalizedSource };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
load(id) {
|
|
90
|
+
if (id.includes(`.mjs?sentry-query-wrapped-entry`)) {
|
|
91
|
+
const entryId = removeSentryQueryFromPath(id).slice(4);
|
|
92
|
+
const entryIdUrl = (0, node_url.pathToFileURL)(entryId).href;
|
|
93
|
+
const configUrl = (0, node_url.pathToFileURL)(resolvedServerConfigPath).href;
|
|
94
|
+
const reExportedFunctions = id.includes("?sentry-query-wrapped-functions=") || id.includes("?sentry-query-reexported-functions=") ? constructFunctionReExport(id, entryIdUrl) : "";
|
|
95
|
+
return `import ${JSON.stringify(configUrl)};\nimport(${JSON.stringify(entryIdUrl)});\n${reExportedFunctions}\n`;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
89
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Strips the Sentry query part from a path.
|
|
103
|
+
* Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path
|
|
104
|
+
*
|
|
105
|
+
* **Only exported for testing**
|
|
106
|
+
*/
|
|
90
107
|
function removeSentryQueryFromPath(url) {
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
const regex = new RegExp(`\\${SENTRY_WRAPPED_ENTRY}.*?\\${QUERY_END_INDICATOR}`);
|
|
109
|
+
return url.replace(regex, "");
|
|
93
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Extracts and sanitizes function re-export and function wrap query parameters from a query string.
|
|
113
|
+
* If it is a default export, it is not considered for re-exporting.
|
|
114
|
+
*
|
|
115
|
+
* **Only exported for testing**
|
|
116
|
+
*/
|
|
94
117
|
function extractFunctionReexportQueryParameters(query) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return { wrap, reexport };
|
|
118
|
+
const wrapRegex = new RegExp(`\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR}|\\${SENTRY_REEXPORTED_FUNCTIONS})`);
|
|
119
|
+
const reexportRegex = new RegExp(`\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR})`);
|
|
120
|
+
const wrapMatch = query.match(wrapRegex);
|
|
121
|
+
const reexportMatch = query.match(reexportRegex);
|
|
122
|
+
return {
|
|
123
|
+
wrap: wrapMatch?.[1] ? wrapMatch[1].split(",").filter((param) => param !== "").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : [],
|
|
124
|
+
reexport: reexportMatch?.[1] ? reexportMatch[1].split(",").filter((param) => param !== "" && param !== "default").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : []
|
|
125
|
+
};
|
|
104
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.
|
|
129
|
+
* It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped
|
|
130
|
+
* (e.g. serverless handlers) are wrapped by Sentry.
|
|
131
|
+
*
|
|
132
|
+
* **Only exported for testing**
|
|
133
|
+
*/
|
|
105
134
|
function constructWrappedFunctionExportQuery(exportedBindings, entrypointWrappedFunctions, debug) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
if (debug && functionsToExport.wrap.length === 0) {
|
|
120
|
-
core.consoleSandbox(
|
|
121
|
-
() => (
|
|
122
|
-
// eslint-disable-next-line no-console
|
|
123
|
-
console.warn(
|
|
124
|
-
"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`."
|
|
125
|
-
)
|
|
126
|
-
)
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
const wrapQuery = functionsToExport.wrap.length ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(",")}` : "";
|
|
130
|
-
const reexportQuery = functionsToExport.reexport.length ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(",")}` : "";
|
|
131
|
-
return [wrapQuery, reexportQuery].join("");
|
|
135
|
+
const functionsToExport = {
|
|
136
|
+
wrap: [],
|
|
137
|
+
reexport: []
|
|
138
|
+
};
|
|
139
|
+
Object.values(exportedBindings || {}).forEach((functions) => functions.forEach((fn) => {
|
|
140
|
+
if (entrypointWrappedFunctions.includes(fn)) functionsToExport.wrap.push(fn);
|
|
141
|
+
else functionsToExport.reexport.push(fn);
|
|
142
|
+
}));
|
|
143
|
+
if (debug && functionsToExport.wrap.length === 0) (0, _sentry_core.consoleSandbox)(() => console.warn("[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`."));
|
|
144
|
+
return [functionsToExport.wrap.length ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(",")}` : "", functionsToExport.reexport.length ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(",")}` : ""].join("");
|
|
132
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
|
|
148
|
+
*
|
|
149
|
+
* **Only exported for testing**
|
|
150
|
+
*/
|
|
133
151
|
function constructFunctionReExport(pathWithQuery, entryId) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`async function ${currFunctionName}_sentryWrapped(...args) {
|
|
138
|
-
const res = await import(${JSON.stringify(entryId)});
|
|
139
|
-
return res.${currFunctionName}.call(this, ...args);
|
|
140
|
-
}
|
|
141
|
-
export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
|
|
142
|
-
`
|
|
143
|
-
),
|
|
144
|
-
""
|
|
145
|
-
).concat(
|
|
146
|
-
reexportFunctions.reduce(
|
|
147
|
-
(functionsCode, currFunctionName) => functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
|
|
148
|
-
""
|
|
149
|
-
)
|
|
150
|
-
);
|
|
152
|
+
const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);
|
|
153
|
+
return wrapFunctions.reduce((functionsCode, currFunctionName) => functionsCode.concat(`async function ${currFunctionName}_sentryWrapped(...args) {\n const res = await import(${JSON.stringify(entryId)});\n return res.${currFunctionName}.call(this, ...args);\n}
|
|
154
|
+
export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\n`), "").concat(reexportFunctions.reduce((functionsCode, currFunctionName) => functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`), ""));
|
|
151
155
|
}
|
|
152
|
-
|
|
153
156
|
exports.QUERY_END_INDICATOR = QUERY_END_INDICATOR;
|
|
154
157
|
exports.SENTRY_REEXPORTED_FUNCTIONS = SENTRY_REEXPORTED_FUNCTIONS;
|
|
155
158
|
exports.SENTRY_WRAPPED_ENTRY = SENTRY_WRAPPED_ENTRY;
|
|
@@ -160,4 +163,5 @@ exports.extractFunctionReexportQueryParameters = extractFunctionReexportQueryPar
|
|
|
160
163
|
exports.removeSentryQueryFromPath = removeSentryQueryFromPath;
|
|
161
164
|
exports.toResolvablePath = toResolvablePath;
|
|
162
165
|
exports.wrapServerEntryWithDynamicImport = wrapServerEntryWithDynamicImport;
|
|
163
|
-
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=wrapServerEntryWithDynamicImport.js.map
|