@sentry/solidstart 8.51.0 → 8.52.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.
Files changed (48) hide show
  1. package/build/cjs/config/addInstrumentation.js +185 -0
  2. package/build/cjs/config/addInstrumentation.js.map +1 -0
  3. package/build/cjs/config/withSentry.js +76 -0
  4. package/build/cjs/config/withSentry.js.map +1 -0
  5. package/build/cjs/config/wrapServerEntryWithDynamicImport.js +248 -0
  6. package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -0
  7. package/build/cjs/index.server.js +3 -0
  8. package/build/cjs/index.server.js.map +1 -1
  9. package/build/cjs/vite/buildInstrumentationFile.js +58 -0
  10. package/build/cjs/vite/buildInstrumentationFile.js.map +1 -0
  11. package/build/cjs/vite/sentrySolidStartVite.js +38 -0
  12. package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
  13. package/build/esm/config/addInstrumentation.js +179 -0
  14. package/build/esm/config/addInstrumentation.js.map +1 -0
  15. package/build/esm/config/withSentry.js +71 -0
  16. package/build/esm/config/withSentry.js.map +1 -0
  17. package/build/esm/config/wrapServerEntryWithDynamicImport.js +238 -0
  18. package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -0
  19. package/build/esm/index.server.js +2 -1
  20. package/build/esm/index.server.js.map +1 -1
  21. package/build/esm/package.json +1 -1
  22. package/build/esm/vite/buildInstrumentationFile.js +56 -0
  23. package/build/esm/vite/buildInstrumentationFile.js.map +1 -0
  24. package/build/esm/vite/sentrySolidStartVite.js +38 -1
  25. package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
  26. package/build/types/config/addInstrumentation.d.ts +36 -0
  27. package/build/types/config/addInstrumentation.d.ts.map +1 -0
  28. package/build/types/config/index.d.ts +2 -0
  29. package/build/types/config/index.d.ts.map +1 -0
  30. package/build/types/config/types.d.ts +13 -0
  31. package/build/types/config/types.d.ts.map +1 -0
  32. package/build/types/config/utils.d.ts +26 -0
  33. package/build/types/config/utils.d.ts.map +1 -0
  34. package/build/types/config/withSentry.d.ts +13 -0
  35. package/build/types/config/withSentry.d.ts.map +1 -0
  36. package/build/types/config/wrapServerEntryWithDynamicImport.d.ts +60 -0
  37. package/build/types/config/wrapServerEntryWithDynamicImport.d.ts.map +1 -0
  38. package/build/types/index.server.d.ts +1 -0
  39. package/build/types/index.server.d.ts.map +1 -1
  40. package/build/types/index.types.d.ts +1 -0
  41. package/build/types/index.types.d.ts.map +1 -1
  42. package/build/types/vite/buildInstrumentationFile.d.ts +8 -0
  43. package/build/types/vite/buildInstrumentationFile.d.ts.map +1 -0
  44. package/build/types/vite/sentrySolidStartVite.d.ts +22 -1
  45. package/build/types/vite/sentrySolidStartVite.d.ts.map +1 -1
  46. package/build/types/vite/types.d.ts +52 -1
  47. package/build/types/vite/types.d.ts.map +1 -1
  48. package/package.json +5 -5
@@ -0,0 +1,185 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const core = require('@sentry/core');
6
+ const wrapServerEntryWithDynamicImport = require('./wrapServerEntryWithDynamicImport.js');
7
+
8
+ // Nitro presets for hosts that only host static files
9
+ const staticHostPresets = ['github_pages'];
10
+ // Nitro presets for hosts that use `server.mjs` as opposed to `index.mjs`
11
+ const serverFilePresets = ['netlify'];
12
+
13
+ /**
14
+ * Adds the built `instrument.server.js` file to the output directory.
15
+ *
16
+ * As Sentry also imports the release injection file, this needs to be copied over manually as well.
17
+ * TODO: The mechanism of manually copying those files could maybe be improved
18
+ *
19
+ * This will no-op if no `instrument.server.js` file was found in the
20
+ * build directory.
21
+ */
22
+ async function addInstrumentationFileToBuild(nitro) {
23
+ nitro.hooks.hook('close', async () => {
24
+ // Static file hosts have no server component so there's nothing to do
25
+ if (staticHostPresets.includes(nitro.options.preset)) {
26
+ return;
27
+ }
28
+
29
+ const buildDir = nitro.options.buildDir;
30
+ const serverDir = nitro.options.output.serverDir;
31
+
32
+ try {
33
+ // 1. Create assets directory first (for release-injection-file)
34
+ const assetsServerDir = path.join(serverDir, 'assets');
35
+ if (!fs.existsSync(assetsServerDir)) {
36
+ await fs.promises.mkdir(assetsServerDir, { recursive: true });
37
+ core.consoleSandbox(() => {
38
+ // eslint-disable-next-line no-console
39
+ console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);
40
+ });
41
+ }
42
+
43
+ // 2. Copy release injection file if available
44
+ try {
45
+ const ssrAssetsPath = path.resolve(buildDir, 'build', 'ssr', 'assets');
46
+ const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath);
47
+ const releaseInjectionFile = assetsBuildDir.find(file => file.startsWith('_sentry-release-injection-file-'));
48
+
49
+ if (releaseInjectionFile) {
50
+ const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);
51
+ const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);
52
+
53
+ await fs.promises.copyFile(releaseSource, releaseDestination);
54
+ core.consoleSandbox(() => {
55
+ // eslint-disable-next-line no-console
56
+ console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);
57
+ });
58
+ }
59
+ } catch (err) {
60
+ core.consoleSandbox(() => {
61
+ // eslint-disable-next-line no-console
62
+ console.warn('[Sentry SolidStart withSentry] Failed to copy release injection file.', err);
63
+ });
64
+ }
65
+
66
+ // 3. Copy Sentry server instrumentation file
67
+ const instrumentSource = path.resolve(buildDir, 'build', 'ssr', 'instrument.server.js');
68
+ const instrumentDestination = path.resolve(serverDir, 'instrument.server.mjs');
69
+
70
+ await fs.promises.copyFile(instrumentSource, instrumentDestination);
71
+ core.consoleSandbox(() => {
72
+ // eslint-disable-next-line no-console
73
+ console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);
74
+ });
75
+ } catch (error) {
76
+ core.consoleSandbox(() => {
77
+ // eslint-disable-next-line no-console
78
+ console.warn('[Sentry SolidStart withSentry] Failed to add instrumentation file to build.', error);
79
+ });
80
+ }
81
+ });
82
+ }
83
+
84
+ /**
85
+ * Adds an `instrument.server.mjs` import to the top of the server entry file.
86
+ *
87
+ * This is meant as an escape hatch and should only be used in environments where
88
+ * it's not possible to `--import` the file instead as it comes with a limited
89
+ * tracing experience, only collecting http traces.
90
+ */
91
+ async function addSentryTopImport(nitro) {
92
+ nitro.hooks.hook('close', async () => {
93
+ const buildPreset = nitro.options.preset;
94
+ const serverDir = nitro.options.output.serverDir;
95
+
96
+ // Static file hosts have no server component so there's nothing to do
97
+ if (staticHostPresets.includes(buildPreset)) {
98
+ return;
99
+ }
100
+
101
+ const instrumentationFile = path.resolve(serverDir, 'instrument.server.mjs');
102
+ const serverEntryFileName = serverFilePresets.includes(buildPreset) ? 'server.mjs' : 'index.mjs';
103
+ const serverEntryFile = path.resolve(serverDir, serverEntryFileName);
104
+
105
+ try {
106
+ await fs.promises.access(instrumentationFile, fs.constants.F_OK);
107
+ } catch (error) {
108
+ core.consoleSandbox(() => {
109
+ // eslint-disable-next-line no-console
110
+ console.warn(
111
+ `[Sentry SolidStart withSentry] Failed to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
112
+ error,
113
+ );
114
+ });
115
+ return;
116
+ }
117
+
118
+ try {
119
+ const content = await fs.promises.readFile(serverEntryFile, 'utf-8');
120
+ const updatedContent = `import './instrument.server.mjs';\n${content}`;
121
+ await fs.promises.writeFile(serverEntryFile, updatedContent);
122
+
123
+ core.consoleSandbox(() => {
124
+ // eslint-disable-next-line no-console
125
+ console.log(
126
+ `[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
127
+ );
128
+ });
129
+ } catch (error) {
130
+ // eslint-disable-next-line no-console
131
+ console.warn(
132
+ `[Sentry SolidStart withSentry] An error occurred when trying to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
133
+ error,
134
+ );
135
+ }
136
+ });
137
+ }
138
+
139
+ /**
140
+ * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)
141
+ * and adds the Sentry server config with the static `import` declaration.
142
+ *
143
+ * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).
144
+ * See: https://nodejs.org/api/module.html#enabling
145
+ */
146
+ async function addDynamicImportEntryFileWrapper({
147
+ nitro,
148
+ rollupConfig,
149
+ sentryPluginOptions,
150
+ }
151
+
152
+ ) {
153
+ // Static file hosts have no server component so there's nothing to do
154
+ if (staticHostPresets.includes(nitro.options.preset)) {
155
+ return;
156
+ }
157
+
158
+ const srcDir = nitro.options.srcDir;
159
+ // todo allow other instrumentation paths
160
+ const serverInstrumentationPath = path.resolve(srcDir, 'src', 'instrument.server.ts');
161
+
162
+ const instrumentationFileName = sentryPluginOptions.instrumentation
163
+ ? path.basename(sentryPluginOptions.instrumentation)
164
+ : '';
165
+
166
+ rollupConfig.plugins.push(
167
+ wrapServerEntryWithDynamicImport.wrapServerEntryWithDynamicImport({
168
+ serverConfigFileName: sentryPluginOptions.instrumentation
169
+ ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name)
170
+ : 'instrument.server',
171
+ serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,
172
+ resolvedServerConfigPath: serverInstrumentationPath,
173
+ entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,
174
+ additionalImports: ['import-in-the-middle/hook.mjs'],
175
+ debug: sentryPluginOptions.debug,
176
+ }),
177
+ );
178
+ }
179
+
180
+ exports.addDynamicImportEntryFileWrapper = addDynamicImportEntryFileWrapper;
181
+ exports.addInstrumentationFileToBuild = addInstrumentationFileToBuild;
182
+ exports.addSentryTopImport = addSentryTopImport;
183
+ exports.serverFilePresets = serverFilePresets;
184
+ exports.staticHostPresets = staticHostPresets;
185
+ //# sourceMappingURL=addInstrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addInstrumentation.js","sources":["../../../src/config/addInstrumentation.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { consoleSandbox } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport type { SentrySolidStartPluginOptions } from '../vite/types';\nimport type { RollupConfig } from './types';\nimport { wrapServerEntryWithDynamicImport } from './wrapServerEntryWithDynamicImport';\n\n// Nitro presets for hosts that only host static files\nexport const staticHostPresets = ['github_pages'];\n// Nitro presets for hosts that use `server.mjs` as opposed to `index.mjs`\nexport const serverFilePresets = ['netlify'];\n\n/**\n * Adds the built `instrument.server.js` file to the output directory.\n *\n * As Sentry also imports the release injection file, this needs to be copied over manually as well.\n * TODO: The mechanism of manually copying those files could maybe be improved\n *\n * This will no-op if no `instrument.server.js` file was found in the\n * build directory.\n */\nexport async function addInstrumentationFileToBuild(nitro: Nitro): Promise<void> {\n nitro.hooks.hook('close', async () => {\n // Static file hosts have no server component so there's nothing to do\n if (staticHostPresets.includes(nitro.options.preset)) {\n return;\n }\n\n const buildDir = nitro.options.buildDir;\n const serverDir = nitro.options.output.serverDir;\n\n try {\n // 1. Create assets directory first (for release-injection-file)\n const assetsServerDir = path.join(serverDir, 'assets');\n if (!fs.existsSync(assetsServerDir)) {\n await fs.promises.mkdir(assetsServerDir, { recursive: true });\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);\n });\n }\n\n // 2. Copy release injection file if available\n try {\n const ssrAssetsPath = path.resolve(buildDir, 'build', 'ssr', 'assets');\n const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath);\n const releaseInjectionFile = assetsBuildDir.find(file => file.startsWith('_sentry-release-injection-file-'));\n\n if (releaseInjectionFile) {\n const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);\n const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);\n\n await fs.promises.copyFile(releaseSource, releaseDestination);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);\n });\n }\n } catch (err) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry SolidStart withSentry] Failed to copy release injection file.', err);\n });\n }\n\n // 3. Copy Sentry server instrumentation file\n const instrumentSource = path.resolve(buildDir, 'build', 'ssr', 'instrument.server.js');\n const instrumentDestination = path.resolve(serverDir, 'instrument.server.mjs');\n\n await fs.promises.copyFile(instrumentSource, instrumentDestination);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);\n });\n } catch (error) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry SolidStart withSentry] Failed to add instrumentation file to build.', error);\n });\n }\n });\n}\n\n/**\n * Adds an `instrument.server.mjs` import to the top of the server entry file.\n *\n * This is meant as an escape hatch and should only be used in environments where\n * it's not possible to `--import` the file instead as it comes with a limited\n * tracing experience, only collecting http traces.\n */\nexport async function addSentryTopImport(nitro: Nitro): Promise<void> {\n nitro.hooks.hook('close', async () => {\n const buildPreset = nitro.options.preset;\n const serverDir = nitro.options.output.serverDir;\n\n // Static file hosts have no server component so there's nothing to do\n if (staticHostPresets.includes(buildPreset)) {\n return;\n }\n\n const instrumentationFile = path.resolve(serverDir, 'instrument.server.mjs');\n const serverEntryFileName = serverFilePresets.includes(buildPreset) ? 'server.mjs' : 'index.mjs';\n const serverEntryFile = path.resolve(serverDir, serverEntryFileName);\n\n try {\n await fs.promises.access(instrumentationFile, fs.constants.F_OK);\n } catch (error) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry SolidStart withSentry] Failed to add \\`${instrumentationFile}\\` as top level import to \\`${serverEntryFile}\\`.`,\n error,\n );\n });\n return;\n }\n\n try {\n const content = await fs.promises.readFile(serverEntryFile, 'utf-8');\n const updatedContent = `import './instrument.server.mjs';\\n${content}`;\n await fs.promises.writeFile(serverEntryFile, updatedContent);\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry SolidStart withSentry] Added \\`${instrumentationFile}\\` as top level import to \\`${serverEntryFile}\\`.`,\n );\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry SolidStart withSentry] An error occurred when trying to add \\`${instrumentationFile}\\` as top level import to \\`${serverEntryFile}\\`.`,\n error,\n );\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport async function addDynamicImportEntryFileWrapper({\n nitro,\n rollupConfig,\n sentryPluginOptions,\n}: {\n nitro: Nitro;\n rollupConfig: RollupConfig;\n sentryPluginOptions: Omit<SentrySolidStartPluginOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentrySolidStartPluginOptions, 'experimental_entrypointWrappedFunctions'>>;\n}): Promise<void> {\n // Static file hosts have no server component so there's nothing to do\n if (staticHostPresets.includes(nitro.options.preset)) {\n return;\n }\n\n const srcDir = nitro.options.srcDir;\n // todo allow other instrumentation paths\n const serverInstrumentationPath = path.resolve(srcDir, 'src', 'instrument.server.ts');\n\n const instrumentationFileName = sentryPluginOptions.instrumentation\n ? path.basename(sentryPluginOptions.instrumentation)\n : '';\n\n rollupConfig.plugins.push(\n wrapServerEntryWithDynamicImport({\n serverConfigFileName: sentryPluginOptions.instrumentation\n ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name)\n : 'instrument.server',\n serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,\n resolvedServerConfigPath: serverInstrumentationPath,\n entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,\n additionalImports: ['import-in-the-middle/hook.mjs'],\n debug: sentryPluginOptions.debug,\n }),\n );\n}\n"],"names":["consoleSandbox","wrapServerEntryWithDynamicImport"],"mappings":";;;;;;;AAQA;AACa,MAAA,iB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A,yBAAA;AACA,MAAA,0BAAA,EAAA,mBAAA,CAAA,uCAAA;AACA,MAAA,iBAAA,EAAA,CAAA,+BAAA,CAAA;AACA,MAAA,KAAA,EAAA,mBAAA,CAAA,KAAA;AACA,KAAA,CAAA;AACA,GAAA;AACA;;;;;;;;"}
@@ -0,0 +1,76 @@
1
+ var {
2
+ _optionalChain
3
+ } = require('@sentry/core');
4
+
5
+ Object.defineProperty(exports, '__esModule', { value: true });
6
+
7
+ const core = require('@sentry/core');
8
+ const sentrySolidStartVite = require('../vite/sentrySolidStartVite.js');
9
+ const addInstrumentation = require('./addInstrumentation.js');
10
+
11
+ const defaultSentrySolidStartPluginOptions
12
+
13
+ = {
14
+ experimental_entrypointWrappedFunctions: ['default', 'handler', 'server'],
15
+ };
16
+
17
+ /**
18
+ * Modifies the passed in Solid Start configuration with build-time enhancements such as
19
+ * building the `instrument.server.ts` file into the appropriate build folder based on
20
+ * build preset.
21
+ *
22
+ * @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`
23
+ * @param sentrySolidStartPluginOptions Options to configure the plugin
24
+ * @returns The modified config to be exported and passed back into `defineConfig`
25
+ */
26
+ function withSentry(
27
+ solidStartConfig = {},
28
+ sentrySolidStartPluginOptions,
29
+ ) {
30
+ const sentryPluginOptions = {
31
+ ...sentrySolidStartPluginOptions,
32
+ ...defaultSentrySolidStartPluginOptions,
33
+ };
34
+
35
+ const server = (solidStartConfig.server || {}) ;
36
+ const hooks = server.hooks || {};
37
+ const vite =
38
+ typeof solidStartConfig.vite === 'function'
39
+ ? (...args) => sentrySolidStartVite.addSentryPluginToVite(solidStartConfig.vite(...args), sentryPluginOptions)
40
+ : sentrySolidStartVite.addSentryPluginToVite(solidStartConfig.vite, sentryPluginOptions);
41
+
42
+ return {
43
+ ...solidStartConfig,
44
+ vite,
45
+ server: {
46
+ ...server,
47
+ hooks: {
48
+ ...hooks,
49
+ async 'rollup:before'(nitro, config) {
50
+ if (_optionalChain([sentrySolidStartPluginOptions, 'optionalAccess', _ => _.autoInjectServerSentry]) === 'experimental_dynamic-import') {
51
+ await addInstrumentation.addDynamicImportEntryFileWrapper({ nitro, rollupConfig: config, sentryPluginOptions });
52
+
53
+ sentrySolidStartPluginOptions.debug &&
54
+ core.logger.log(
55
+ 'Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',
56
+ );
57
+ } else {
58
+ await addInstrumentation.addInstrumentationFileToBuild(nitro);
59
+
60
+ if (_optionalChain([sentrySolidStartPluginOptions, 'optionalAccess', _2 => _2.autoInjectServerSentry]) === 'top-level-import') {
61
+ await addInstrumentation.addSentryTopImport(nitro);
62
+ }
63
+ }
64
+
65
+ // Run user provided hook
66
+ if (hooks['rollup:before']) {
67
+ hooks['rollup:before'](nitro);
68
+ }
69
+ },
70
+ },
71
+ },
72
+ };
73
+ }
74
+
75
+ exports.withSentry = withSentry;
76
+ //# sourceMappingURL=withSentry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withSentry.js","sources":["../../../src/config/withSentry.ts"],"sourcesContent":["import { logger } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport { addSentryPluginToVite } from '../vite';\nimport type { SentrySolidStartPluginOptions } from '../vite/types';\nimport {\n addDynamicImportEntryFileWrapper,\n addInstrumentationFileToBuild,\n addSentryTopImport,\n} from './addInstrumentation';\nimport type { RollupConfig, SolidStartInlineConfig, SolidStartInlineServerConfig } from './types';\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 const hooks = server.hooks || {};\n const vite =\n typeof solidStartConfig.vite === 'function'\n ? (...args: unknown[]) => addSentryPluginToVite(solidStartConfig.vite(...args), sentryPluginOptions)\n : addSentryPluginToVite(solidStartConfig.vite, sentryPluginOptions);\n\n return {\n ...solidStartConfig,\n vite,\n server: {\n ...server,\n hooks: {\n ...hooks,\n async 'rollup:before'(nitro: Nitro, config: RollupConfig) {\n if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {\n await addDynamicImportEntryFileWrapper({ nitro, rollupConfig: config, sentryPluginOptions });\n\n sentrySolidStartPluginOptions.debug &&\n logger.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 // Run user provided hook\n if (hooks['rollup:before']) {\n hooks['rollup:before'](nitro);\n }\n },\n },\n },\n };\n}\n"],"names":["addSentryPluginToVite","addDynamicImportEntryFileWrapper","logger","addInstrumentationFileToBuild","addSentryTopImport"],"mappings":";;;;;;;;;;AAWA,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CA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AAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAkB,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC;YAC7C;UACA;;UAEA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;UACU,CAAI,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAC,EAAE;YAC1B,KAAK,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAC,CAAC,KAAK,CAAC;UACzC;QACS,CAAA;MACF,CAAA;IACF,CAAA;EACF,CAAA;AACH;;"}
@@ -0,0 +1,248 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ const core = require('@sentry/core');
4
+
5
+ /** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */
6
+
7
+ const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';
8
+ const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';
9
+ const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';
10
+ const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';
11
+
12
+ /**
13
+ * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
14
+ * by using a regular `import` and load the server after that.
15
+ * This also works with serverless `handler` functions, as it re-exports the `handler`.
16
+ *
17
+ * @param config Configuration options for the Rollup Plugin
18
+ * @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'
19
+ * @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'
20
+ * @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)
21
+ * @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']
22
+ * @param config.additionalImports Adds additional imports to the entry file. Can be e.g. 'import-in-the-middle/hook.mjs'
23
+ * @param config.debug Whether debug logs are enabled in the build time environment
24
+ */
25
+ function wrapServerEntryWithDynamicImport(config) {
26
+ const {
27
+ serverConfigFileName,
28
+ serverEntrypointFileName,
29
+ resolvedServerConfigPath,
30
+ entrypointWrappedFunctions,
31
+ additionalImports,
32
+ debug,
33
+ } = config;
34
+
35
+ // In order to correctly import the server config file
36
+ // and dynamically import the nitro runtime, we need to
37
+ // mark the resolutionId with '\0raw' to fall into the
38
+ // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142
39
+ const resolutionIdPrefix = '\0raw';
40
+
41
+ return {
42
+ name: 'sentry-wrap-server-entry-with-dynamic-import',
43
+ async resolveId(source, importer, options) {
44
+ if (source.includes(`/${serverConfigFileName}`)) {
45
+ return { id: source, moduleSideEffects: true };
46
+ }
47
+
48
+ if (additionalImports && additionalImports.includes(source)) {
49
+ // When importing additional imports like "import-in-the-middle/hook.mjs" in the returned code of the `load()` function below:
50
+ // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it
51
+ // 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()`.
52
+ // Prevents the error "Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'"
53
+ return { id: source, moduleSideEffects: true, external: true };
54
+ }
55
+
56
+ if (
57
+ options.isEntry &&
58
+ source.includes(serverEntrypointFileName) &&
59
+ source.includes('.mjs') &&
60
+ !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)
61
+ ) {
62
+ const resolution = await this.resolve(source, importer, options);
63
+
64
+ // If it cannot be resolved or is external, just return it so that Rollup can display an error
65
+ if (!resolution || (resolution && resolution.external)) return resolution;
66
+
67
+ const moduleInfo = await this.load(resolution);
68
+
69
+ moduleInfo.moduleSideEffects = true;
70
+
71
+ // 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
72
+ return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)
73
+ ? resolution.id
74
+ : `${resolutionIdPrefix}${resolution.id
75
+ // 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)
76
+ .concat(SENTRY_WRAPPED_ENTRY)
77
+ .concat(
78
+ constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug),
79
+ )
80
+ .concat(QUERY_END_INDICATOR)}`;
81
+ }
82
+ return null;
83
+ },
84
+ load(id) {
85
+ if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
86
+ const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);
87
+
88
+ // Mostly useful for serverless `handler` functions
89
+ const reExportedFunctions =
90
+ id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)
91
+ ? constructFunctionReExport(id, entryId)
92
+ : '';
93
+
94
+ return (
95
+ // Regular `import` of the Sentry config
96
+ `import ${JSON.stringify(resolvedServerConfigPath)};\n` +
97
+ // Dynamic `import()` for the previous, actual entry point.
98
+ // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)
99
+ `import(${JSON.stringify(entryId)});\n` +
100
+ // By importing additional imports like "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()`.
101
+ `${additionalImports ? additionalImports.map(importPath => `import "${importPath}";\n`) : ''}` +
102
+ `${reExportedFunctions}\n`
103
+ );
104
+ }
105
+
106
+ return null;
107
+ },
108
+ };
109
+ }
110
+
111
+ /**
112
+ * Strips the Sentry query part from a path.
113
+ * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path
114
+ *
115
+ * **Only exported for testing**
116
+ */
117
+ function removeSentryQueryFromPath(url) {
118
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
119
+ const regex = new RegExp(`\\${SENTRY_WRAPPED_ENTRY}.*?\\${QUERY_END_INDICATOR}`);
120
+ return url.replace(regex, '');
121
+ }
122
+
123
+ /**
124
+ * Extracts and sanitizes function re-export and function wrap query parameters from a query string.
125
+ * If it is a default export, it is not considered for re-exporting.
126
+ *
127
+ * **Only exported for testing**
128
+ */
129
+ function extractFunctionReexportQueryParameters(query) {
130
+ // Regex matches the comma-separated params between the functions query
131
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
132
+ const wrapRegex = new RegExp(
133
+ `\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR}|\\${SENTRY_REEXPORTED_FUNCTIONS})`,
134
+ );
135
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
136
+ const reexportRegex = new RegExp(`\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR})`);
137
+
138
+ const wrapMatch = query.match(wrapRegex);
139
+ const reexportMatch = query.match(reexportRegex);
140
+
141
+ const wrap =
142
+ wrapMatch && wrapMatch[1]
143
+ ? wrapMatch[1]
144
+ .split(',')
145
+ .filter(param => param !== '')
146
+ // Sanitize, as code could be injected with another rollup plugin
147
+ .map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
148
+ : [];
149
+
150
+ const reexport =
151
+ reexportMatch && reexportMatch[1]
152
+ ? reexportMatch[1]
153
+ .split(',')
154
+ .filter(param => param !== '' && param !== 'default')
155
+ // Sanitize, as code could be injected with another rollup plugin
156
+ .map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
157
+ : [];
158
+
159
+ return { wrap, reexport };
160
+ }
161
+
162
+ /**
163
+ * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.
164
+ * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped
165
+ * (e.g. serverless handlers) are wrapped by Sentry.
166
+ *
167
+ * **Only exported for testing**
168
+ */
169
+ function constructWrappedFunctionExportQuery(
170
+ exportedBindings,
171
+ entrypointWrappedFunctions,
172
+ debug,
173
+ ) {
174
+ const functionsToExport = {
175
+ wrap: [],
176
+ reexport: [],
177
+ };
178
+
179
+ // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`
180
+ // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.
181
+ Object.values(exportedBindings || {}).forEach(functions =>
182
+ functions.forEach(fn => {
183
+ if (entrypointWrappedFunctions.includes(fn)) {
184
+ functionsToExport.wrap.push(fn);
185
+ } else {
186
+ functionsToExport.reexport.push(fn);
187
+ }
188
+ }),
189
+ );
190
+
191
+ if (debug && functionsToExport.wrap.length === 0) {
192
+ core.consoleSandbox(() =>
193
+ // eslint-disable-next-line no-console
194
+ console.warn(
195
+ '[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`.',
196
+ ),
197
+ );
198
+ }
199
+
200
+ const wrapQuery = functionsToExport.wrap.length
201
+ ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`
202
+ : '';
203
+ const reexportQuery = functionsToExport.reexport.length
204
+ ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`
205
+ : '';
206
+
207
+ return [wrapQuery, reexportQuery].join('');
208
+ }
209
+
210
+ /**
211
+ * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
212
+ *
213
+ * **Only exported for testing**
214
+ */
215
+ function constructFunctionReExport(pathWithQuery, entryId) {
216
+ const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);
217
+
218
+ return wrapFunctions
219
+ .reduce(
220
+ (functionsCode, currFunctionName) =>
221
+ functionsCode.concat(
222
+ `async function ${currFunctionName}_sentryWrapped(...args) {\n` +
223
+ ` const res = await import(${JSON.stringify(entryId)});\n` +
224
+ ` return res.${currFunctionName}.call(this, ...args);\n` +
225
+ '}\n' +
226
+ `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\n`,
227
+ ),
228
+ '',
229
+ )
230
+ .concat(
231
+ reexportFunctions.reduce(
232
+ (functionsCode, currFunctionName) =>
233
+ functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
234
+ '',
235
+ ),
236
+ );
237
+ }
238
+
239
+ exports.QUERY_END_INDICATOR = QUERY_END_INDICATOR;
240
+ exports.SENTRY_REEXPORTED_FUNCTIONS = SENTRY_REEXPORTED_FUNCTIONS;
241
+ exports.SENTRY_WRAPPED_ENTRY = SENTRY_WRAPPED_ENTRY;
242
+ exports.SENTRY_WRAPPED_FUNCTIONS = SENTRY_WRAPPED_FUNCTIONS;
243
+ exports.constructFunctionReExport = constructFunctionReExport;
244
+ exports.constructWrappedFunctionExportQuery = constructWrappedFunctionExportQuery;
245
+ exports.extractFunctionReexportQueryParameters = extractFunctionReexportQueryParameters;
246
+ exports.removeSentryQueryFromPath = removeSentryQueryFromPath;
247
+ exports.wrapServerEntryWithDynamicImport = wrapServerEntryWithDynamicImport;
248
+ //# sourceMappingURL=wrapServerEntryWithDynamicImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapServerEntryWithDynamicImport.js","sources":["../../../src/config/wrapServerEntryWithDynamicImport.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\nimport type { InputPluginOption } from 'rollup';\n\n/** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\nexport type WrapServerEntryPluginOptions = {\n serverEntrypointFileName: string;\n serverConfigFileName: string;\n resolvedServerConfigPath: string;\n entrypointWrappedFunctions: string[];\n additionalImports?: string[];\n debug?: boolean;\n};\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n *\n * @param config Configuration options for the Rollup Plugin\n * @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'\n * @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'\n * @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)\n * @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']\n * @param config.additionalImports Adds additional imports to the entry file. Can be e.g. 'import-in-the-middle/hook.mjs'\n * @param config.debug Whether debug logs are enabled in the build time environment\n */\nexport function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOptions): InputPluginOption {\n const {\n serverConfigFileName,\n serverEntrypointFileName,\n resolvedServerConfigPath,\n entrypointWrappedFunctions,\n additionalImports,\n debug,\n } = config;\n\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-server-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${serverConfigFileName}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (additionalImports && additionalImports.includes(source)) {\n // When importing additional imports like \"import-in-the-middle/hook.mjs\" in the returned code of the `load()` function below:\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // 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()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (\n options.isEntry &&\n source.includes(serverEntrypointFileName) &&\n source.includes('.mjs') &&\n !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || (resolution && resolution.external)) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // 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\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // 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)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedServerConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n // By importing additional imports like \"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()`.\n `${additionalImports ? additionalImports.map(importPath => `import \"${importPath}\";\\n`) : ''}` +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * **Only exported for testing**\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * **Only exported for testing**\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch && wrapMatch[1]\n ? wrapMatch[1]\n .split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n const reexport =\n reexportMatch && reexportMatch[1]\n ? reexportMatch[1]\n .split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n *\n * **Only exported for testing**\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n '[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`.',\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n *\n * **Only exported for testing**\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n"],"names":["consoleSandbox"],"mappings":";;;;AAGA;;AAEO,MAAM,oBAAqB,GAAE;AAC7B,MAAM,wBAAyB,GAAE;AACjC,MAAM,2BAA4B,GAAE;AACpC,MAAM,mBAAoB,GAAE;;AAWnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,MAAM,EAAmD;AAC1G,EAAE,MAAM;AACR,IAAI,oBAAoB;AACxB,IAAI,wBAAwB;AAC5B,IAAI,wBAAwB;AAC5B,IAAI,0BAA0B;AAC9B,IAAI,iBAAiB;AACrB,IAAI,KAAK;AACT,GAAE,GAAI,MAAM;;AAEZ;AACA;AACA;AACA;AACA,EAAE,MAAM,kBAAmB,GAAE,OAAO;;AAEpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,8CAA8C;AACxD,IAAI,MAAM,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC/C,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAA,CAAA,EA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MAAA;AACA,UAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,2BAAA,CAAA;AACA,YAAA,CAAA,2BAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA;AACA,YAAA,CAAA,aAAA,EAAA,gBAAA,CAAA,uBAAA,CAAA;AACA,YAAA,KAAA;AACA,YAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,kBAAA,EAAA,gBAAA,CAAA,KAAA,CAAA;AACA,SAAA;AACA,MAAA,EAAA;AACA;AACA,KAAA,MAAA;AACA,MAAA,iBAAA,CAAA,MAAA;AACA,QAAA,CAAA,aAAA,EAAA,gBAAA;AACA,UAAA,aAAA,CAAA,MAAA,CAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,QAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,QAAA,EAAA;AACA,OAAA;AACA,KAAA;AACA;;;;;;;;;;;;"}
@@ -6,6 +6,7 @@ const sdk = require('./server/sdk.js');
6
6
  const withServerActionInstrumentation = require('./server/withServerActionInstrumentation.js');
7
7
  const middleware = require('./server/middleware.js');
8
8
  const sentrySolidStartVite = require('./vite/sentrySolidStartVite.js');
9
+ const withSentry = require('./config/withSentry.js');
9
10
 
10
11
 
11
12
 
@@ -132,7 +133,9 @@ exports.withSentryErrorBoundary = solid.withSentryErrorBoundary;
132
133
  exports.init = sdk.init;
133
134
  exports.withServerActionInstrumentation = withServerActionInstrumentation.withServerActionInstrumentation;
134
135
  exports.sentryBeforeResponseMiddleware = middleware.sentryBeforeResponseMiddleware;
136
+ exports.addSentryPluginToVite = sentrySolidStartVite.addSentryPluginToVite;
135
137
  exports.sentrySolidStartVite = sentrySolidStartVite.sentrySolidStartVite;
138
+ exports.withSentry = withSentry.withSentry;
136
139
  Object.prototype.hasOwnProperty.call(node, '__proto__') &&
137
140
  !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
138
141
  Object.defineProperty(exports, '__proto__', {
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}