@sentry/solidstart 10.53.1 → 10.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/client/sdk.js +3 -20
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/config/addInstrumentation.js +28 -91
- package/build/cjs/config/addInstrumentation.js.map +1 -1
- package/build/cjs/config/withSentry.js +28 -52
- package/build/cjs/config/withSentry.js.map +1 -1
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js +52 -170
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/cjs/server/middleware.js +11 -22
- package/build/cjs/server/middleware.js.map +1 -1
- package/build/cjs/server/sdk.js +2 -7
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/solidrouter.js +1 -20
- package/build/cjs/server/solidrouter.js.map +1 -1
- package/build/cjs/server/utils.js +6 -24
- package/build/cjs/server/utils.js.map +1 -1
- package/build/cjs/server/withServerActionInstrumentation.js +14 -31
- package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
- package/build/cjs/vite/buildInstrumentationFile.js +12 -22
- package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
- package/build/cjs/vite/sentrySolidStartVite.js +3 -15
- package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +37 -89
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/esm/client/sdk.js +3 -20
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/config/addInstrumentation.js +28 -91
- package/build/esm/config/addInstrumentation.js.map +1 -1
- package/build/esm/config/withSentry.js +28 -52
- package/build/esm/config/withSentry.js.map +1 -1
- package/build/esm/config/wrapServerEntryWithDynamicImport.js +52 -170
- package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/middleware.js +11 -22
- package/build/esm/server/middleware.js.map +1 -1
- package/build/esm/server/sdk.js +2 -7
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/solidrouter.js +1 -20
- package/build/esm/server/solidrouter.js.map +1 -1
- package/build/esm/server/utils.js +6 -24
- package/build/esm/server/utils.js.map +1 -1
- package/build/esm/server/withServerActionInstrumentation.js +14 -31
- package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
- package/build/esm/vite/buildInstrumentationFile.js +12 -22
- package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
- package/build/esm/vite/sentrySolidStartVite.js +3 -15
- package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +37 -89
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/types/config/withSentry.d.ts.map +1 -1
- package/package.json +4 -4
package/build/cjs/client/sdk.js
CHANGED
|
@@ -3,36 +3,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
4
|
const solid = require('@sentry/solid');
|
|
5
5
|
|
|
6
|
-
// Treeshakable guard to remove all code related to tracing
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Initializes the client side of the Solid Start SDK.
|
|
10
|
-
*/
|
|
11
6
|
function init(options) {
|
|
12
7
|
const opts = {
|
|
13
8
|
defaultIntegrations: getDefaultIntegrations(options),
|
|
14
|
-
...options
|
|
9
|
+
...options
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
core.applySdkMetadata(opts, 'solidstart', ['solidstart', 'solid']);
|
|
18
|
-
|
|
11
|
+
core.applySdkMetadata(opts, "solidstart", ["solidstart", "solid"]);
|
|
19
12
|
return solid.init(opts);
|
|
20
13
|
}
|
|
21
|
-
|
|
22
14
|
function getDefaultIntegrations(options) {
|
|
23
15
|
const integrations = solid.getDefaultIntegrations(options);
|
|
24
|
-
|
|
25
|
-
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
|
|
26
|
-
// in which case everything inside will get tree-shaken away
|
|
27
|
-
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
|
|
28
|
-
// We add the default BrowserTracingIntegration here always.
|
|
29
|
-
// We can do this, even if `solidRouterBrowserTracingIntegration` is
|
|
30
|
-
// supplied as integration in `init` by users because it will win
|
|
31
|
-
// over the default integration by virtue of having the same
|
|
32
|
-
// `BrowserTracing` integration name and being added later.
|
|
16
|
+
if (typeof __SENTRY_TRACING__ === "undefined" || __SENTRY_TRACING__) {
|
|
33
17
|
integrations.push(solid.browserTracingIntegration());
|
|
34
18
|
}
|
|
35
|
-
|
|
36
19
|
return integrations;
|
|
37
20
|
}
|
|
38
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { Client, Integration } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { BrowserOptions } from '@sentry/solid';\nimport {\n browserTracingIntegration,\n getDefaultIntegrations as getDefaultSolidIntegrations,\n init as initSolidSDK,\n} from '@sentry/solid';\n\n// Treeshakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean;\n\n/**\n * Initializes the client side of the Solid Start SDK.\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n defaultIntegrations: getDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(opts, 'solidstart', ['solidstart', 'solid']);\n\n return initSolidSDK(opts);\n}\n\nfunction getDefaultIntegrations(options: BrowserOptions): Integration[] {\n const integrations = getDefaultSolidIntegrations(options);\n\n // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with \"false\",\n // in which case everything inside will get tree-shaken away\n if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {\n // We add the default BrowserTracingIntegration here always.\n // We can do this, even if `solidRouterBrowserTracingIntegration` is\n // supplied as integration in `init` by users because it will win\n // over the default integration by virtue of having the same\n // `BrowserTracing` integration name and being added later.\n integrations.push(browserTracingIntegration());\n }\n\n return integrations;\n}\n"],"names":["applySdkMetadata","initSolidSDK","getDefaultSolidIntegrations","browserTracingIntegration"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { Client, Integration } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { BrowserOptions } from '@sentry/solid';\nimport {\n browserTracingIntegration,\n getDefaultIntegrations as getDefaultSolidIntegrations,\n init as initSolidSDK,\n} from '@sentry/solid';\n\n// Treeshakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean;\n\n/**\n * Initializes the client side of the Solid Start SDK.\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n defaultIntegrations: getDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(opts, 'solidstart', ['solidstart', 'solid']);\n\n return initSolidSDK(opts);\n}\n\nfunction getDefaultIntegrations(options: BrowserOptions): Integration[] {\n const integrations = getDefaultSolidIntegrations(options);\n\n // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with \"false\",\n // in which case everything inside will get tree-shaken away\n if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {\n // We add the default BrowserTracingIntegration here always.\n // We can do this, even if `solidRouterBrowserTracingIntegration` is\n // supplied as integration in `init` by users because it will win\n // over the default integration by virtue of having the same\n // `BrowserTracing` integration name and being added later.\n integrations.push(browserTracingIntegration());\n }\n\n return integrations;\n}\n"],"names":["applySdkMetadata","initSolidSDK","getDefaultSolidIntegrations","browserTracingIntegration"],"mappings":";;;;;AAeO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,mBAAA,EAAqB,uBAAuB,OAAO,CAAA;AAAA,IACnD,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,IAAA,EAAM,YAAA,EAAc,CAAC,YAAA,EAAc,OAAO,CAAC,CAAA;AAE5D,EAAA,OAAOC,WAAa,IAAI,CAAA;AAC1B;AAEA,SAAS,uBAAuB,OAAA,EAAwC;AACtE,EAAA,MAAM,YAAA,GAAeC,6BAA4B,OAAO,CAAA;AAIxD,EAAA,IAAI,OAAO,kBAAA,KAAuB,WAAA,IAAe,kBAAA,EAAoB;AAMnE,IAAA,YAAA,CAAa,IAAA,CAAKC,iCAA2B,CAAA;AAAA,EAC/C;AAEA,EAAA,OAAO,YAAA;AACT;;;;"}
|
|
@@ -5,177 +5,114 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const wrapServerEntryWithDynamicImport = require('./wrapServerEntryWithDynamicImport.js');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
// Nitro presets for hosts that use `server.mjs` as opposed to `index.mjs`
|
|
11
|
-
const serverFilePresets = ['netlify'];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Adds the built `instrument.server.js` file to the output directory.
|
|
15
|
-
*
|
|
16
|
-
* As Sentry also imports the release injection file, this needs to be copied over manually as well.
|
|
17
|
-
* TODO: The mechanism of manually copying those files could maybe be improved
|
|
18
|
-
*
|
|
19
|
-
* This will no-op if no `instrument.server.js` file was found in the
|
|
20
|
-
* build directory.
|
|
21
|
-
*/
|
|
8
|
+
const staticHostPresets = ["github_pages"];
|
|
9
|
+
const serverFilePresets = ["netlify"];
|
|
22
10
|
async function addInstrumentationFileToBuild(nitro) {
|
|
23
|
-
nitro.hooks.hook(
|
|
24
|
-
// Static file hosts have no server component so there's nothing to do
|
|
11
|
+
nitro.hooks.hook("close", async () => {
|
|
25
12
|
if (staticHostPresets.includes(nitro.options.preset)) {
|
|
26
13
|
return;
|
|
27
14
|
}
|
|
28
|
-
|
|
29
15
|
const buildDir = nitro.options.buildDir;
|
|
30
16
|
const serverDir = nitro.options.output.serverDir;
|
|
31
|
-
|
|
32
17
|
try {
|
|
33
|
-
|
|
34
|
-
const assetsServerDir = path.join(serverDir, 'assets');
|
|
18
|
+
const assetsServerDir = path.join(serverDir, "assets");
|
|
35
19
|
if (!fs.existsSync(assetsServerDir)) {
|
|
36
20
|
await fs.promises.mkdir(assetsServerDir, { recursive: true });
|
|
37
21
|
core.consoleSandbox(() => {
|
|
38
|
-
// eslint-disable-next-line no-console
|
|
39
22
|
console.log(`[Sentry SolidStart withSentry] Successfully created directory ${assetsServerDir}.`);
|
|
40
23
|
});
|
|
41
24
|
}
|
|
42
|
-
|
|
43
|
-
// 2. Copy release injection file if available
|
|
44
25
|
try {
|
|
45
|
-
const ssrAssetsPath = path.resolve(buildDir,
|
|
26
|
+
const ssrAssetsPath = path.resolve(buildDir, "build", "ssr", "assets");
|
|
46
27
|
const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath);
|
|
47
|
-
const releaseInjectionFile = assetsBuildDir.find(
|
|
48
|
-
/^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file)
|
|
28
|
+
const releaseInjectionFile = assetsBuildDir.find(
|
|
29
|
+
(file) => /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file)
|
|
49
30
|
);
|
|
50
|
-
|
|
51
31
|
if (releaseInjectionFile) {
|
|
52
32
|
const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile);
|
|
53
33
|
const releaseDestination = path.resolve(assetsServerDir, releaseInjectionFile);
|
|
54
|
-
|
|
55
34
|
await fs.promises.copyFile(releaseSource, releaseDestination);
|
|
56
35
|
core.consoleSandbox(() => {
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
36
|
console.log(`[Sentry SolidStart withSentry] Successfully created ${releaseDestination}.`);
|
|
59
37
|
});
|
|
60
38
|
}
|
|
61
39
|
} catch (err) {
|
|
62
40
|
core.consoleSandbox(() => {
|
|
63
|
-
|
|
64
|
-
console.warn('[Sentry SolidStart withSentry] Failed to copy release injection file.', err);
|
|
41
|
+
console.warn("[Sentry SolidStart withSentry] Failed to copy release injection file.", err);
|
|
65
42
|
});
|
|
66
43
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const instrumentSource = path.resolve(buildDir, 'build', 'ssr', 'instrument.server.js');
|
|
70
|
-
const instrumentDestination = path.resolve(serverDir, 'instrument.server.mjs');
|
|
71
|
-
|
|
44
|
+
const instrumentSource = path.resolve(buildDir, "build", "ssr", "instrument.server.js");
|
|
45
|
+
const instrumentDestination = path.resolve(serverDir, "instrument.server.mjs");
|
|
72
46
|
await fs.promises.copyFile(instrumentSource, instrumentDestination);
|
|
73
47
|
core.consoleSandbox(() => {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
48
|
console.log(`[Sentry SolidStart withSentry] Successfully created ${instrumentDestination}.`);
|
|
76
49
|
});
|
|
77
50
|
} catch (error) {
|
|
78
51
|
core.consoleSandbox(() => {
|
|
79
|
-
|
|
80
|
-
console.warn('[Sentry SolidStart withSentry] Failed to add instrumentation file to build.', error);
|
|
52
|
+
console.warn("[Sentry SolidStart withSentry] Failed to add instrumentation file to build.", error);
|
|
81
53
|
});
|
|
82
54
|
}
|
|
83
55
|
});
|
|
84
56
|
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Adds an `instrument.server.mjs` import to the top of the server entry file.
|
|
88
|
-
*
|
|
89
|
-
* This is meant as an escape hatch and should only be used in environments where
|
|
90
|
-
* it's not possible to `--import` the file instead as it comes with a limited
|
|
91
|
-
* tracing experience, only collecting http traces.
|
|
92
|
-
*/
|
|
93
57
|
async function addSentryTopImport(nitro) {
|
|
94
|
-
nitro.hooks.hook(
|
|
58
|
+
nitro.hooks.hook("close", async () => {
|
|
95
59
|
const buildPreset = nitro.options.preset;
|
|
96
60
|
const serverDir = nitro.options.output.serverDir;
|
|
97
|
-
|
|
98
|
-
// Static file hosts have no server component so there's nothing to do
|
|
99
61
|
if (staticHostPresets.includes(buildPreset)) {
|
|
100
62
|
return;
|
|
101
63
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
const serverEntryFileName = serverFilePresets.includes(buildPreset) ? 'server.mjs' : 'index.mjs';
|
|
64
|
+
const instrumentationFile = path.resolve(serverDir, "instrument.server.mjs");
|
|
65
|
+
const serverEntryFileName = serverFilePresets.includes(buildPreset) ? "server.mjs" : "index.mjs";
|
|
105
66
|
const serverEntryFile = path.resolve(serverDir, serverEntryFileName);
|
|
106
|
-
|
|
107
67
|
try {
|
|
108
68
|
await fs.promises.access(instrumentationFile, fs.constants.F_OK);
|
|
109
69
|
} catch (error) {
|
|
110
70
|
core.consoleSandbox(() => {
|
|
111
|
-
// eslint-disable-next-line no-console
|
|
112
71
|
console.warn(
|
|
113
72
|
`[Sentry SolidStart withSentry] Failed to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
|
|
114
|
-
error
|
|
73
|
+
error
|
|
115
74
|
);
|
|
116
75
|
});
|
|
117
76
|
return;
|
|
118
77
|
}
|
|
119
|
-
|
|
120
78
|
try {
|
|
121
|
-
const content = await fs.promises.readFile(serverEntryFile,
|
|
122
|
-
const updatedContent = `import './instrument.server.mjs'
|
|
79
|
+
const content = await fs.promises.readFile(serverEntryFile, "utf-8");
|
|
80
|
+
const updatedContent = `import './instrument.server.mjs';
|
|
81
|
+
${content}`;
|
|
123
82
|
await fs.promises.writeFile(serverEntryFile, updatedContent);
|
|
124
|
-
|
|
125
83
|
core.consoleSandbox(() => {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
84
|
console.log(
|
|
128
|
-
`[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}
|
|
85
|
+
`[Sentry SolidStart withSentry] Added \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`
|
|
129
86
|
);
|
|
130
87
|
});
|
|
131
88
|
} catch (error) {
|
|
132
|
-
// eslint-disable-next-line no-console
|
|
133
89
|
console.warn(
|
|
134
90
|
`[Sentry SolidStart withSentry] An error occurred when trying to add \`${instrumentationFile}\` as top level import to \`${serverEntryFile}\`.`,
|
|
135
|
-
error
|
|
91
|
+
error
|
|
136
92
|
);
|
|
137
93
|
}
|
|
138
94
|
});
|
|
139
95
|
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)
|
|
143
|
-
* and adds the Sentry server config with the static `import` declaration.
|
|
144
|
-
*
|
|
145
|
-
* With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).
|
|
146
|
-
* See: https://nodejs.org/api/module.html#enabling
|
|
147
|
-
*/
|
|
148
96
|
async function addDynamicImportEntryFileWrapper({
|
|
149
97
|
nitro,
|
|
150
98
|
rollupConfig,
|
|
151
|
-
sentryPluginOptions
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
) {
|
|
155
|
-
// Static file hosts have no server component so there's nothing to do
|
|
99
|
+
sentryPluginOptions
|
|
100
|
+
}) {
|
|
156
101
|
if (staticHostPresets.includes(nitro.options.preset)) {
|
|
157
102
|
return;
|
|
158
103
|
}
|
|
159
|
-
|
|
160
104
|
const srcDir = nitro.options.srcDir;
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const instrumentationFileName = sentryPluginOptions.instrumentation
|
|
165
|
-
? path.basename(sentryPluginOptions.instrumentation)
|
|
166
|
-
: '';
|
|
167
|
-
|
|
105
|
+
const serverInstrumentationPath = path.resolve(srcDir, "src", "instrument.server.ts");
|
|
106
|
+
const instrumentationFileName = sentryPluginOptions.instrumentation ? path.basename(sentryPluginOptions.instrumentation) : "";
|
|
168
107
|
rollupConfig.plugins.push(
|
|
169
108
|
wrapServerEntryWithDynamicImport.wrapServerEntryWithDynamicImport({
|
|
170
|
-
serverConfigFileName: sentryPluginOptions.instrumentation
|
|
171
|
-
? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name)
|
|
172
|
-
: 'instrument.server',
|
|
109
|
+
serverConfigFileName: sentryPluginOptions.instrumentation ? path.join(path.dirname(instrumentationFileName), path.parse(instrumentationFileName).name) : "instrument.server",
|
|
173
110
|
serverEntrypointFileName: sentryPluginOptions.serverEntrypointFileName || nitro.options.preset,
|
|
174
111
|
resolvedServerConfigPath: serverInstrumentationPath,
|
|
175
112
|
entrypointWrappedFunctions: sentryPluginOptions.experimental_entrypointWrappedFunctions,
|
|
176
|
-
additionalImports: [
|
|
177
|
-
debug: sentryPluginOptions.debug
|
|
178
|
-
})
|
|
113
|
+
additionalImports: ["import-in-the-middle/hook.mjs"],
|
|
114
|
+
debug: sentryPluginOptions.debug
|
|
115
|
+
})
|
|
179
116
|
);
|
|
180
117
|
}
|
|
181
118
|
|
|
@@ -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":["consoleSandbox","wrapServerEntryWithDynamicImport"],"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,YAAY,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS;;AAEpD,IAAI,IAAI;AACR;AACA,MAAM,MAAM,eAAA,GAAkB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;AAC5D,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;AAC3C,QAAQ,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAA,EAAM,CAAC;AACrE,QAAQA,m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EA,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,IAAAC,iEAAA,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":["consoleSandbox","wrapServerEntryWithDynamicImport"],"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,G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A,IAAI,iBAAA,CAAkB,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACpD,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,MAAA;AAE7B,EAAA,MAAM,yBAAA,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,IACnBC,iEAAA,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,iBAAA,EAAmB,CAAC,+BAA+B,CAAA;AAAA,MACnD,OAAO,mBAAA,CAAoB;AAAA,KAC5B;AAAA,GACH;AACF;;;;;;;;"}
|
|
@@ -4,68 +4,44 @@ const core = require('@sentry/core');
|
|
|
4
4
|
const sentrySolidStartVite = require('../vite/sentrySolidStartVite.js');
|
|
5
5
|
const addInstrumentation = require('./addInstrumentation.js');
|
|
6
6
|
|
|
7
|
-
const defaultSentrySolidStartPluginOptions
|
|
8
|
-
|
|
9
|
-
= {
|
|
10
|
-
experimental_entrypointWrappedFunctions: ['default', 'handler', 'server'],
|
|
7
|
+
const defaultSentrySolidStartPluginOptions = {
|
|
8
|
+
experimental_entrypointWrappedFunctions: ["default", "handler", "server"]
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Modifies the passed in Solid Start configuration with build-time enhancements such as
|
|
15
|
-
* building the `instrument.server.ts` file into the appropriate build folder based on
|
|
16
|
-
* build preset.
|
|
17
|
-
*
|
|
18
|
-
* @param solidStartConfig A Solid Start configuration object, as usually passed to `defineConfig` in `app.config.ts|js`
|
|
19
|
-
* @param sentrySolidStartPluginOptions Options to configure the plugin
|
|
20
|
-
* @returns The modified config to be exported and passed back into `defineConfig`
|
|
21
|
-
*/
|
|
22
|
-
function withSentry(
|
|
23
|
-
solidStartConfig = {},
|
|
24
|
-
sentrySolidStartPluginOptions,
|
|
25
|
-
) {
|
|
10
|
+
function withSentry(solidStartConfig = {}, sentrySolidStartPluginOptions) {
|
|
26
11
|
const sentryPluginOptions = {
|
|
27
12
|
...sentrySolidStartPluginOptions,
|
|
28
|
-
...defaultSentrySolidStartPluginOptions
|
|
13
|
+
...defaultSentrySolidStartPluginOptions
|
|
29
14
|
};
|
|
30
|
-
|
|
31
|
-
const server = (solidStartConfig.server || {}) ;
|
|
32
|
-
const hooks = server.hooks || {};
|
|
15
|
+
const server = solidStartConfig.server || {};
|
|
33
16
|
const viteConfig = solidStartConfig.vite;
|
|
34
|
-
const vite =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
const vite = typeof viteConfig === "function" ? (...args) => sentrySolidStartVite.addSentryPluginToVite(viteConfig(...args), sentryPluginOptions) : sentrySolidStartVite.addSentryPluginToVite(viteConfig, sentryPluginOptions);
|
|
18
|
+
const sentryNitroModule = (nitro) => {
|
|
19
|
+
nitro.hooks.hook("rollup:before", async (nitro2, rollupConfig) => {
|
|
20
|
+
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "experimental_dynamic-import") {
|
|
21
|
+
await addInstrumentation.addDynamicImportEntryFileWrapper({
|
|
22
|
+
nitro: nitro2,
|
|
23
|
+
rollupConfig,
|
|
24
|
+
sentryPluginOptions
|
|
25
|
+
});
|
|
26
|
+
sentrySolidStartPluginOptions.debug && core.debug.log(
|
|
27
|
+
"Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes."
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
await addInstrumentation.addInstrumentationFileToBuild(nitro2);
|
|
31
|
+
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === "top-level-import") {
|
|
32
|
+
await addInstrumentation.addSentryTopImport(nitro2);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const existingModules = server.modules || [];
|
|
39
38
|
return {
|
|
40
39
|
...solidStartConfig,
|
|
41
40
|
vite,
|
|
42
41
|
server: {
|
|
43
42
|
...server,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
async 'rollup:before'(nitro, config) {
|
|
47
|
-
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'experimental_dynamic-import') {
|
|
48
|
-
await addInstrumentation.addDynamicImportEntryFileWrapper({ nitro, rollupConfig: config, sentryPluginOptions });
|
|
49
|
-
|
|
50
|
-
sentrySolidStartPluginOptions.debug &&
|
|
51
|
-
core.debug.log(
|
|
52
|
-
'Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',
|
|
53
|
-
);
|
|
54
|
-
} else {
|
|
55
|
-
await addInstrumentation.addInstrumentationFileToBuild(nitro);
|
|
56
|
-
|
|
57
|
-
if (sentrySolidStartPluginOptions?.autoInjectServerSentry === 'top-level-import') {
|
|
58
|
-
await addInstrumentation.addSentryTopImport(nitro);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Run user provided hook
|
|
63
|
-
if (hooks['rollup:before']) {
|
|
64
|
-
hooks['rollup:before'](nitro);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
43
|
+
modules: [...existingModules, sentryNitroModule]
|
|
44
|
+
}
|
|
69
45
|
};
|
|
70
46
|
}
|
|
71
47
|
|
|
@@ -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
|
|
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":["addSentryPluginToVite","nitro","addDynamicImportEntryFileWrapper","debug","addInstrumentationFileToBuild","addSentryTopImport"],"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,KAAwCA,0CAAA,CAAsB,UAAA,CAAW,GAAG,IAAI,CAAA,EAAG,mBAAmB,CAAA,GAC1GA,0CAAA,CAAsB,YAAY,mBAAmB,CAAA;AAG3D,EAAA,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAiB;AAC1C,IAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,eAAA,EAAiB,OAAOC,QAAO,YAAA,KAAiB;AAC/D,MAAA,IAAI,6BAAA,EAA+B,2BAA2B,6BAAA,EAA+B;AAC3F,QAAA,MAAMC,mDAAA,CAAiC;AAAA,UACrC,KAAA,EAAAD,MAAAA;AAAA,UACA,YAAA;AAAA,UACA;AAAA,SACD,CAAA;AAED,QAAA,6BAAA,CAA8B,SAC5BE,UAAA,CAAM,GAAA;AAAA,UACJ;AAAA,SACF;AAAA,MACJ,CAAA,MAAO;AACL,QAAA,MA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