@sentry/solidstart 10.53.0 → 10.54.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 (51) hide show
  1. package/build/cjs/client/sdk.js +3 -20
  2. package/build/cjs/client/sdk.js.map +1 -1
  3. package/build/cjs/config/addInstrumentation.js +28 -91
  4. package/build/cjs/config/addInstrumentation.js.map +1 -1
  5. package/build/cjs/config/withSentry.js +28 -52
  6. package/build/cjs/config/withSentry.js.map +1 -1
  7. package/build/cjs/config/wrapServerEntryWithDynamicImport.js +52 -170
  8. package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  9. package/build/cjs/server/middleware.js +11 -22
  10. package/build/cjs/server/middleware.js.map +1 -1
  11. package/build/cjs/server/sdk.js +2 -7
  12. package/build/cjs/server/sdk.js.map +1 -1
  13. package/build/cjs/server/solidrouter.js +1 -20
  14. package/build/cjs/server/solidrouter.js.map +1 -1
  15. package/build/cjs/server/utils.js +6 -24
  16. package/build/cjs/server/utils.js.map +1 -1
  17. package/build/cjs/server/withServerActionInstrumentation.js +14 -31
  18. package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
  19. package/build/cjs/vite/buildInstrumentationFile.js +12 -22
  20. package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
  21. package/build/cjs/vite/sentrySolidStartVite.js +3 -15
  22. package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
  23. package/build/cjs/vite/sourceMaps.js +37 -89
  24. package/build/cjs/vite/sourceMaps.js.map +1 -1
  25. package/build/esm/client/sdk.js +3 -20
  26. package/build/esm/client/sdk.js.map +1 -1
  27. package/build/esm/config/addInstrumentation.js +28 -91
  28. package/build/esm/config/addInstrumentation.js.map +1 -1
  29. package/build/esm/config/withSentry.js +28 -52
  30. package/build/esm/config/withSentry.js.map +1 -1
  31. package/build/esm/config/wrapServerEntryWithDynamicImport.js +52 -170
  32. package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  33. package/build/esm/package.json +1 -1
  34. package/build/esm/server/middleware.js +11 -22
  35. package/build/esm/server/middleware.js.map +1 -1
  36. package/build/esm/server/sdk.js +2 -7
  37. package/build/esm/server/sdk.js.map +1 -1
  38. package/build/esm/server/solidrouter.js +1 -20
  39. package/build/esm/server/solidrouter.js.map +1 -1
  40. package/build/esm/server/utils.js +6 -24
  41. package/build/esm/server/utils.js.map +1 -1
  42. package/build/esm/server/withServerActionInstrumentation.js +14 -31
  43. package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
  44. package/build/esm/vite/buildInstrumentationFile.js +12 -22
  45. package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
  46. package/build/esm/vite/sentrySolidStartVite.js +3 -15
  47. package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
  48. package/build/esm/vite/sourceMaps.js +37 -89
  49. package/build/esm/vite/sourceMaps.js.map +1 -1
  50. package/build/types/config/withSentry.d.ts.map +1 -1
  51. package/package.json +4 -4
@@ -3,177 +3,114 @@ import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import { wrapServerEntryWithDynamicImport } from './wrapServerEntryWithDynamicImport.js';
5
5
 
6
- // Nitro presets for hosts that only host static files
7
- const staticHostPresets = ['github_pages'];
8
- // Nitro presets for hosts that use `server.mjs` as opposed to `index.mjs`
9
- const serverFilePresets = ['netlify'];
10
-
11
- /**
12
- * Adds the built `instrument.server.js` file to the output directory.
13
- *
14
- * As Sentry also imports the release injection file, this needs to be copied over manually as well.
15
- * TODO: The mechanism of manually copying those files could maybe be improved
16
- *
17
- * This will no-op if no `instrument.server.js` file was found in the
18
- * build directory.
19
- */
6
+ const staticHostPresets = ["github_pages"];
7
+ const serverFilePresets = ["netlify"];
20
8
  async function addInstrumentationFileToBuild(nitro) {
21
- nitro.hooks.hook('close', async () => {
22
- // Static file hosts have no server component so there's nothing to do
9
+ nitro.hooks.hook("close", async () => {
23
10
  if (staticHostPresets.includes(nitro.options.preset)) {
24
11
  return;
25
12
  }
26
-
27
13
  const buildDir = nitro.options.buildDir;
28
14
  const serverDir = nitro.options.output.serverDir;
29
-
30
15
  try {
31
- // 1. Create assets directory first (for release-injection-file)
32
- const assetsServerDir = path.join(serverDir, 'assets');
16
+ const assetsServerDir = path.join(serverDir, "assets");
33
17
  if (!fs.existsSync(assetsServerDir)) {
34
18
  await fs.promises.mkdir(assetsServerDir, { recursive: true });
35
19
  consoleSandbox(() => {
36
- // eslint-disable-next-line no-console
37
20
  console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);
38
21
  });
39
22
  }
40
-
41
- // 2. Copy release injection file if available
42
23
  try {
43
- const ssrAssetsPath = path.resolve(buildDir, 'build', 'ssr', 'assets');
24
+ const ssrAssetsPath = path.resolve(buildDir, "build", "ssr", "assets");
44
25
  const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath);
45
- const releaseInjectionFile = assetsBuildDir.find(file =>
46
- /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file),
26
+ const releaseInjectionFile = assetsBuildDir.find(
27
+ (file) => /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file)
47
28
  );
48
-
49
29
  if (releaseInjectionFile) {
50
30
  const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);
51
31
  const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);
52
-
53
32
  await fs.promises.copyFile(releaseSource, releaseDestination);
54
33
  consoleSandbox(() => {
55
- // eslint-disable-next-line no-console
56
34
  console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);
57
35
  });
58
36
  }
59
37
  } catch (err) {
60
38
  consoleSandbox(() => {
61
- // eslint-disable-next-line no-console
62
- console.warn('[Sentry SolidStart withSentry] Failed to copy release injection file.', err);
39
+ console.warn("[Sentry SolidStart withSentry] Failed to copy release injection file.", err);
63
40
  });
64
41
  }
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
-
42
+ const instrumentSource = path.resolve(buildDir, "build", "ssr", "instrument.server.js");
43
+ const instrumentDestination = path.resolve(serverDir, "instrument.server.mjs");
70
44
  await fs.promises.copyFile(instrumentSource, instrumentDestination);
71
45
  consoleSandbox(() => {
72
- // eslint-disable-next-line no-console
73
46
  console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);
74
47
  });
75
48
  } catch (error) {
76
49
  consoleSandbox(() => {
77
- // eslint-disable-next-line no-console
78
- console.warn('[Sentry SolidStart withSentry] Failed to add instrumentation file to build.', error);
50
+ console.warn("[Sentry SolidStart withSentry] Failed to add instrumentation file to build.", error);
79
51
  });
80
52
  }
81
53
  });
82
54
  }
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
55
  async function addSentryTopImport(nitro) {
92
- nitro.hooks.hook('close', async () => {
56
+ nitro.hooks.hook("close", async () => {
93
57
  const buildPreset = nitro.options.preset;
94
58
  const serverDir = nitro.options.output.serverDir;
95
-
96
- // Static file hosts have no server component so there's nothing to do
97
59
  if (staticHostPresets.includes(buildPreset)) {
98
60
  return;
99
61
  }
100
-
101
- const instrumentationFile = path.resolve(serverDir, 'instrument.server.mjs');
102
- const serverEntryFileName = serverFilePresets.includes(buildPreset) ? 'server.mjs' : 'index.mjs';
62
+ const instrumentationFile = path.resolve(serverDir, "instrument.server.mjs");
63
+ const serverEntryFileName = serverFilePresets.includes(buildPreset) ? "server.mjs" : "index.mjs";
103
64
  const serverEntryFile = path.resolve(serverDir, serverEntryFileName);
104
-
105
65
  try {
106
66
  await fs.promises.access(instrumentationFile, fs.constants.F_OK);
107
67
  } catch (error) {
108
68
  consoleSandbox(() => {
109
- // eslint-disable-next-line no-console
110
69
  console.warn(
111
70
  `[Sentry SolidStart withSentry] Failed to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
112
- error,
71
+ error
113
72
  );
114
73
  });
115
74
  return;
116
75
  }
117
-
118
76
  try {
119
- const content = await fs.promises.readFile(serverEntryFile, 'utf-8');
120
- const updatedContent = `import './instrument.server.mjs';\n${content}`;
77
+ const content = await fs.promises.readFile(serverEntryFile, "utf-8");
78
+ const updatedContent = `import './instrument.server.mjs';
79
+ ${content}`;
121
80
  await fs.promises.writeFile(serverEntryFile, updatedContent);
122
-
123
81
  consoleSandbox(() => {
124
- // eslint-disable-next-line no-console
125
82
  console.log(
126
- `[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
83
+ `[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`
127
84
  );
128
85
  });
129
86
  } catch (error) {
130
- // eslint-disable-next-line no-console
131
87
  console.warn(
132
88
  `[Sentry SolidStart withSentry] An error occurred when trying to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
133
- error,
89
+ error
134
90
  );
135
91
  }
136
92
  });
137
93
  }
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
94
  async function addDynamicImportEntryFileWrapper({
147
95
  nitro,
148
96
  rollupConfig,
149
- sentryPluginOptions,
150
- }
151
-
152
- ) {
153
- // Static file hosts have no server component so there's nothing to do
97
+ sentryPluginOptions
98
+ }) {
154
99
  if (staticHostPresets.includes(nitro.options.preset)) {
155
100
  return;
156
101
  }
157
-
158
102
  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
-
103
+ const serverInstrumentationPath = path.resolve(srcDir, "src", "instrument.server.ts");
104
+ const instrumentationFileName = sentryPluginOptions.instrumentation ? path.basename(sentryPluginOptions.instrumentation) : "";
166
105
  rollupConfig.plugins.push(
167
106
  wrapServerEntryWithDynamicImport({
168
- serverConfigFileName: sentryPluginOptions.instrumentation
169
- ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name)
170
- : 'instrument.server',
107
+ serverConfigFileName: sentryPluginOptions.instrumentation ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name) : "instrument.server",
171
108
  serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,
172
109
  resolvedServerConfigPath: serverInstrumentationPath,
173
110
  entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,
174
- additionalImports: ['import-in-the-middle/hook.mjs'],
175
- debug: sentryPluginOptions.debug,
176
- }),
111
+ additionalImports: ["import-in-the-middle/hook.mjs"],
112
+ debug: sentryPluginOptions.debug
113
+ })
177
114
  );
178
115
  }
179
116
 
@@ -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 (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":[],"mappings":";;;;;AAQA;AACO,MAAM,iBAAA,GAAoB,CAAC,cAAc;AAChD;AACO,MAAM,iBAAA,GAAoB,CAAC,SAAS;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,6BAA6B,CAAC,KAAK,EAAwB;AACjF,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY;AACxC;AACA,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AAC1D,MAAM;AACN,IAAI;;AAEJ,IAAI,MAAM,QAAA,GAAW,KAAK,CAAC,OAAO,CAAC,QAAQ;AAC3C,IAAI,MAAM,YA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,GAAA,CAAA;AACA,QAAA,KAAA;AACA,OAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAA,gCAAA,CAAA;AACA,EAAA,KAAA;AACA,EAAA,YAAA;AACA,EAAA,mBAAA;AACA;;AAKA,EAAA;AACA;AACA,EAAA,IAAA,iBAAA,CAAA,QAAA,CAAA,KAAA,CAAA,OAAA,CAAA,MAAA,CAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,MAAA,GAAA,KAAA,CAAA,OAAA,CAAA,MAAA;AACA;AACA,EAAA,MAAA,yBAAA,GAAA,IAAA,CAAA,OAAA,CAAA,MAAA,EAAA,KAAA,EAAA,sBAAA,CAAA;;AAEA,EAAA,MAAA,uBAAA,GAAA,mBAAA,CAAA;AACA,MAAA,IAAA,CAAA,QAAA,CAAA,mBAAA,CAAA,eAAA;AACA,MAAA,EAAA;;AAEA,EAAA,YAAA,CAAA,OAAA,CAAA,IAAA;AACA,IAAA,gCAAA,CAAA;AACA,MAAA,oBAAA,EAAA,mBAAA,CAAA;AACA,UAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,EAAA,IAAA,CAAA,KAAA,CAAA,uBAAA,CAAA,CAAA,IAAA;AACA,UAAA,mBAAA;AACA,MAAA,wBAAA,EAAA,mBAAA,CAAA,wBAAA,IAAA,KAAA,CAAA,OAAA,CAAA,MAAA;AACA,MAAA,wBAAA,EAAA,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;;;;"}
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 (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":[],"mappings":";;;;;AASO,MAAM,iBAAA,GAAoB,CAAC,cAAc;AA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StartVite.js';
3
3
  import { addDynamicImportEntryFileWrapper, addInstrumentationFileToBuild, addSentryTopImport } from './addInstrumentation.js';
4
4
 
5
- const defaultSentrySolidStartPluginOptions
6
-
7
- = {
8
- experimental_entrypointWrappedFunctions: ['default', 'handler', 'server'],
5
+ const defaultSentrySolidStartPluginOptions = {
6
+ experimental_entrypointWrappedFunctions: ["default", "handler", "server"]
9
7
  };
10
-
11
- /**
12
- * Modifies the passed in Solid Start configuration with build-time enhancements such as
13
- * building the `instrument.server.ts` file into the appropriate build folder based on
14
- * build preset.
15
- *
16
- * @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`
17
- * @param sentrySolidStartPluginOptions Options to configure the plugin
18
- * @returns The modified config to be exported and passed back into `defineConfig`
19
- */
20
- function withSentry(
21
- solidStartConfig = {},
22
- sentrySolidStartPluginOptions,
23
- ) {
8
+ function withSentry(solidStartConfig = {}, sentrySolidStartPluginOptions) {
24
9
  const sentryPluginOptions = {
25
10
  ...sentrySolidStartPluginOptions,
26
- ...defaultSentrySolidStartPluginOptions,
11
+ ...defaultSentrySolidStartPluginOptions
27
12
  };
28
-
29
- const server = (solidStartConfig.server || {}) ;
30
- const hooks = server.hooks || {};
13
+ const server = solidStartConfig.server || {};
31
14
  const viteConfig = solidStartConfig.vite;
32
- const vite =
33
- typeof viteConfig === 'function'
34
- ? (...args) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions)
35
- : addSentryPluginToVite(viteConfig, sentryPluginOptions);
36
-
15
+ const vite = typeof viteConfig === "function" ? (...args) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions) : addSentryPluginToVite(viteConfig, sentryPluginOptions);
16
+ const sentryNitroModule = (nitro) => {
17
+ nitro.hooks.hook("rollup:before", async (nitro2, rollupConfig) => {
18
+ if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "experimental_dynamic-import") {
19
+ await addDynamicImportEntryFileWrapper({
20
+ nitro: nitro2,
21
+ rollupConfig,
22
+ sentryPluginOptions
23
+ });
24
+ sentrySolidStartPluginOptions.debug && debug.log(
25
+ "Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes."
26
+ );
27
+ } else {
28
+ await addInstrumentationFileToBuild(nitro2);
29
+ if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "top-level-import") {
30
+ await addSentryTopImport(nitro2);
31
+ }
32
+ }
33
+ });
34
+ };
35
+ const existingModules = server.modules || [];
37
36
  return {
38
37
  ...solidStartConfig,
39
38
  vite,
40
39
  server: {
41
40
  ...server,
42
- hooks: {
43
- ...hooks,
44
- async 'rollup:before'(nitro, config) {
45
- if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {
46
- await addDynamicImportEntryFileWrapper({ nitro, rollupConfig: config, sentryPluginOptions });
47
-
48
- sentrySolidStartPluginOptions.debug &&
49
- 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(nitro);
54
-
55
- if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'top-level-import') {
56
- await addSentryTopImport(nitro);
57
- }
58
- }
59
-
60
- // Run user provided hook
61
- if (hooks['rollup:before']) {
62
- hooks['rollup:before'](nitro);
63
- }
64
- },
65
- },
66
- },
41
+ modules: [...existingModules, sentryNitroModule]
42
+ }
67
43
  };
68
44
  }
69
45
 
@@ -1 +1 @@
1
- {"version":3,"file":"withSentry.js","sources":["../../../src/config/withSentry.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\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\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 viteConfig = solidStartConfig.vite;\n const vite =\n typeof viteConfig === 'function'\n ? (...args: Parameters<typeof viteConfig>) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions)\n : addSentryPluginToVite(viteConfig, 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 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 // Run user provided hook\n if (hooks['rollup:before']) {\n hooks['rollup:before'](nitro);\n }\n },\n },\n },\n };\n}\n"],"names":[],"mapp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AA6B,CAAC,KAAK,CAAC;;AAEtD,YAAY,IAAI,6BAA6B,EAAE,sBAAA,KAA2B,kBAAkB,EAAE;AAC9F,cAAc,MAAM,kBAAkB,CAAC,KAAK,CAAC;AAC7C,YAAY;AACZ,UAAU;;AAEV;AACA,UAAU,IAAI,KAAK,CAAC,eAAe,CAAC,EAAE;AACtC,YAAY,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC;AACzC,UAAU;AACV,QAAQ,CAAC;AACT,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"withSentry.js","sources":["../../../src/config/withSentry.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\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\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 viteConfig = solidStartConfig.vite;\n const vite =\n typeof viteConfig === 'function'\n ? (...args: Parameters<typeof viteConfig>) => addSentryPluginToVite(viteConfig(...args), sentryPluginOptions)\n : addSentryPluginToVite(viteConfig, sentryPluginOptions);\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 if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {\n await addDynamicImportEntryFileWrapper({\n nitro,\n rollupConfig: rollupConfig as unknown as RollupConfig,\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 return {\n ...solidStartConfig,\n vite,\n server: {\n ...server,\n modules: [...existingModules, sentryNitroModule],\n },\n };\n}\n"],"names":["nitro"],"mappings":";;;;AAWA,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;AAC5C,EAAA,MAAM,aAAa,gBAAA,CAAiB,IAAA;AACpC,EAAA,MAAM,IAAA,GACJ,OAAO,UAAA,KAAe,UAAA,GAClB,IAAI,IAAA,KAAwC,qBAAA,CAAsB,UAAA,CAAW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