@sentry/solidstart 11.12.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.
Files changed (101) hide show
  1. package/build/cjs/_virtual/_rolldown/runtime.js +34 -0
  2. package/build/cjs/client/index.js +11 -18
  3. package/build/cjs/client/sdk.js +19 -20
  4. package/build/cjs/client/sdk.js.map +1 -1
  5. package/build/cjs/client/solidrouter.js +8 -16
  6. package/build/cjs/common/tunnel.js +11 -8
  7. package/build/cjs/common/tunnel.js.map +1 -1
  8. package/build/cjs/config/addInstrumentation.js +110 -111
  9. package/build/cjs/config/addInstrumentation.js.map +1 -1
  10. package/build/cjs/config/index.js +2 -0
  11. package/build/cjs/config/withSentry.js +86 -87
  12. package/build/cjs/config/withSentry.js.map +1 -1
  13. package/build/cjs/config/wrapServerEntryWithDynamicImport.js +139 -135
  14. package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  15. package/build/cjs/index.client.js +12 -18
  16. package/build/cjs/index.server.js +162 -159
  17. package/build/cjs/index.server.js.map +1 -1
  18. package/build/cjs/nitro/tunnelPlugin.js +12 -10
  19. package/build/cjs/nitro/tunnelPlugin.js.map +1 -1
  20. package/build/cjs/server/index.js +151 -158
  21. package/build/cjs/server/middleware.js +26 -37
  22. package/build/cjs/server/middleware.js.map +1 -1
  23. package/build/cjs/server/sdk.js +13 -14
  24. package/build/cjs/server/sdk.js.map +1 -1
  25. package/build/cjs/server/solidrouter.js +26 -18
  26. package/build/cjs/server/solidrouter.js.map +1 -1
  27. package/build/cjs/server/utils.js +32 -27
  28. package/build/cjs/server/utils.js.map +1 -1
  29. package/build/cjs/server/withServerActionInstrumentation.js +46 -49
  30. package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
  31. package/build/cjs/solidrouter.client.js +9 -16
  32. package/build/cjs/solidrouter.js +12 -18
  33. package/build/cjs/solidrouter.server.js +3 -8
  34. package/build/cjs/vite/buildInstrumentationFile.js +46 -46
  35. package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
  36. package/build/cjs/vite/index.js +5 -10
  37. package/build/cjs/vite/sentrySolidStart.js +86 -39
  38. package/build/cjs/vite/sentrySolidStart.js.map +1 -1
  39. package/build/cjs/vite/sentrySolidStartVite.js +32 -35
  40. package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
  41. package/build/cjs/vite/sourceMaps.js +117 -152
  42. package/build/cjs/vite/sourceMaps.js.map +1 -1
  43. package/build/esm/client/index.js +2 -3
  44. package/build/esm/client/sdk.js +19 -18
  45. package/build/esm/client/sdk.js.map +1 -1
  46. package/build/esm/client/solidrouter.js +1 -2
  47. package/build/esm/common/tunnel.js +11 -6
  48. package/build/esm/common/tunnel.js.map +1 -1
  49. package/build/esm/config/addInstrumentation.js +107 -109
  50. package/build/esm/config/addInstrumentation.js.map +1 -1
  51. package/build/esm/config/index.js +1 -0
  52. package/build/esm/config/withSentry.js +86 -84
  53. package/build/esm/config/withSentry.js.map +1 -1
  54. package/build/esm/config/wrapServerEntryWithDynamicImport.js +139 -133
  55. package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  56. package/build/esm/index.client.js +3 -3
  57. package/build/esm/index.server.js +14 -10
  58. package/build/esm/index.server.js.map +1 -1
  59. package/build/esm/nitro/tunnelPlugin.js +12 -10
  60. package/build/esm/nitro/tunnelPlugin.js.map +1 -1
  61. package/build/esm/package.json +1 -1
  62. package/build/esm/server/index.js +7 -7
  63. package/build/esm/server/middleware.js +26 -35
  64. package/build/esm/server/middleware.js.map +1 -1
  65. package/build/esm/server/sdk.js +13 -12
  66. package/build/esm/server/sdk.js.map +1 -1
  67. package/build/esm/server/solidrouter.js +25 -16
  68. package/build/esm/server/solidrouter.js.map +1 -1
  69. package/build/esm/server/utils.js +32 -25
  70. package/build/esm/server/utils.js.map +1 -1
  71. package/build/esm/server/withServerActionInstrumentation.js +46 -47
  72. package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
  73. package/build/esm/solidrouter.client.js +2 -2
  74. package/build/esm/solidrouter.js +3 -3
  75. package/build/esm/solidrouter.server.js +1 -2
  76. package/build/esm/vite/buildInstrumentationFile.js +43 -44
  77. package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
  78. package/build/esm/vite/index.js +3 -3
  79. package/build/esm/vite/sentrySolidStart.js +86 -37
  80. package/build/esm/vite/sentrySolidStart.js.map +1 -1
  81. package/build/esm/vite/sentrySolidStartVite.js +32 -33
  82. package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
  83. package/build/esm/vite/sourceMaps.js +117 -150
  84. package/build/esm/vite/sourceMaps.js.map +1 -1
  85. package/package.json +20 -20
  86. package/build/cjs/client/index.js.map +0 -1
  87. package/build/cjs/client/solidrouter.js.map +0 -1
  88. package/build/cjs/index.client.js.map +0 -1
  89. package/build/cjs/server/index.js.map +0 -1
  90. package/build/cjs/solidrouter.client.js.map +0 -1
  91. package/build/cjs/solidrouter.js.map +0 -1
  92. package/build/cjs/solidrouter.server.js.map +0 -1
  93. package/build/cjs/vite/index.js.map +0 -1
  94. package/build/esm/client/index.js.map +0 -1
  95. package/build/esm/client/solidrouter.js.map +0 -1
  96. package/build/esm/index.client.js.map +0 -1
  97. package/build/esm/server/index.js.map +0 -1
  98. package/build/esm/solidrouter.client.js.map +0 -1
  99. package/build/esm/solidrouter.js.map +0 -1
  100. package/build/esm/solidrouter.server.js.map +0 -1
  101. package/build/esm/vite/index.js.map +0 -1
@@ -1,117 +1,115 @@
1
- import { consoleSandbox } from '@sentry/core';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import { wrapServerEntryWithDynamicImport } from './wrapServerEntryWithDynamicImport.js';
5
-
1
+ import { wrapServerEntryWithDynamicImport } from "./wrapServerEntryWithDynamicImport.js";
2
+ import { consoleSandbox } from "@sentry/core";
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ // src/config/addInstrumentation.ts
6
6
  const staticHostPresets = ["github_pages"];
7
7
  const serverFilePresets = ["netlify"];
8
+ /**
9
+ * Adds the built `instrument.server.js` file to the output directory.
10
+ *
11
+ * As Sentry also imports the release injection file, this needs to be copied over manually as well.
12
+ * TODO: The mechanism of manually copying those files could maybe be improved
13
+ *
14
+ * This will no-op if no `instrument.server.js` file was found in the
15
+ * build directory.
16
+ */
8
17
  async function addInstrumentationFileToBuild(nitro) {
9
- nitro.hooks.hook("close", async () => {
10
- if (staticHostPresets.includes(nitro.options.preset)) {
11
- return;
12
- }
13
- const buildDir = nitro.options.buildDir;
14
- const serverDir = nitro.options.output.serverDir;
15
- try {
16
- const assetsServerDir = path.join(serverDir, "assets");
17
- if (!fs.existsSync(assetsServerDir)) {
18
- await fs.promises.mkdir(assetsServerDir, { recursive: true });
19
- consoleSandbox(() => {
20
- console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);
21
- });
22
- }
23
- try {
24
- const ssrAssetsPath = path.resolve(buildDir, "build", "ssr", "assets");
25
- const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath);
26
- const releaseInjectionFile = assetsBuildDir.find(
27
- (file) => /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file)
28
- );
29
- if (releaseInjectionFile) {
30
- const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);
31
- const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);
32
- await fs.promises.copyFile(releaseSource, releaseDestination);
33
- consoleSandbox(() => {
34
- console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);
35
- });
36
- }
37
- } catch (err) {
38
- consoleSandbox(() => {
39
- console.warn("[Sentry SolidStart withSentry] Failed to copy release injection file.", err);
40
- });
41
- }
42
- const instrumentSource = path.resolve(buildDir, "build", "ssr", "instrument.server.js");
43
- const instrumentDestination = path.resolve(serverDir, "instrument.server.mjs");
44
- await fs.promises.copyFile(instrumentSource, instrumentDestination);
45
- consoleSandbox(() => {
46
- console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);
47
- });
48
- } catch (error) {
49
- consoleSandbox(() => {
50
- console.warn("[Sentry SolidStart withSentry] Failed to add instrumentation file to build.", error);
51
- });
52
- }
53
- });
18
+ nitro.hooks.hook("close", async () => {
19
+ if (staticHostPresets.includes(nitro.options.preset)) return;
20
+ const buildDir = nitro.options.buildDir;
21
+ const serverDir = nitro.options.output.serverDir;
22
+ try {
23
+ const assetsServerDir = path.join(serverDir, "assets");
24
+ if (!fs.existsSync(assetsServerDir)) {
25
+ await fs.promises.mkdir(assetsServerDir, { recursive: true });
26
+ consoleSandbox(() => {
27
+ console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);
28
+ });
29
+ }
30
+ try {
31
+ const ssrAssetsPath = path.resolve(buildDir, "build", "ssr", "assets");
32
+ const releaseInjectionFile = (await fs.promises.readdir(ssrAssetsPath)).find((file) => /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file));
33
+ if (releaseInjectionFile) {
34
+ const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);
35
+ const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);
36
+ await fs.promises.copyFile(releaseSource, releaseDestination);
37
+ consoleSandbox(() => {
38
+ console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);
39
+ });
40
+ }
41
+ } catch (err) {
42
+ consoleSandbox(() => {
43
+ console.warn("[Sentry SolidStart withSentry] Failed to copy release injection file.", err);
44
+ });
45
+ }
46
+ const instrumentSource = path.resolve(buildDir, "build", "ssr", "instrument.server.js");
47
+ const instrumentDestination = path.resolve(serverDir, "instrument.server.mjs");
48
+ await fs.promises.copyFile(instrumentSource, instrumentDestination);
49
+ consoleSandbox(() => {
50
+ console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);
51
+ });
52
+ } catch (error) {
53
+ consoleSandbox(() => {
54
+ console.warn("[Sentry SolidStart withSentry] Failed to add instrumentation file to build.", error);
55
+ });
56
+ }
57
+ });
54
58
  }
59
+ /**
60
+ * Adds an `instrument.server.mjs` import to the top of the server entry file.
61
+ *
62
+ * This is meant as an escape hatch and should only be used in environments where
63
+ * it's not possible to `--import` the file instead as it comes with a limited
64
+ * tracing experience, only collecting http traces.
65
+ */
55
66
  async function addSentryTopImport(nitro) {
56
- nitro.hooks.hook("close", async () => {
57
- const buildPreset = nitro.options.preset;
58
- const serverDir = nitro.options.output.serverDir;
59
- if (staticHostPresets.includes(buildPreset)) {
60
- return;
61
- }
62
- const instrumentationFile = path.resolve(serverDir, "instrument.server.mjs");
63
- const serverEntryFileName = serverFilePresets.includes(buildPreset) ? "server.mjs" : "index.mjs";
64
- const serverEntryFile = path.resolve(serverDir, serverEntryFileName);
65
- try {
66
- await fs.promises.access(instrumentationFile, fs.constants.F_OK);
67
- } catch (error) {
68
- consoleSandbox(() => {
69
- console.warn(
70
- `[Sentry SolidStart withSentry] Failed to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
71
- error
72
- );
73
- });
74
- return;
75
- }
76
- try {
77
- const content = await fs.promises.readFile(serverEntryFile, "utf-8");
78
- const updatedContent = `import './instrument.server.mjs';
79
- ${content}`;
80
- await fs.promises.writeFile(serverEntryFile, updatedContent);
81
- consoleSandbox(() => {
82
- console.log(
83
- `[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`
84
- );
85
- });
86
- } catch (error) {
87
- console.warn(
88
- `[Sentry SolidStart withSentry] An error occurred when trying to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
89
- error
90
- );
91
- }
92
- });
67
+ nitro.hooks.hook("close", async () => {
68
+ const buildPreset = nitro.options.preset;
69
+ const serverDir = nitro.options.output.serverDir;
70
+ if (staticHostPresets.includes(buildPreset)) return;
71
+ const instrumentationFile = path.resolve(serverDir, "instrument.server.mjs");
72
+ const serverEntryFileName = serverFilePresets.includes(buildPreset) ? "server.mjs" : "index.mjs";
73
+ const serverEntryFile = path.resolve(serverDir, serverEntryFileName);
74
+ try {
75
+ await fs.promises.access(instrumentationFile, fs.constants.F_OK);
76
+ } catch (error) {
77
+ consoleSandbox(() => {
78
+ console.warn(`[Sentry SolidStart withSentry] Failed to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`, error);
79
+ });
80
+ return;
81
+ }
82
+ try {
83
+ const updatedContent = `import './instrument.server.mjs';\n${await fs.promises.readFile(serverEntryFile, "utf-8")}`;
84
+ await fs.promises.writeFile(serverEntryFile, updatedContent);
85
+ consoleSandbox(() => {
86
+ console.log(`[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`);
87
+ });
88
+ } catch (error) {
89
+ console.warn(`[Sentry SolidStart withSentry] An error occurred when trying to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`, error);
90
+ }
91
+ });
93
92
  }
94
- async function addDynamicImportEntryFileWrapper({
95
- nitro,
96
- rollupConfig,
97
- sentryPluginOptions
98
- }) {
99
- if (staticHostPresets.includes(nitro.options.preset)) {
100
- return;
101
- }
102
- const srcDir = nitro.options.srcDir;
103
- const serverInstrumentationPath = path.resolve(srcDir, "src", "instrument.server.ts");
104
- const instrumentationFileName = sentryPluginOptions.instrumentation ? path.basename(sentryPluginOptions.instrumentation) : "";
105
- rollupConfig.plugins.push(
106
- wrapServerEntryWithDynamicImport({
107
- serverConfigFileName: sentryPluginOptions.instrumentation ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name) : "instrument.server",
108
- serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,
109
- resolvedServerConfigPath: serverInstrumentationPath,
110
- entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,
111
- debug: sentryPluginOptions.debug
112
- })
113
- );
93
+ /**
94
+ * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)
95
+ * and adds the Sentry server config with the static `import` declaration.
96
+ *
97
+ * With this, the Sentry server config can be loaded before all other modules of the application.
98
+ * See: https://nodejs.org/api/module.html#enabling
99
+ */
100
+ async function addDynamicImportEntryFileWrapper({ nitro, rollupConfig, sentryPluginOptions }) {
101
+ if (staticHostPresets.includes(nitro.options.preset)) return;
102
+ const srcDir = nitro.options.srcDir;
103
+ const serverInstrumentationPath = path.resolve(srcDir, "src", "instrument.server.ts");
104
+ const instrumentationFileName = sentryPluginOptions.instrumentation ? path.basename(sentryPluginOptions.instrumentation) : "";
105
+ rollupConfig.plugins.push(wrapServerEntryWithDynamicImport({
106
+ serverConfigFileName: sentryPluginOptions.instrumentation ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name) : "instrument.server",
107
+ serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,
108
+ resolvedServerConfigPath: serverInstrumentationPath,
109
+ entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,
110
+ debug: sentryPluginOptions.debug
111
+ }));
114
112
  }
115
-
116
113
  export { addDynamicImportEntryFileWrapper, addInstrumentationFileToBuild, addSentryTopImport, serverFilePresets, staticHostPresets };
117
- //# sourceMappingURL=addInstrumentation.js.map
114
+
115
+ //# sourceMappingURL=addInstrumentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"addInstrumentation.js","sources":["../../../src/config/addInstrumentation.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport * as path from 'path';\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 =>\n /^_sentry-release-injection-file-.*\\.(js|mjs)$/.test(file),\n );\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.\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 debug: sentryPluginOptions.debug,\n }),\n );\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,iBAAA,GAAoB,CAAC,cAAc;AAEzC,MAAM,iBAAA,GAAoB,CAAC,SAAS;AAW3C,eAAsB,8BAA8B,KAAA,EAA6B;AAC/E,EAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,YAAY;AAEpC,IAAA,IAAI,iBAAA,CAAkB,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACpD,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,QAAA;AAC/B,IAAA,MAAM,SAAA,GAAY,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAA;AAEvC,IAAA,IAAI;AAEF,MAAA,MAAM,eAAA,GAAkB,IAAA,CAAK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GAA4B,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,OAAO,sBAAsB,CAAA;AAEpF,EAAA,MAAM,0BAA0B,mBAAA,CAAoB,eAAA,GAChD,KAAK,QAAA,CAAS,mBAAA,CAAoB,eAAe,CAAA,GACjD,EAAA;AAEJ,EAAA,YAAA,CAAa,OAAA,CAAQ,IAAA;AAAA,IACnB,gCAAA,CAAiC;AAAA,MAC/B,oBAAA,EAAsB,mBAAA,CAAoB,eAAA,GACtC,IAAA,CAAK,KAAK,IAAA,CAAK,OAAA,CAAQ,uBAAuB,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,uBAAuB,CAAA,CAAE,IAAI,CAAA,GACzF,mBAAA;AAAA,MACJ,wBAAA,EAA0B,mBAAA,CAAoB,wBAAA,IAA4B,KAAA,CAAM,OAAA,CAAQ,MAAA;AAAA,MACxF,wBAAA,EAA0B,yBAAA;AAAA,MAC1B,4BAA4B,mBAAA,CAAoB,uCAAA;AAAA,MAChD,OAAO,mBAAA,CAAoB;AAAA,KAC5B;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"addInstrumentation.js","names":[],"sources":["../../../src/config/addInstrumentation.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport * as path from 'path';\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 =>\n /^_sentry-release-injection-file-.*\\.(js|mjs)$/.test(file),\n );\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.\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 debug: sentryPluginOptions.debug,\n }),\n );\n}\n"],"mappings":";;;;;AASA,MAAa,oBAAoB,CAAC,cAAc;AAEhD,MAAa,oBAAoB,CAAC,SAAS;;;;;;;;;;AAW3C,eAAsB,8BAA8B,OAA6B;CAC/E,MAAM,MAAM,KAAK,SAAS,YAAY;EAEpC,IAAI,kBAAkB,SAAS,MAAM,QAAQ,MAAM,GACjD;EAGF,MAAM,WAAW,MAAM,QAAQ;EAC/B,MAAM,YAAY,MAAM,QAAQ,OAAO;EAEvC,IAAI;GAEF,MAAM,kBAAkB,KAAK,KAAK,WAAW,QAAQ;GACrD,IAAI,CAAC,GAAG,WAAW,eAAe,GAAG;IACnC,MAAM,GAAG,SAAS,MAAM,iBAAiB,EAAE,WAAW,KAAK,CAAC;IAC5D,qBAAqB;KAEnB,QAAQ,IAAI,iEAAiE,gBAAgB,EAAE;IACjG,CAAC;GACH;GAGA,IAAI;IACF,MAAM,gBAAgB,KAAK,QAAQ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kDAAkD,oBAAoB,8BAA8B,gBAAgB,MACpH,KACF;GACF,CAAC;GACD;EACF;EAEA,IAAI;GAEF,MAAM,iBAAiB,sCAAsC,MADvC,GAAG,SAAS,SAAS,iBAAiB,OAAO;GAEnE,MAAM,GAAG,SAAS,UAAU,iBAAiB,cAAc;GAE3D,qBAAqB;IAEnB,QAAQ,IACN,0CAA0C,oBAAoB,8BAA8B,gBAAgB,IAC9G;GACF,CAAC;EACH,SAAS,OAAO;GAEd,QAAQ,KACN,yEAAyE,oBAAoB,8BAA8B,gBAAgB,MAC3I,KACF;EACF;CACF,CAAC;AACH;;;;;;;;AASA,eAAsB,iCAAiC,EACrD,OACA,cACA,uBAMgB;CAEhB,IAAI,kBAAkB,SAAS,MAAM,QAAQ,MAAM,GACjD;CAGF,MAAM,SAAS,MAAM,QAAQ;CAE7B,MAAM,4BAA4B,KAAK,QAAQ,QAAQ,OAAO,sBAAsB;CAEpF,MAAM,0BAA0B,oBAAoB,kBAChD,KAAK,SAAS,oBAAoB,eAAe,IACjD;CAEJ,aAAa,QAAQ,KACnB,iCAAiC;EAC/B,sBAAsB,oBAAoB,kBACtC,KAAK,KAAK,KAAK,QAAQ,uBAAuB,GAAG,KAAK,MAAM,uBAAuB,CAAC,CAAC,IAAI,IACzF;EACJ,0BAA0B,oBAAoB,4BAA4B,MAAM,QAAQ;EACxF,0BAA0B;EAC1B,4BAA4B,oBAAoB;EAChD,OAAO,oBAAoB;CAC7B,CAAC,CACH;AACF"}
@@ -0,0 +1 @@
1
+ export { withSentry } from "./withSentry.js";
@@ -1,90 +1,92 @@
1
- import { fileURLToPath } from 'node:url';
2
- import { _INTERNAL_normalizeTunnelBasePath, GLOBAL_OBJ, debug } from '@sentry/core';
3
- import { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';
4
- import { commonJSInteropOptions, sentryOrchestrionPlugin, sentryCommonJSInteropPlugin } from '@sentry/server-utils/orchestrion/rollup';
5
- import { TUNNEL_BASE_PATH_GLOBAL } from '../common/tunnel.js';
6
- import { addSentryPluginToVite } from '../vite/sentrySolidStartVite.js';
7
- import { addDynamicImportEntryFileWrapper, addInstrumentationFileToBuild, addSentryTopImport } from './addInstrumentation.js';
8
-
1
+ import { TUNNEL_BASE_PATH_GLOBAL } from "../common/tunnel.js";
2
+ import { addSentryPluginToVite } from "../vite/sentrySolidStartVite.js";
3
+ import { addDynamicImportEntryFileWrapper, addInstrumentationFileToBuild, addSentryTopImport } from "./addInstrumentation.js";
4
+ import { GLOBAL_OBJ, _INTERNAL_normalizeTunnelBasePath, debug } from "@sentry/core";
5
+ import { fileURLToPath } from "node:url";
6
+ import { INSTRUMENTED_MODULE_NAMES } from "@sentry/server-utils/orchestrion/config";
7
+ import { commonJSInteropOptions, sentryCommonJSInteropPlugin, sentryOrchestrionPlugin } from "@sentry/server-utils/orchestrion/rollup";
8
+ // src/config/withSentry.ts
9
9
  const IORedisDependencies = ["standard-as-callback"];
10
- const defaultSentrySolidStartPluginOptions = {
11
- experimental_entrypointWrappedFunctions: ["default", "handler", "server"]
12
- };
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
+ */
13
24
  function withSentry(solidStartConfig = {}, sentrySolidStartPluginOptions) {
14
- const sentryPluginOptions = {
15
- ...sentrySolidStartPluginOptions,
16
- ...defaultSentrySolidStartPluginOptions
17
- };
18
- const server = solidStartConfig.server || {};
19
- const tunnelBasePath = _INTERNAL_normalizeTunnelBasePath(
20
- server.baseURL
21
- );
22
- if (tunnelBasePath) {
23
- GLOBAL_OBJ[TUNNEL_BASE_PATH_GLOBAL] = tunnelBasePath;
24
- }
25
- const viteConfig = solidStartConfig.vite;
26
- const vite = typeof viteConfig === "function" ? (...args) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions, tunnelBasePath) : addSentryPluginToVite(viteConfig, sentryPluginOptions, tunnelBasePath);
27
- const addBuildTimeInstrumentation = sentryPluginOptions.buildTimeInstrumentation !== false;
28
- const sentryNitroModule = (nitro) => {
29
- nitro.hooks.hook("rollup:before", async (nitro2, rollupConfig) => {
30
- const sentryRollupConfig = rollupConfig;
31
- if (tunnelBasePath) {
32
- sentryRollupConfig.plugins.push({
33
- name: "sentry-solidstart-tunnel-base-path",
34
- banner: `globalThis.${TUNNEL_BASE_PATH_GLOBAL} = ${JSON.stringify(tunnelBasePath)};`
35
- });
36
- }
37
- if (addBuildTimeInstrumentation) {
38
- sentryRollupConfig.plugins.push(
39
- sentryOrchestrionPlugin({ buildTimeInstrumentation: sentryPluginOptions.buildTimeInstrumentation }),
40
- sentryCommonJSInteropPlugin()
41
- );
42
- }
43
- if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "experimental_dynamic-import") {
44
- await addDynamicImportEntryFileWrapper({
45
- nitro: nitro2,
46
- rollupConfig: sentryRollupConfig,
47
- sentryPluginOptions
48
- });
49
- sentrySolidStartPluginOptions.debug && debug.log(
50
- "Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes."
51
- );
52
- } else {
53
- await addInstrumentationFileToBuild(nitro2);
54
- if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "top-level-import") {
55
- await addSentryTopImport(nitro2);
56
- }
57
- }
58
- });
59
- };
60
- const existingModules = server.modules || [];
61
- let externals = server.externals;
62
- let commonJS = server.commonJS;
63
- if (addBuildTimeInstrumentation) {
64
- const existingInline = externals?.inline || [];
65
- externals = {
66
- ...externals,
67
- inline: [.../* @__PURE__ */ new Set([...existingInline, ...INSTRUMENTED_MODULE_NAMES, ...IORedisDependencies])]
68
- };
69
- commonJS = { ...commonJSInteropOptions(), ...commonJS };
70
- }
71
- return {
72
- ...solidStartConfig,
73
- vite,
74
- server: {
75
- ...server,
76
- externals,
77
- commonJS,
78
- modules: [...existingModules, sentryNitroModule],
79
- // Through `server.plugins`, since vinxi's dev server ignores plugins that Nitro modules add.
80
- plugins: [...server.plugins || [], getTunnelPluginPath()]
81
- }
82
- };
25
+ const sentryPluginOptions = {
26
+ ...sentrySolidStartPluginOptions,
27
+ ...defaultSentrySolidStartPluginOptions
28
+ };
29
+ const server = solidStartConfig.server || {};
30
+ const tunnelBasePath = _INTERNAL_normalizeTunnelBasePath(server.baseURL);
31
+ if (tunnelBasePath) GLOBAL_OBJ[TUNNEL_BASE_PATH_GLOBAL] = tunnelBasePath;
32
+ const viteConfig = solidStartConfig.vite;
33
+ const vite = typeof viteConfig === "function" ? (...args) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions, tunnelBasePath) : 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.${TUNNEL_BASE_PATH_GLOBAL} = ${JSON.stringify(tunnelBasePath)};`
41
+ });
42
+ if (addBuildTimeInstrumentation) sentryRollupConfig.plugins.push(sentryOrchestrionPlugin({ buildTimeInstrumentation: sentryPluginOptions.buildTimeInstrumentation }), sentryCommonJSInteropPlugin());
43
+ if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "experimental_dynamic-import") {
44
+ await addDynamicImportEntryFileWrapper({
45
+ nitro,
46
+ rollupConfig: sentryRollupConfig,
47
+ sentryPluginOptions
48
+ });
49
+ sentrySolidStartPluginOptions.debug && debug.log("Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.");
50
+ } else {
51
+ await addInstrumentationFileToBuild(nitro);
52
+ if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "top-level-import") await 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
+ ...INSTRUMENTED_MODULE_NAMES,
66
+ ...IORedisDependencies
67
+ ])]
68
+ };
69
+ commonJS = {
70
+ ...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
+ };
83
85
  }
84
86
  function getTunnelPluginPath() {
85
- const url = new URL("../nitro/tunnelPlugin.js", import.meta.url);
86
- return url.protocol === "file:" ? fileURLToPath(url) : url.pathname;
87
+ const url = new URL("../nitro/tunnelPlugin.js", import.meta.url);
88
+ return url.protocol === "file:" ? fileURLToPath(url) : url.pathname;
87
89
  }
88
-
89
90
  export { withSentry };
90
- //# sourceMappingURL=withSentry.js.map
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"],"names":["normalizeTunnelBasePath","nitro"],"mappings":";;;;;;;;AAqBA,MAAM,mBAAA,GAAsB,CAAC,sBAAsB,CAAA;AAEnD,MAAM,oCAAA,GAIuF;AAAA,EAC3F,uCAAA,EAAyC,CAAC,SAAA,EAAW,SAAA,EAAW,QAAQ;AAC1E,CAAA;AAWO,SAAS,UAAA,CACd,gBAAA,GAA2C,EAAC,EAC5C,6BAAA,EACwB;AACxB,EAAA,MAAM,mBAAA,GAAsB;AAAA,IAC1B,GAAG,6BAAA;AAAA,IACH,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,MAAA,GAAU,gBAAA,CAAiB,MAAA,IAAU,EAAC;AAE5C,EAAA,MAAM,cAAA,GAAiBA,iCAAA;AAAA,IACpB,MAAA,C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AA,KAAa,OAAA,GAAU,aAAA,CAAc,GAAG,IAAI,GAAA,CAAI,QAAA;AAC7D;;;;"}
1
+ {"version":3,"file":"withSentry.js","names":["normalizeTunnelBasePath"],"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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