jscrambler-metro-plugin 8.4.17 → 8.4.19
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/lib/sourceMaps.js +28 -5
- package/package.json +1 -1
package/lib/sourceMaps.js
CHANGED
@@ -55,8 +55,15 @@ module.exports = async function generateSourceMaps(payload) {
|
|
55
55
|
const metroSourceMap = await readFile(bundleSourceMapPath, 'utf8');
|
56
56
|
const finalBundleLocs = await extractLocs(finalBundle);
|
57
57
|
|
58
|
-
const metroSourceMapConsumer = new sourceMap.SourceMapConsumer(
|
59
|
-
|
58
|
+
const metroSourceMapConsumer = new sourceMap.SourceMapConsumer(
|
59
|
+
metroSourceMap,
|
60
|
+
);
|
61
|
+
// retrieve debug ids after the validation by the sourcemap package
|
62
|
+
// eslint-disable-next-line camelcase
|
63
|
+
const { debugId, debug_id } = JSON.parse(metroSourceMap);
|
64
|
+
const finalSourceMapGenerator = new sourceMap.SourceMapGenerator({
|
65
|
+
file: bundlePath,
|
66
|
+
});
|
60
67
|
const ofuscatedSourceMapConsumers = obfuscatedSourceMaps.map((map) =>
|
61
68
|
// when a source file is excluded, the sourcemap is not produced
|
62
69
|
map ? new sourceMap.SourceMapConsumer(map) : null,
|
@@ -145,8 +152,24 @@ module.exports = async function generateSourceMaps(payload) {
|
|
145
152
|
}
|
146
153
|
}
|
147
154
|
|
148
|
-
newMappings.forEach((newMapping) =>
|
155
|
+
newMappings.forEach((newMapping) =>
|
156
|
+
finalSourceMapGenerator.addMapping(newMapping),
|
157
|
+
);
|
149
158
|
})
|
150
159
|
|
151
|
-
|
152
|
-
|
160
|
+
const finalSourceMaps = finalSourceMapGenerator.toString();
|
161
|
+
|
162
|
+
// for when react native debugIds are necessary in the sourcemaps (upload to sentry for example)
|
163
|
+
// needs to be added in the end since the debugIds are not in SourceMapGenerator type
|
164
|
+
const finalSourceMapsJson = JSON.parse(finalSourceMaps);
|
165
|
+
if (debugId) {
|
166
|
+
finalSourceMapsJson.debugId = debugId;
|
167
|
+
}
|
168
|
+
// eslint-disable-next-line camelcase
|
169
|
+
if (debug_id) {
|
170
|
+
// eslint-disable-next-line camelcase
|
171
|
+
finalSourceMapsJson.debug_id = debug_id;
|
172
|
+
}
|
173
|
+
|
174
|
+
return JSON.stringify(finalSourceMapsJson);
|
175
|
+
};
|