metro 0.76.3 → 0.76.5
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/package.json +24 -23
- package/src/Assets.js +35 -3
- package/src/Assets.js.flow +38 -3
- package/src/Bundler/util.js +0 -72
- package/src/Bundler/util.js.flow +0 -98
- package/src/DeltaBundler/DeltaCalculator.js +7 -0
- package/src/DeltaBundler/DeltaCalculator.js.flow +7 -0
- package/src/DeltaBundler/Graph.js +108 -26
- package/src/DeltaBundler/Graph.js.flow +119 -26
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +3 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +1 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +3 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +4 -1
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -1
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +2 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +10 -12
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +3 -8
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -4
- package/src/DeltaBundler/Transformer.js +1 -0
- package/src/DeltaBundler/Transformer.js.flow +1 -0
- package/src/DeltaBundler/types.d.ts +1 -0
- package/src/DeltaBundler/types.flow.js.flow +10 -7
- package/src/Server.js +52 -14
- package/src/Server.js.flow +61 -16
- package/src/lib/getAppendScripts.js +1 -0
- package/src/lib/getAppendScripts.js.flow +12 -10
- package/src/lib/parseOptionsFromUrl.js +4 -3
- package/src/lib/parseOptionsFromUrl.js.flow +4 -3
package/src/Server.js
CHANGED
|
@@ -34,6 +34,8 @@ const { codeFrameColumns } = require("@babel/code-frame");
|
|
|
34
34
|
const MultipartResponse = require("./Server/MultipartResponse");
|
|
35
35
|
const debug = require("debug")("Metro:Server");
|
|
36
36
|
const fs = require("graceful-fs");
|
|
37
|
+
const invariant = require("invariant");
|
|
38
|
+
const jscSafeUrl = require("jsc-safe-url");
|
|
37
39
|
const {
|
|
38
40
|
Logger,
|
|
39
41
|
Logger: { createActionStartEntry, createActionEndEntry, log },
|
|
@@ -136,6 +138,8 @@ class Server {
|
|
|
136
138
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
137
139
|
serverRoot:
|
|
138
140
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
141
|
+
shouldAddToIgnoreList: (module) =>
|
|
142
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
139
143
|
};
|
|
140
144
|
let bundleCode = null;
|
|
141
145
|
let bundleMap = null;
|
|
@@ -163,6 +167,7 @@ class Server {
|
|
|
163
167
|
{
|
|
164
168
|
excludeSource: serializerOptions.excludeSource,
|
|
165
169
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
170
|
+
shouldAddToIgnoreList: bundleOptions.shouldAddToIgnoreList,
|
|
166
171
|
}
|
|
167
172
|
);
|
|
168
173
|
}
|
|
@@ -220,6 +225,8 @@ class Server {
|
|
|
220
225
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
221
226
|
serverRoot:
|
|
222
227
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
228
|
+
shouldAddToIgnoreList: (module) =>
|
|
229
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
223
230
|
});
|
|
224
231
|
}
|
|
225
232
|
async getAssets(options) {
|
|
@@ -350,9 +357,14 @@ class Server {
|
|
|
350
357
|
_parseOptions(url) {
|
|
351
358
|
return parseOptionsFromUrl(url, new Set(this._config.resolver.platforms));
|
|
352
359
|
}
|
|
360
|
+
_rewriteAndNormalizeUrl(requestUrl) {
|
|
361
|
+
return jscSafeUrl.toNormalUrl(
|
|
362
|
+
this._config.server.rewriteRequestUrl(jscSafeUrl.toNormalUrl(requestUrl))
|
|
363
|
+
);
|
|
364
|
+
}
|
|
353
365
|
async _processRequest(req, res, next) {
|
|
354
366
|
const originalUrl = req.url;
|
|
355
|
-
req.url = this.
|
|
367
|
+
req.url = this._rewriteAndNormalizeUrl(req.url);
|
|
356
368
|
const urlObj = url.parse(req.url, true);
|
|
357
369
|
const { host } = req.headers;
|
|
358
370
|
debug(
|
|
@@ -683,6 +695,8 @@ class Server {
|
|
|
683
695
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
684
696
|
serverRoot:
|
|
685
697
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
698
|
+
shouldAddToIgnoreList: (module) =>
|
|
699
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
686
700
|
}
|
|
687
701
|
);
|
|
688
702
|
bundlePerfLogger.point("serializingBundle_end");
|
|
@@ -697,7 +711,7 @@ class Server {
|
|
|
697
711
|
bundle: bundleCode,
|
|
698
712
|
};
|
|
699
713
|
},
|
|
700
|
-
finish({ req, mres, result }) {
|
|
714
|
+
finish({ req, mres, serializerOptions, result }) {
|
|
701
715
|
if (
|
|
702
716
|
// We avoid parsing the dates since the client should never send a more
|
|
703
717
|
// recent date than the one returned by the Delta Bundler (if that's the
|
|
@@ -714,6 +728,9 @@ class Server {
|
|
|
714
728
|
String(result.numModifiedFiles)
|
|
715
729
|
);
|
|
716
730
|
mres.setHeader(DELTA_ID_HEADER, String(result.nextRevId));
|
|
731
|
+
if (serializerOptions?.sourceUrl != null) {
|
|
732
|
+
mres.setHeader("Content-Location", serializerOptions.sourceUrl);
|
|
733
|
+
}
|
|
717
734
|
mres.setHeader("Content-Type", "application/javascript; charset=UTF-8");
|
|
718
735
|
mres.setHeader("Last-Modified", result.lastModifiedDate.toUTCString());
|
|
719
736
|
mres.setHeader(
|
|
@@ -792,6 +809,8 @@ class Server {
|
|
|
792
809
|
return sourceMapString([...prepend, ...this._getSortedModules(graph)], {
|
|
793
810
|
excludeSource: serializerOptions.excludeSource,
|
|
794
811
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
812
|
+
shouldAddToIgnoreList: (module) =>
|
|
813
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
795
814
|
});
|
|
796
815
|
},
|
|
797
816
|
finish({ mres, result }) {
|
|
@@ -890,18 +909,27 @@ class Server {
|
|
|
890
909
|
/* $FlowFixMe: where is `rawBody` defined? Is it added by the `connect` framework? */
|
|
891
910
|
const body = await req.rawBody;
|
|
892
911
|
const parsedBody = JSON.parse(body);
|
|
893
|
-
const
|
|
894
|
-
|
|
912
|
+
const rewriteAndNormalizeStackFrame = (frame, lineNumber) => {
|
|
913
|
+
invariant(
|
|
914
|
+
frame != null && typeof frame === "object",
|
|
915
|
+
"Bad stack frame at line %d, expected object, received: %s",
|
|
916
|
+
lineNumber,
|
|
917
|
+
typeof frame
|
|
918
|
+
);
|
|
919
|
+
const frameFile = frame.file;
|
|
920
|
+
if (typeof frameFile === "string" && frameFile.includes("://")) {
|
|
895
921
|
return {
|
|
896
922
|
...frame,
|
|
897
|
-
file: this.
|
|
923
|
+
file: this._rewriteAndNormalizeUrl(frameFile),
|
|
898
924
|
};
|
|
899
925
|
}
|
|
900
926
|
return frame;
|
|
901
|
-
}
|
|
927
|
+
};
|
|
928
|
+
const stack = parsedBody.stack.map(rewriteAndNormalizeStackFrame);
|
|
902
929
|
// In case of multiple bundles / HMR, some stack frames can have different URLs from others
|
|
903
930
|
const urls = new Set();
|
|
904
931
|
stack.forEach((frame) => {
|
|
932
|
+
// These urls have been rewritten and normalized above.
|
|
905
933
|
const sourceUrl = frame.file;
|
|
906
934
|
// Skip `/debuggerWorker.js` which does not need symbolication.
|
|
907
935
|
if (
|
|
@@ -915,8 +943,11 @@ class Server {
|
|
|
915
943
|
});
|
|
916
944
|
debug("Getting source maps for symbolication");
|
|
917
945
|
const sourceMaps = await Promise.all(
|
|
918
|
-
|
|
919
|
-
|
|
946
|
+
Array.from(urls.values()).map((normalizedUrl) =>
|
|
947
|
+
this._explodedSourceMapForBundleOptions(
|
|
948
|
+
this._parseOptions(normalizedUrl)
|
|
949
|
+
)
|
|
950
|
+
)
|
|
920
951
|
);
|
|
921
952
|
debug("Performing fast symbolication");
|
|
922
953
|
const symbolicatedStack = await symbolicate(
|
|
@@ -945,11 +976,7 @@ class Server {
|
|
|
945
976
|
);
|
|
946
977
|
}
|
|
947
978
|
}
|
|
948
|
-
async
|
|
949
|
-
const options = parseOptionsFromUrl(
|
|
950
|
-
reqUrl,
|
|
951
|
-
new Set(this._config.resolver.platforms)
|
|
952
|
-
);
|
|
979
|
+
async _explodedSourceMapForBundleOptions(bundleOptions) {
|
|
953
980
|
const {
|
|
954
981
|
entryFile,
|
|
955
982
|
graphOptions,
|
|
@@ -957,7 +984,7 @@ class Server {
|
|
|
957
984
|
resolverOptions,
|
|
958
985
|
serializerOptions,
|
|
959
986
|
transformOptions,
|
|
960
|
-
} = splitBundleOptions(
|
|
987
|
+
} = splitBundleOptions(bundleOptions);
|
|
961
988
|
|
|
962
989
|
/**
|
|
963
990
|
* `entryFile` is relative to projectRoot, we need to use resolution function
|
|
@@ -1057,6 +1084,17 @@ class Server {
|
|
|
1057
1084
|
async ready() {
|
|
1058
1085
|
await this._bundler.ready();
|
|
1059
1086
|
}
|
|
1087
|
+
_shouldAddModuleToIgnoreList(module) {
|
|
1088
|
+
// TODO: Add flag to Module signifying whether it represents generated code
|
|
1089
|
+
// and clean up these heuristics.
|
|
1090
|
+
return (
|
|
1091
|
+
// Prelude code, see getPrependedScripts.js
|
|
1092
|
+
module.path === "__prelude__" ||
|
|
1093
|
+
// Generated require.context() module, see contextModule.js
|
|
1094
|
+
module.path.includes("?ctx=") ||
|
|
1095
|
+
this._config.serializer.isThirdPartyModule(module)
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1060
1098
|
}
|
|
1061
1099
|
function* zip(xs, ys) {
|
|
1062
1100
|
//$FlowIssue #9324959
|
package/src/Server.js.flow
CHANGED
|
@@ -65,6 +65,8 @@ const {codeFrameColumns} = require('@babel/code-frame');
|
|
|
65
65
|
const MultipartResponse = require('./Server/MultipartResponse');
|
|
66
66
|
const debug = require('debug')('Metro:Server');
|
|
67
67
|
const fs = require('graceful-fs');
|
|
68
|
+
const invariant = require('invariant');
|
|
69
|
+
const jscSafeUrl = require('jsc-safe-url');
|
|
68
70
|
const {
|
|
69
71
|
Logger,
|
|
70
72
|
Logger: {createActionStartEntry, createActionEndEntry, log},
|
|
@@ -233,6 +235,8 @@ class Server {
|
|
|
233
235
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
234
236
|
serverRoot:
|
|
235
237
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
238
|
+
shouldAddToIgnoreList: (module: Module<>) =>
|
|
239
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
236
240
|
};
|
|
237
241
|
let bundleCode = null;
|
|
238
242
|
let bundleMap = null;
|
|
@@ -260,6 +264,7 @@ class Server {
|
|
|
260
264
|
{
|
|
261
265
|
excludeSource: serializerOptions.excludeSource,
|
|
262
266
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
267
|
+
shouldAddToIgnoreList: bundleOptions.shouldAddToIgnoreList,
|
|
263
268
|
},
|
|
264
269
|
);
|
|
265
270
|
}
|
|
@@ -321,6 +326,8 @@ class Server {
|
|
|
321
326
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
322
327
|
serverRoot:
|
|
323
328
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
329
|
+
shouldAddToIgnoreList: (module: Module<>) =>
|
|
330
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
324
331
|
});
|
|
325
332
|
}
|
|
326
333
|
|
|
@@ -484,14 +491,19 @@ class Server {
|
|
|
484
491
|
return parseOptionsFromUrl(url, new Set(this._config.resolver.platforms));
|
|
485
492
|
}
|
|
486
493
|
|
|
494
|
+
_rewriteAndNormalizeUrl(requestUrl: string): string {
|
|
495
|
+
return jscSafeUrl.toNormalUrl(
|
|
496
|
+
this._config.server.rewriteRequestUrl(jscSafeUrl.toNormalUrl(requestUrl)),
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
|
|
487
500
|
async _processRequest(
|
|
488
501
|
req: IncomingMessage,
|
|
489
502
|
res: ServerResponse,
|
|
490
503
|
next: (?Error) => mixed,
|
|
491
504
|
) {
|
|
492
505
|
const originalUrl = req.url;
|
|
493
|
-
req.url = this.
|
|
494
|
-
|
|
506
|
+
req.url = this._rewriteAndNormalizeUrl(req.url);
|
|
495
507
|
const urlObj = url.parse(req.url, true);
|
|
496
508
|
const {host} = req.headers;
|
|
497
509
|
debug(
|
|
@@ -875,6 +887,8 @@ class Server {
|
|
|
875
887
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
876
888
|
serverRoot:
|
|
877
889
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
890
|
+
shouldAddToIgnoreList: (module: Module<>) =>
|
|
891
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
878
892
|
},
|
|
879
893
|
);
|
|
880
894
|
bundlePerfLogger.point('serializingBundle_end');
|
|
@@ -892,7 +906,7 @@ class Server {
|
|
|
892
906
|
bundle: bundleCode,
|
|
893
907
|
};
|
|
894
908
|
},
|
|
895
|
-
finish({req, mres, result}) {
|
|
909
|
+
finish({req, mres, serializerOptions, result}) {
|
|
896
910
|
if (
|
|
897
911
|
// We avoid parsing the dates since the client should never send a more
|
|
898
912
|
// recent date than the one returned by the Delta Bundler (if that's the
|
|
@@ -909,6 +923,9 @@ class Server {
|
|
|
909
923
|
String(result.numModifiedFiles),
|
|
910
924
|
);
|
|
911
925
|
mres.setHeader(DELTA_ID_HEADER, String(result.nextRevId));
|
|
926
|
+
if (serializerOptions?.sourceUrl != null) {
|
|
927
|
+
mres.setHeader('Content-Location', serializerOptions.sourceUrl);
|
|
928
|
+
}
|
|
912
929
|
mres.setHeader('Content-Type', 'application/javascript; charset=UTF-8');
|
|
913
930
|
mres.setHeader('Last-Modified', result.lastModifiedDate.toUTCString());
|
|
914
931
|
mres.setHeader(
|
|
@@ -996,6 +1013,8 @@ class Server {
|
|
|
996
1013
|
return sourceMapString([...prepend, ...this._getSortedModules(graph)], {
|
|
997
1014
|
excludeSource: serializerOptions.excludeSource,
|
|
998
1015
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
1016
|
+
shouldAddToIgnoreList: (module: Module<>) =>
|
|
1017
|
+
this._shouldAddModuleToIgnoreList(module),
|
|
999
1018
|
});
|
|
1000
1019
|
},
|
|
1001
1020
|
finish({mres, result}) {
|
|
@@ -1103,19 +1122,33 @@ class Server {
|
|
|
1103
1122
|
/* $FlowFixMe: where is `rawBody` defined? Is it added by the `connect` framework? */
|
|
1104
1123
|
const body = await req.rawBody;
|
|
1105
1124
|
const parsedBody = JSON.parse(body);
|
|
1106
|
-
|
|
1107
|
-
|
|
1125
|
+
|
|
1126
|
+
const rewriteAndNormalizeStackFrame = <T>(
|
|
1127
|
+
frame: T,
|
|
1128
|
+
lineNumber: number,
|
|
1129
|
+
): T => {
|
|
1130
|
+
invariant(
|
|
1131
|
+
frame != null && typeof frame === 'object',
|
|
1132
|
+
'Bad stack frame at line %d, expected object, received: %s',
|
|
1133
|
+
lineNumber,
|
|
1134
|
+
typeof frame,
|
|
1135
|
+
);
|
|
1136
|
+
const frameFile = frame.file;
|
|
1137
|
+
if (typeof frameFile === 'string' && frameFile.includes('://')) {
|
|
1108
1138
|
return {
|
|
1109
1139
|
...frame,
|
|
1110
|
-
file: this.
|
|
1140
|
+
file: this._rewriteAndNormalizeUrl(frameFile),
|
|
1111
1141
|
};
|
|
1112
1142
|
}
|
|
1113
1143
|
return frame;
|
|
1114
|
-
}
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
const stack = parsedBody.stack.map(rewriteAndNormalizeStackFrame);
|
|
1115
1147
|
// In case of multiple bundles / HMR, some stack frames can have different URLs from others
|
|
1116
1148
|
const urls = new Set<string>();
|
|
1117
1149
|
|
|
1118
1150
|
stack.forEach(frame => {
|
|
1151
|
+
// These urls have been rewritten and normalized above.
|
|
1119
1152
|
const sourceUrl = frame.file;
|
|
1120
1153
|
// Skip `/debuggerWorker.js` which does not need symbolication.
|
|
1121
1154
|
if (
|
|
@@ -1130,8 +1163,11 @@ class Server {
|
|
|
1130
1163
|
|
|
1131
1164
|
debug('Getting source maps for symbolication');
|
|
1132
1165
|
const sourceMaps = await Promise.all(
|
|
1133
|
-
|
|
1134
|
-
|
|
1166
|
+
Array.from(urls.values()).map(normalizedUrl =>
|
|
1167
|
+
this._explodedSourceMapForBundleOptions(
|
|
1168
|
+
this._parseOptions(normalizedUrl),
|
|
1169
|
+
),
|
|
1170
|
+
),
|
|
1135
1171
|
);
|
|
1136
1172
|
|
|
1137
1173
|
debug('Performing fast symbolication');
|
|
@@ -1159,12 +1195,9 @@ class Server {
|
|
|
1159
1195
|
}
|
|
1160
1196
|
}
|
|
1161
1197
|
|
|
1162
|
-
async
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
new Set(this._config.resolver.platforms),
|
|
1166
|
-
);
|
|
1167
|
-
|
|
1198
|
+
async _explodedSourceMapForBundleOptions(
|
|
1199
|
+
bundleOptions: BundleOptions,
|
|
1200
|
+
): Promise<ExplodedSourceMap> {
|
|
1168
1201
|
const {
|
|
1169
1202
|
entryFile,
|
|
1170
1203
|
graphOptions,
|
|
@@ -1172,7 +1205,7 @@ class Server {
|
|
|
1172
1205
|
resolverOptions,
|
|
1173
1206
|
serializerOptions,
|
|
1174
1207
|
transformOptions,
|
|
1175
|
-
} = splitBundleOptions(
|
|
1208
|
+
} = splitBundleOptions(bundleOptions);
|
|
1176
1209
|
|
|
1177
1210
|
/**
|
|
1178
1211
|
* `entryFile` is relative to projectRoot, we need to use resolution function
|
|
@@ -1309,6 +1342,18 @@ class Server {
|
|
|
1309
1342
|
async ready(): Promise<void> {
|
|
1310
1343
|
await this._bundler.ready();
|
|
1311
1344
|
}
|
|
1345
|
+
|
|
1346
|
+
_shouldAddModuleToIgnoreList(module: Module<>): boolean {
|
|
1347
|
+
// TODO: Add flag to Module signifying whether it represents generated code
|
|
1348
|
+
// and clean up these heuristics.
|
|
1349
|
+
return (
|
|
1350
|
+
// Prelude code, see getPrependedScripts.js
|
|
1351
|
+
module.path === '__prelude__' ||
|
|
1352
|
+
// Generated require.context() module, see contextModule.js
|
|
1353
|
+
module.path.includes('?ctx=') ||
|
|
1354
|
+
this._config.serializer.isThirdPartyModule(module)
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1312
1357
|
}
|
|
1313
1358
|
|
|
1314
1359
|
function* zip<X, Y>(xs: Iterable<X>, ys: Iterable<Y>): Iterable<[X, Y]> {
|
|
@@ -20,17 +20,18 @@ const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
|
|
|
20
20
|
const countLines = require('./countLines');
|
|
21
21
|
const nullthrows = require('nullthrows');
|
|
22
22
|
|
|
23
|
-
type Options<T: number | string> = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
type Options<T: number | string> = $ReadOnly<{
|
|
24
|
+
asyncRequireModulePath: string,
|
|
25
|
+
createModuleId: string => T,
|
|
26
|
+
getRunModuleStatement: T => string,
|
|
27
|
+
inlineSourceMap: ?boolean,
|
|
28
|
+
runBeforeMainModule: $ReadOnlyArray<string>,
|
|
29
|
+
runModule: boolean,
|
|
30
|
+
shouldAddToIgnoreList: (Module<>) => boolean,
|
|
31
|
+
sourceMapUrl: ?string,
|
|
32
|
+
sourceUrl: ?string,
|
|
32
33
|
...
|
|
33
|
-
}
|
|
34
|
+
}>;
|
|
34
35
|
|
|
35
36
|
function getAppendScripts<T: number | string>(
|
|
36
37
|
entryPoint: string,
|
|
@@ -73,6 +74,7 @@ function getAppendScripts<T: number | string>(
|
|
|
73
74
|
sourceMapString(modules, {
|
|
74
75
|
processModuleFilter: (): boolean => true,
|
|
75
76
|
excludeSource: false,
|
|
77
|
+
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
|
|
76
78
|
}),
|
|
77
79
|
)
|
|
78
80
|
: nullthrows(options.sourceMapUrl);
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const parsePlatformFilePath = require("../node-haste/lib/parsePlatformFilePath");
|
|
15
15
|
const parseCustomResolverOptions = require("./parseCustomResolverOptions");
|
|
16
16
|
const parseCustomTransformOptions = require("./parseCustomTransformOptions");
|
|
17
|
+
const jscSafeUrl = require("jsc-safe-url");
|
|
17
18
|
const nullthrows = require("nullthrows");
|
|
18
19
|
const path = require("path");
|
|
19
20
|
const url = require("url");
|
|
@@ -27,8 +28,8 @@ const getTransformProfile = (transformProfile) =>
|
|
|
27
28
|
transformProfile === "hermes-stable" || transformProfile === "hermes-canary"
|
|
28
29
|
? transformProfile
|
|
29
30
|
: "default";
|
|
30
|
-
module.exports = function parseOptionsFromUrl(
|
|
31
|
-
const parsedURL = nullthrows(url.parse(
|
|
31
|
+
module.exports = function parseOptionsFromUrl(normalizedRequestUrl, platforms) {
|
|
32
|
+
const parsedURL = nullthrows(url.parse(normalizedRequestUrl, true)); // `true` to parse the query param as an object.
|
|
32
33
|
const query = nullthrows(parsedURL.query);
|
|
33
34
|
const pathname =
|
|
34
35
|
query.bundleEntry ||
|
|
@@ -62,7 +63,7 @@ module.exports = function parseOptionsFromUrl(requestUrl, platforms) {
|
|
|
62
63
|
platform != null && platform.match(/^(android|ios)$/) ? "http" : "",
|
|
63
64
|
pathname: pathname.replace(/\.(bundle|delta)$/, ".map"),
|
|
64
65
|
}),
|
|
65
|
-
sourceUrl:
|
|
66
|
+
sourceUrl: jscSafeUrl.toJscSafeUrl(normalizedRequestUrl),
|
|
66
67
|
unstable_transformProfile: getTransformProfile(
|
|
67
68
|
query.unstable_transformProfile
|
|
68
69
|
),
|
|
@@ -17,6 +17,7 @@ import type {TransformProfile} from 'metro-babel-transformer';
|
|
|
17
17
|
const parsePlatformFilePath = require('../node-haste/lib/parsePlatformFilePath');
|
|
18
18
|
const parseCustomResolverOptions = require('./parseCustomResolverOptions');
|
|
19
19
|
const parseCustomTransformOptions = require('./parseCustomTransformOptions');
|
|
20
|
+
const jscSafeUrl = require('jsc-safe-url');
|
|
20
21
|
const nullthrows = require('nullthrows');
|
|
21
22
|
const path = require('path');
|
|
22
23
|
const url = require('url');
|
|
@@ -39,10 +40,10 @@ const getTransformProfile = (transformProfile: string): TransformProfile =>
|
|
|
39
40
|
: 'default';
|
|
40
41
|
|
|
41
42
|
module.exports = function parseOptionsFromUrl(
|
|
42
|
-
|
|
43
|
+
normalizedRequestUrl: string,
|
|
43
44
|
platforms: Set<string>,
|
|
44
45
|
): BundleOptions {
|
|
45
|
-
const parsedURL = nullthrows(url.parse(
|
|
46
|
+
const parsedURL = nullthrows(url.parse(normalizedRequestUrl, true)); // `true` to parse the query param as an object.
|
|
46
47
|
const query = nullthrows(parsedURL.query);
|
|
47
48
|
const pathname =
|
|
48
49
|
query.bundleEntry ||
|
|
@@ -77,7 +78,7 @@ module.exports = function parseOptionsFromUrl(
|
|
|
77
78
|
platform != null && platform.match(/^(android|ios)$/) ? 'http' : '',
|
|
78
79
|
pathname: pathname.replace(/\.(bundle|delta)$/, '.map'),
|
|
79
80
|
}),
|
|
80
|
-
sourceUrl:
|
|
81
|
+
sourceUrl: jscSafeUrl.toJscSafeUrl(normalizedRequestUrl),
|
|
81
82
|
unstable_transformProfile: getTransformProfile(
|
|
82
83
|
query.unstable_transformProfile,
|
|
83
84
|
),
|