@sentry/bundler-plugin-core 4.6.1 → 4.6.2
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/dist/cjs/index.js +128 -88
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +128 -88
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -8336,7 +8336,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
|
|
|
8336
8336
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
8337
8337
|
tracesSampleRate: 1,
|
|
8338
8338
|
sampleRate: 1,
|
|
8339
|
-
release: "4.6.
|
|
8339
|
+
release: "4.6.2",
|
|
8340
8340
|
integrations: [],
|
|
8341
8341
|
tracePropagationTargets: ["sentry.io/api"],
|
|
8342
8342
|
stackParser: stackParser,
|
|
@@ -8945,7 +8945,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
8945
8945
|
});
|
|
8946
8946
|
|
|
8947
8947
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
8948
|
-
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.6.
|
|
8948
|
+
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.6.2");
|
|
8949
8949
|
|
|
8950
8950
|
// Propagate debug flag to Sentry CLI via environment variable
|
|
8951
8951
|
// Only set if not already defined to respect user's explicit configuration
|
|
@@ -9942,42 +9942,76 @@ var COMMENT_USE_STRICT_REGEX =
|
|
|
9942
9942
|
* about type mismatches
|
|
9943
9943
|
*/
|
|
9944
9944
|
|
|
9945
|
+
/**
|
|
9946
|
+
* Checks if a file is a JavaScript file based on its extension.
|
|
9947
|
+
* Handles query strings and hashes in the filename.
|
|
9948
|
+
*/
|
|
9949
|
+
function isJsFile(fileName) {
|
|
9950
|
+
var cleanFileName = stripQueryAndHashFromPath(fileName);
|
|
9951
|
+
return [".js", ".mjs", ".cjs"].some(function (ext) {
|
|
9952
|
+
return cleanFileName.endsWith(ext);
|
|
9953
|
+
});
|
|
9954
|
+
}
|
|
9955
|
+
|
|
9956
|
+
/**
|
|
9957
|
+
* Checks if a chunk should be skipped for code injection
|
|
9958
|
+
*
|
|
9959
|
+
* This is necessary to handle Vite's MPA (multi-page application) mode where
|
|
9960
|
+
* HTML entry points create "facade" chunks that should not contain injected code.
|
|
9961
|
+
* See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
|
|
9962
|
+
*
|
|
9963
|
+
* @param code - The chunk's code content
|
|
9964
|
+
* @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks
|
|
9965
|
+
* @returns true if the chunk should be skipped
|
|
9966
|
+
*/
|
|
9967
|
+
function shouldSkipCodeInjection(code, facadeModuleId) {
|
|
9968
|
+
// Skip empty chunks - these are placeholder chunks that should be optimized away
|
|
9969
|
+
if (code.trim().length === 0) {
|
|
9970
|
+
return true;
|
|
9971
|
+
}
|
|
9972
|
+
|
|
9973
|
+
// Skip HTML facade chunks
|
|
9974
|
+
// They only contain import statements and should not have Sentry code injected
|
|
9975
|
+
if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith(".html")) {
|
|
9976
|
+
return true;
|
|
9977
|
+
}
|
|
9978
|
+
return false;
|
|
9979
|
+
}
|
|
9945
9980
|
function createRollupReleaseInjectionHooks(injectionCode) {
|
|
9946
9981
|
return {
|
|
9947
9982
|
renderChunk: function renderChunk(code, chunk) {
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
[".js", ".mjs", ".cjs"].some(function (ending) {
|
|
9951
|
-
return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
|
|
9952
|
-
})) {
|
|
9953
|
-
var _code$match;
|
|
9954
|
-
var ms = new MagicString__default["default"](code, {
|
|
9955
|
-
filename: chunk.fileName
|
|
9956
|
-
});
|
|
9957
|
-
var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
|
|
9958
|
-
if (match) {
|
|
9959
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
9960
|
-
ms.appendLeft(match.length, injectionCode);
|
|
9961
|
-
} else {
|
|
9962
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
9963
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
9964
|
-
// need this special case here.
|
|
9965
|
-
ms.prepend(injectionCode);
|
|
9966
|
-
}
|
|
9967
|
-
return {
|
|
9968
|
-
code: ms.toString(),
|
|
9969
|
-
map: ms.generateMap({
|
|
9970
|
-
file: chunk.fileName,
|
|
9971
|
-
hires: "boundary"
|
|
9972
|
-
})
|
|
9973
|
-
};
|
|
9974
|
-
} else {
|
|
9983
|
+
var _code$match;
|
|
9984
|
+
if (!isJsFile(chunk.fileName)) {
|
|
9975
9985
|
return null; // returning null means not modifying the chunk at all
|
|
9976
9986
|
}
|
|
9987
|
+
|
|
9988
|
+
// Skip empty chunks and HTML facade chunks (Vite MPA)
|
|
9989
|
+
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
|
|
9990
|
+
return null;
|
|
9991
|
+
}
|
|
9992
|
+
var ms = new MagicString__default["default"](code, {
|
|
9993
|
+
filename: chunk.fileName
|
|
9994
|
+
});
|
|
9995
|
+
var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
|
|
9996
|
+
if (match) {
|
|
9997
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
9998
|
+
ms.appendLeft(match.length, injectionCode);
|
|
9999
|
+
} else {
|
|
10000
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10001
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10002
|
+
// need this special case here.
|
|
10003
|
+
ms.prepend(injectionCode);
|
|
10004
|
+
}
|
|
10005
|
+
return {
|
|
10006
|
+
code: ms.toString(),
|
|
10007
|
+
map: ms.generateMap({
|
|
10008
|
+
file: chunk.fileName,
|
|
10009
|
+
hires: "boundary"
|
|
10010
|
+
})
|
|
10011
|
+
};
|
|
9977
10012
|
}
|
|
9978
10013
|
};
|
|
9979
10014
|
}
|
|
9980
|
-
|
|
9981
10015
|
function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
9982
10016
|
return {
|
|
9983
10017
|
transform: function transform(code) {
|
|
@@ -9988,77 +10022,83 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
|
9988
10022
|
function createRollupDebugIdInjectionHooks() {
|
|
9989
10023
|
return {
|
|
9990
10024
|
renderChunk: function renderChunk(code, chunk) {
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
[".js", ".mjs", ".cjs"].some(function (ending) {
|
|
9994
|
-
return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
|
|
9995
|
-
})) {
|
|
9996
|
-
var _code$match2;
|
|
9997
|
-
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
9998
|
-
var codeToInject = getDebugIdSnippet(debugId);
|
|
9999
|
-
var ms = new MagicString__default["default"](code, {
|
|
10000
|
-
filename: chunk.fileName
|
|
10001
|
-
});
|
|
10002
|
-
var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
|
|
10003
|
-
if (match) {
|
|
10004
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10005
|
-
ms.appendLeft(match.length, codeToInject);
|
|
10006
|
-
} else {
|
|
10007
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10008
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10009
|
-
// need this special case here.
|
|
10010
|
-
ms.prepend(codeToInject);
|
|
10011
|
-
}
|
|
10012
|
-
return {
|
|
10013
|
-
code: ms.toString(),
|
|
10014
|
-
map: ms.generateMap({
|
|
10015
|
-
file: chunk.fileName,
|
|
10016
|
-
hires: "boundary"
|
|
10017
|
-
})
|
|
10018
|
-
};
|
|
10019
|
-
} else {
|
|
10025
|
+
var _code$match2;
|
|
10026
|
+
if (!isJsFile(chunk.fileName)) {
|
|
10020
10027
|
return null; // returning null means not modifying the chunk at all
|
|
10021
10028
|
}
|
|
10029
|
+
|
|
10030
|
+
// Skip empty chunks and HTML facade chunks (Vite MPA)
|
|
10031
|
+
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
|
|
10032
|
+
return null;
|
|
10033
|
+
}
|
|
10034
|
+
|
|
10035
|
+
// Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
|
|
10036
|
+
var chunkStartSnippet = code.slice(0, 6000);
|
|
10037
|
+
var chunkEndSnippet = code.slice(-500);
|
|
10038
|
+
if (chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId=")) {
|
|
10039
|
+
return null; // Debug ID already present, skip injection
|
|
10040
|
+
}
|
|
10041
|
+
|
|
10042
|
+
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
10043
|
+
var codeToInject = getDebugIdSnippet(debugId);
|
|
10044
|
+
var ms = new MagicString__default["default"](code, {
|
|
10045
|
+
filename: chunk.fileName
|
|
10046
|
+
});
|
|
10047
|
+
var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
|
|
10048
|
+
if (match) {
|
|
10049
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10050
|
+
ms.appendLeft(match.length, codeToInject);
|
|
10051
|
+
} else {
|
|
10052
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10053
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10054
|
+
// need this special case here.
|
|
10055
|
+
ms.prepend(codeToInject);
|
|
10056
|
+
}
|
|
10057
|
+
return {
|
|
10058
|
+
code: ms.toString(),
|
|
10059
|
+
map: ms.generateMap({
|
|
10060
|
+
file: chunk.fileName,
|
|
10061
|
+
hires: "boundary"
|
|
10062
|
+
})
|
|
10063
|
+
};
|
|
10022
10064
|
}
|
|
10023
10065
|
};
|
|
10024
10066
|
}
|
|
10025
|
-
|
|
10026
10067
|
function createRollupModuleMetadataInjectionHooks(injectionCode) {
|
|
10027
10068
|
return {
|
|
10028
10069
|
renderChunk: function renderChunk(code, chunk) {
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
[".js", ".mjs", ".cjs"].some(function (ending) {
|
|
10032
|
-
return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
|
|
10033
|
-
})) {
|
|
10034
|
-
var _code$match3;
|
|
10035
|
-
var ms = new MagicString__default["default"](code, {
|
|
10036
|
-
filename: chunk.fileName
|
|
10037
|
-
});
|
|
10038
|
-
var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
|
|
10039
|
-
if (match) {
|
|
10040
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10041
|
-
ms.appendLeft(match.length, injectionCode);
|
|
10042
|
-
} else {
|
|
10043
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10044
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10045
|
-
// need this special case here.
|
|
10046
|
-
ms.prepend(injectionCode);
|
|
10047
|
-
}
|
|
10048
|
-
return {
|
|
10049
|
-
code: ms.toString(),
|
|
10050
|
-
map: ms.generateMap({
|
|
10051
|
-
file: chunk.fileName,
|
|
10052
|
-
hires: "boundary"
|
|
10053
|
-
})
|
|
10054
|
-
};
|
|
10055
|
-
} else {
|
|
10070
|
+
var _code$match3;
|
|
10071
|
+
if (!isJsFile(chunk.fileName)) {
|
|
10056
10072
|
return null; // returning null means not modifying the chunk at all
|
|
10057
10073
|
}
|
|
10074
|
+
|
|
10075
|
+
// Skip empty chunks and HTML facade chunks (Vite MPA)
|
|
10076
|
+
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
|
|
10077
|
+
return null;
|
|
10078
|
+
}
|
|
10079
|
+
var ms = new MagicString__default["default"](code, {
|
|
10080
|
+
filename: chunk.fileName
|
|
10081
|
+
});
|
|
10082
|
+
var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
|
|
10083
|
+
if (match) {
|
|
10084
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10085
|
+
ms.appendLeft(match.length, injectionCode);
|
|
10086
|
+
} else {
|
|
10087
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10088
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10089
|
+
// need this special case here.
|
|
10090
|
+
ms.prepend(injectionCode);
|
|
10091
|
+
}
|
|
10092
|
+
return {
|
|
10093
|
+
code: ms.toString(),
|
|
10094
|
+
map: ms.generateMap({
|
|
10095
|
+
file: chunk.fileName,
|
|
10096
|
+
hires: "boundary"
|
|
10097
|
+
})
|
|
10098
|
+
};
|
|
10058
10099
|
}
|
|
10059
10100
|
};
|
|
10060
10101
|
}
|
|
10061
|
-
|
|
10062
10102
|
function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuildArtifacts) {
|
|
10063
10103
|
var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
|
|
10064
10104
|
return {
|