@jsenv/core 40.5.2 → 40.6.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/dist/build/build.js +52 -14
- package/dist/build/jsenv_core_packages.js +110 -110
- package/dist/start_dev_server/jsenv_core_packages.js +110 -110
- package/dist/start_dev_server/start_dev_server.js +52 -14
- package/package.json +25 -22
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +9 -4
- package/src/plugins/resolution_node_esm/node_esm_resolver.js +43 -10
package/dist/build/build.js
CHANGED
|
@@ -5594,13 +5594,32 @@ const createNodeEsmResolver = ({
|
|
|
5594
5594
|
return null; // let it to jsenv_web_resolution
|
|
5595
5595
|
}
|
|
5596
5596
|
const { specifier } = reference;
|
|
5597
|
-
|
|
5598
|
-
|
|
5597
|
+
// specifiers like "#something" have a special meaning for Node.js
|
|
5598
|
+
// but can also be used in .css and .html files for example and should not be modified
|
|
5599
|
+
// by node esm resolution
|
|
5600
|
+
const webResolutionFallback =
|
|
5601
|
+
ownerUrlInfo.type !== "js_module" ||
|
|
5602
|
+
reference.type === "sourcemap_comment";
|
|
5603
|
+
const conditions = buildPackageConditions(specifier, parentUrl, {
|
|
5604
|
+
webResolutionFallback,
|
|
5605
|
+
});
|
|
5606
|
+
let resolution;
|
|
5607
|
+
const nodeEsmResolutionParams = {
|
|
5599
5608
|
conditions,
|
|
5600
5609
|
parentUrl,
|
|
5601
5610
|
specifier,
|
|
5602
5611
|
preservesSymlink,
|
|
5603
|
-
}
|
|
5612
|
+
};
|
|
5613
|
+
if (webResolutionFallback) {
|
|
5614
|
+
try {
|
|
5615
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
5616
|
+
} catch {
|
|
5617
|
+
return null; // delegate to web_resolution plugin
|
|
5618
|
+
}
|
|
5619
|
+
} else {
|
|
5620
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
5621
|
+
}
|
|
5622
|
+
const { url, type, isMain, packageDirectoryUrl } = resolution;
|
|
5604
5623
|
// try to give a more meaningful filename after build
|
|
5605
5624
|
if (isMain && packageDirectoryUrl) {
|
|
5606
5625
|
const basename = urlToBasename(url);
|
|
@@ -5669,12 +5688,26 @@ const createBuildPackageConditions = (
|
|
|
5669
5688
|
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
5670
5689
|
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
5671
5690
|
const processArgConditions = readCustomConditionsFromProcessArgs();
|
|
5672
|
-
const devResolver = (specifier, importer) => {
|
|
5691
|
+
const devResolver = (specifier, importer, { webResolutionFallback }) => {
|
|
5673
5692
|
if (isBareSpecifier$1(specifier)) {
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5693
|
+
let url;
|
|
5694
|
+
if (webResolutionFallback) {
|
|
5695
|
+
try {
|
|
5696
|
+
const resolution = applyNodeEsmResolution({
|
|
5697
|
+
specifier,
|
|
5698
|
+
parentUrl: importer,
|
|
5699
|
+
});
|
|
5700
|
+
url = resolution.url;
|
|
5701
|
+
} catch {
|
|
5702
|
+
url = new URL(specifier, importer).href;
|
|
5703
|
+
}
|
|
5704
|
+
} else {
|
|
5705
|
+
const resolution = applyNodeEsmResolution({
|
|
5706
|
+
specifier,
|
|
5707
|
+
parentUrl: importer,
|
|
5708
|
+
});
|
|
5709
|
+
url = resolution.url;
|
|
5710
|
+
}
|
|
5678
5711
|
return !url.includes("/node_modules/");
|
|
5679
5712
|
}
|
|
5680
5713
|
return !importer.includes("/node_modules/");
|
|
@@ -5778,12 +5811,12 @@ const createBuildPackageConditions = (
|
|
|
5778
5811
|
}
|
|
5779
5812
|
|
|
5780
5813
|
const conditionCandidateArray = Object.keys(conditionResolvers);
|
|
5781
|
-
return (specifier, importer) => {
|
|
5814
|
+
return (specifier, importer, params) => {
|
|
5782
5815
|
const conditions = [];
|
|
5783
5816
|
for (const conditionCandidate of conditionCandidateArray) {
|
|
5784
5817
|
const conditionResolver = conditionResolvers[conditionCandidate];
|
|
5785
5818
|
if (typeof conditionResolver === "function") {
|
|
5786
|
-
if (conditionResolver(specifier, importer)) {
|
|
5819
|
+
if (conditionResolver(specifier, importer, params)) {
|
|
5787
5820
|
conditions.push(conditionCandidate);
|
|
5788
5821
|
}
|
|
5789
5822
|
} else if (conditionResolver) {
|
|
@@ -5907,8 +5940,7 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5907
5940
|
if (config === true) {
|
|
5908
5941
|
resolver = nodeEsmResolverDefault;
|
|
5909
5942
|
} else if (config === false) {
|
|
5910
|
-
|
|
5911
|
-
continue;
|
|
5943
|
+
resolver = null;
|
|
5912
5944
|
} else if (typeof config === "object") {
|
|
5913
5945
|
resolver = resolverFromObject(config, { kitchenContext, urlType });
|
|
5914
5946
|
} else {
|
|
@@ -5923,6 +5955,9 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5923
5955
|
resolverMap.set(urlType, resolver);
|
|
5924
5956
|
}
|
|
5925
5957
|
}
|
|
5958
|
+
if (!anyTypeResolver) {
|
|
5959
|
+
anyTypeResolver = nodeEsmResolverDefault;
|
|
5960
|
+
}
|
|
5926
5961
|
|
|
5927
5962
|
if (!resolverMap.has("js_module")) {
|
|
5928
5963
|
resolverMap.set("js_module", nodeEsmResolverDefault);
|
|
@@ -5948,8 +5983,11 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5948
5983
|
}
|
|
5949
5984
|
const urlType = urlTypeFromReference(reference);
|
|
5950
5985
|
const resolver = resolverMap.get(urlType);
|
|
5951
|
-
if (resolver) {
|
|
5952
|
-
|
|
5986
|
+
if (resolver !== undefined) {
|
|
5987
|
+
if (typeof resolver === "function") {
|
|
5988
|
+
return resolver(reference);
|
|
5989
|
+
}
|
|
5990
|
+
return resolver;
|
|
5953
5991
|
}
|
|
5954
5992
|
if (anyTypeResolver) {
|
|
5955
5993
|
return anyTypeResolver(reference);
|
|
@@ -7080,6 +7080,23 @@ const isResponseEligibleForIntegrityValidation = (response) => {
|
|
|
7080
7080
|
return ["basic", "cors", "default"].includes(response.type);
|
|
7081
7081
|
};
|
|
7082
7082
|
|
|
7083
|
+
const assertImportMap = (value) => {
|
|
7084
|
+
if (value === null) {
|
|
7085
|
+
throw new TypeError(`an importMap must be an object, got null`);
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7088
|
+
const type = typeof value;
|
|
7089
|
+
if (type !== "object") {
|
|
7090
|
+
throw new TypeError(`an importMap must be an object, received ${value}`);
|
|
7091
|
+
}
|
|
7092
|
+
|
|
7093
|
+
if (Array.isArray(value)) {
|
|
7094
|
+
throw new TypeError(
|
|
7095
|
+
`an importMap must be an object, received array ${value}`,
|
|
7096
|
+
);
|
|
7097
|
+
}
|
|
7098
|
+
};
|
|
7099
|
+
|
|
7083
7100
|
// duplicated from @jsenv/log to avoid the dependency
|
|
7084
7101
|
const createDetailedMessage = (message, details = {}) => {
|
|
7085
7102
|
let string = `${message}`;
|
|
@@ -7096,89 +7113,72 @@ const createDetailedMessage = (message, details = {}) => {
|
|
|
7096
7113
|
}`;
|
|
7097
7114
|
});
|
|
7098
7115
|
|
|
7099
|
-
return string
|
|
7116
|
+
return string;
|
|
7100
7117
|
};
|
|
7101
7118
|
|
|
7102
|
-
const
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
}
|
|
7106
|
-
|
|
7107
|
-
const type = typeof value;
|
|
7108
|
-
if (type !== "object") {
|
|
7109
|
-
throw new TypeError(`an importMap must be an object, received ${value}`)
|
|
7110
|
-
}
|
|
7119
|
+
const hasScheme = (string) => {
|
|
7120
|
+
return /^[a-zA-Z]{2,}:/.test(string);
|
|
7121
|
+
};
|
|
7111
7122
|
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7123
|
+
const pathnameToParentPathname = (pathname) => {
|
|
7124
|
+
const slashLastIndex = pathname.lastIndexOf("/");
|
|
7125
|
+
if (slashLastIndex === -1) {
|
|
7126
|
+
return "/";
|
|
7116
7127
|
}
|
|
7117
|
-
};
|
|
7118
7128
|
|
|
7119
|
-
|
|
7120
|
-
return /^[a-zA-Z]{2,}:/.test(string)
|
|
7129
|
+
return pathname.slice(0, slashLastIndex + 1);
|
|
7121
7130
|
};
|
|
7122
7131
|
|
|
7123
7132
|
const urlToScheme = (urlString) => {
|
|
7124
7133
|
const colonIndex = urlString.indexOf(":");
|
|
7125
|
-
if (colonIndex === -1) return ""
|
|
7126
|
-
return urlString.slice(0, colonIndex)
|
|
7134
|
+
if (colonIndex === -1) return "";
|
|
7135
|
+
return urlString.slice(0, colonIndex);
|
|
7136
|
+
};
|
|
7137
|
+
|
|
7138
|
+
const urlToOrigin = (urlString) => {
|
|
7139
|
+
const scheme = urlToScheme(urlString);
|
|
7140
|
+
|
|
7141
|
+
if (scheme === "file") {
|
|
7142
|
+
return "file://";
|
|
7143
|
+
}
|
|
7144
|
+
|
|
7145
|
+
if (scheme === "http" || scheme === "https") {
|
|
7146
|
+
const secondProtocolSlashIndex = scheme.length + "://".length;
|
|
7147
|
+
const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
|
|
7148
|
+
|
|
7149
|
+
if (pathnameSlashIndex === -1) return urlString;
|
|
7150
|
+
return urlString.slice(0, pathnameSlashIndex);
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
return urlString.slice(0, scheme.length + 1);
|
|
7127
7154
|
};
|
|
7128
7155
|
|
|
7129
7156
|
const urlToPathname = (urlString) => {
|
|
7130
|
-
return ressourceToPathname(urlToRessource(urlString))
|
|
7157
|
+
return ressourceToPathname(urlToRessource(urlString));
|
|
7131
7158
|
};
|
|
7132
7159
|
|
|
7133
7160
|
const urlToRessource = (urlString) => {
|
|
7134
7161
|
const scheme = urlToScheme(urlString);
|
|
7135
7162
|
|
|
7136
7163
|
if (scheme === "file") {
|
|
7137
|
-
return urlString.slice("file://".length)
|
|
7164
|
+
return urlString.slice("file://".length);
|
|
7138
7165
|
}
|
|
7139
7166
|
|
|
7140
7167
|
if (scheme === "https" || scheme === "http") {
|
|
7141
7168
|
// remove origin
|
|
7142
7169
|
const afterProtocol = urlString.slice(scheme.length + "://".length);
|
|
7143
7170
|
const pathnameSlashIndex = afterProtocol.indexOf("/", "://".length);
|
|
7144
|
-
return afterProtocol.slice(pathnameSlashIndex)
|
|
7171
|
+
return afterProtocol.slice(pathnameSlashIndex);
|
|
7145
7172
|
}
|
|
7146
7173
|
|
|
7147
|
-
return urlString.slice(scheme.length + 1)
|
|
7174
|
+
return urlString.slice(scheme.length + 1);
|
|
7148
7175
|
};
|
|
7149
7176
|
|
|
7150
7177
|
const ressourceToPathname = (ressource) => {
|
|
7151
7178
|
const searchSeparatorIndex = ressource.indexOf("?");
|
|
7152
7179
|
return searchSeparatorIndex === -1
|
|
7153
7180
|
? ressource
|
|
7154
|
-
: ressource.slice(0, searchSeparatorIndex)
|
|
7155
|
-
};
|
|
7156
|
-
|
|
7157
|
-
const urlToOrigin = (urlString) => {
|
|
7158
|
-
const scheme = urlToScheme(urlString);
|
|
7159
|
-
|
|
7160
|
-
if (scheme === "file") {
|
|
7161
|
-
return "file://"
|
|
7162
|
-
}
|
|
7163
|
-
|
|
7164
|
-
if (scheme === "http" || scheme === "https") {
|
|
7165
|
-
const secondProtocolSlashIndex = scheme.length + "://".length;
|
|
7166
|
-
const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
|
|
7167
|
-
|
|
7168
|
-
if (pathnameSlashIndex === -1) return urlString
|
|
7169
|
-
return urlString.slice(0, pathnameSlashIndex)
|
|
7170
|
-
}
|
|
7171
|
-
|
|
7172
|
-
return urlString.slice(0, scheme.length + 1)
|
|
7173
|
-
};
|
|
7174
|
-
|
|
7175
|
-
const pathnameToParentPathname = (pathname) => {
|
|
7176
|
-
const slashLastIndex = pathname.lastIndexOf("/");
|
|
7177
|
-
if (slashLastIndex === -1) {
|
|
7178
|
-
return "/"
|
|
7179
|
-
}
|
|
7180
|
-
|
|
7181
|
-
return pathname.slice(0, slashLastIndex + 1)
|
|
7181
|
+
: ressource.slice(0, searchSeparatorIndex);
|
|
7182
7182
|
};
|
|
7183
7183
|
|
|
7184
7184
|
// could be useful: https://url.spec.whatwg.org/#url-miscellaneous
|
|
@@ -7187,29 +7187,29 @@ const pathnameToParentPathname = (pathname) => {
|
|
|
7187
7187
|
const resolveUrl = (specifier, baseUrl) => {
|
|
7188
7188
|
if (baseUrl) {
|
|
7189
7189
|
if (typeof baseUrl !== "string") {
|
|
7190
|
-
throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }))
|
|
7190
|
+
throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }));
|
|
7191
7191
|
}
|
|
7192
7192
|
if (!hasScheme(baseUrl)) {
|
|
7193
|
-
throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }))
|
|
7193
|
+
throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }));
|
|
7194
7194
|
}
|
|
7195
7195
|
}
|
|
7196
7196
|
|
|
7197
7197
|
if (hasScheme(specifier)) {
|
|
7198
|
-
return specifier
|
|
7198
|
+
return specifier;
|
|
7199
7199
|
}
|
|
7200
7200
|
|
|
7201
7201
|
if (!baseUrl) {
|
|
7202
|
-
throw new Error(writeBaseUrlRequired({ baseUrl, specifier }))
|
|
7202
|
+
throw new Error(writeBaseUrlRequired({ baseUrl, specifier }));
|
|
7203
7203
|
}
|
|
7204
7204
|
|
|
7205
7205
|
// scheme relative
|
|
7206
7206
|
if (specifier.slice(0, 2) === "//") {
|
|
7207
|
-
return `${urlToScheme(baseUrl)}:${specifier}
|
|
7207
|
+
return `${urlToScheme(baseUrl)}:${specifier}`;
|
|
7208
7208
|
}
|
|
7209
7209
|
|
|
7210
7210
|
// origin relative
|
|
7211
7211
|
if (specifier[0] === "/") {
|
|
7212
|
-
return `${urlToOrigin(baseUrl)}${specifier}
|
|
7212
|
+
return `${urlToOrigin(baseUrl)}${specifier}`;
|
|
7213
7213
|
}
|
|
7214
7214
|
|
|
7215
7215
|
const baseOrigin = urlToOrigin(baseUrl);
|
|
@@ -7217,13 +7217,13 @@ const resolveUrl = (specifier, baseUrl) => {
|
|
|
7217
7217
|
|
|
7218
7218
|
if (specifier === ".") {
|
|
7219
7219
|
const baseDirectoryPathname = pathnameToParentPathname(basePathname);
|
|
7220
|
-
return `${baseOrigin}${baseDirectoryPathname}
|
|
7220
|
+
return `${baseOrigin}${baseDirectoryPathname}`;
|
|
7221
7221
|
}
|
|
7222
7222
|
|
|
7223
7223
|
// pathname relative inside
|
|
7224
7224
|
if (specifier.slice(0, 2) === "./") {
|
|
7225
7225
|
const baseDirectoryPathname = pathnameToParentPathname(basePathname);
|
|
7226
|
-
return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}
|
|
7226
|
+
return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}`;
|
|
7227
7227
|
}
|
|
7228
7228
|
|
|
7229
7229
|
// pathname relative outside
|
|
@@ -7244,17 +7244,17 @@ const resolveUrl = (specifier, baseUrl) => {
|
|
|
7244
7244
|
const resolvedPathname = `${importerFolders.join(
|
|
7245
7245
|
"/",
|
|
7246
7246
|
)}/${unresolvedPathname}`;
|
|
7247
|
-
return `${baseOrigin}${resolvedPathname}
|
|
7247
|
+
return `${baseOrigin}${resolvedPathname}`;
|
|
7248
7248
|
}
|
|
7249
7249
|
|
|
7250
7250
|
// bare
|
|
7251
7251
|
if (basePathname === "") {
|
|
7252
|
-
return `${baseOrigin}/${specifier}
|
|
7252
|
+
return `${baseOrigin}/${specifier}`;
|
|
7253
7253
|
}
|
|
7254
7254
|
if (basePathname[basePathname.length] === "/") {
|
|
7255
|
-
return `${baseOrigin}${basePathname}${specifier}
|
|
7255
|
+
return `${baseOrigin}${basePathname}${specifier}`;
|
|
7256
7256
|
}
|
|
7257
|
-
return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}
|
|
7257
|
+
return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}`;
|
|
7258
7258
|
};
|
|
7259
7259
|
|
|
7260
7260
|
const writeBaseUrlMustBeAString = ({
|
|
@@ -7286,7 +7286,7 @@ ${specifier}`;
|
|
|
7286
7286
|
|
|
7287
7287
|
const tryUrlResolution = (string, url) => {
|
|
7288
7288
|
const result = resolveUrl(string, url);
|
|
7289
|
-
return hasScheme(result) ? result : null
|
|
7289
|
+
return hasScheme(result) ? result : null;
|
|
7290
7290
|
};
|
|
7291
7291
|
|
|
7292
7292
|
const resolveSpecifier = (specifier, importer) => {
|
|
@@ -7296,14 +7296,14 @@ const resolveSpecifier = (specifier, importer) => {
|
|
|
7296
7296
|
specifier.startsWith("./") ||
|
|
7297
7297
|
specifier.startsWith("../")
|
|
7298
7298
|
) {
|
|
7299
|
-
return resolveUrl(specifier, importer)
|
|
7299
|
+
return resolveUrl(specifier, importer);
|
|
7300
7300
|
}
|
|
7301
7301
|
|
|
7302
7302
|
if (hasScheme(specifier)) {
|
|
7303
|
-
return specifier
|
|
7303
|
+
return specifier;
|
|
7304
7304
|
}
|
|
7305
7305
|
|
|
7306
|
-
return null
|
|
7306
|
+
return null;
|
|
7307
7307
|
};
|
|
7308
7308
|
|
|
7309
7309
|
const applyImportMap = ({
|
|
@@ -7316,7 +7316,7 @@ const applyImportMap = ({
|
|
|
7316
7316
|
specifier,
|
|
7317
7317
|
importer,
|
|
7318
7318
|
}),
|
|
7319
|
-
)
|
|
7319
|
+
);
|
|
7320
7320
|
},
|
|
7321
7321
|
onImportMapping = () => {},
|
|
7322
7322
|
}) => {
|
|
@@ -7327,7 +7327,7 @@ const applyImportMap = ({
|
|
|
7327
7327
|
specifier,
|
|
7328
7328
|
importer,
|
|
7329
7329
|
}),
|
|
7330
|
-
)
|
|
7330
|
+
);
|
|
7331
7331
|
}
|
|
7332
7332
|
if (importer) {
|
|
7333
7333
|
if (typeof importer !== "string") {
|
|
@@ -7336,7 +7336,7 @@ const applyImportMap = ({
|
|
|
7336
7336
|
importer,
|
|
7337
7337
|
specifier,
|
|
7338
7338
|
}),
|
|
7339
|
-
)
|
|
7339
|
+
);
|
|
7340
7340
|
}
|
|
7341
7341
|
if (!hasScheme(importer)) {
|
|
7342
7342
|
throw new Error(
|
|
@@ -7344,7 +7344,7 @@ const applyImportMap = ({
|
|
|
7344
7344
|
importer,
|
|
7345
7345
|
specifier,
|
|
7346
7346
|
}),
|
|
7347
|
-
)
|
|
7347
|
+
);
|
|
7348
7348
|
}
|
|
7349
7349
|
}
|
|
7350
7350
|
|
|
@@ -7358,7 +7358,7 @@ const applyImportMap = ({
|
|
|
7358
7358
|
return (
|
|
7359
7359
|
scopeSpecifier === importer ||
|
|
7360
7360
|
specifierIsPrefixOf(scopeSpecifier, importer)
|
|
7361
|
-
)
|
|
7361
|
+
);
|
|
7362
7362
|
},
|
|
7363
7363
|
);
|
|
7364
7364
|
if (scopeSpecifierMatching) {
|
|
@@ -7370,7 +7370,7 @@ const applyImportMap = ({
|
|
|
7370
7370
|
onImportMapping,
|
|
7371
7371
|
);
|
|
7372
7372
|
if (mappingFromScopes !== null) {
|
|
7373
|
-
return mappingFromScopes
|
|
7373
|
+
return mappingFromScopes;
|
|
7374
7374
|
}
|
|
7375
7375
|
}
|
|
7376
7376
|
}
|
|
@@ -7384,15 +7384,15 @@ const applyImportMap = ({
|
|
|
7384
7384
|
onImportMapping,
|
|
7385
7385
|
);
|
|
7386
7386
|
if (mappingFromImports !== null) {
|
|
7387
|
-
return mappingFromImports
|
|
7387
|
+
return mappingFromImports;
|
|
7388
7388
|
}
|
|
7389
7389
|
}
|
|
7390
7390
|
|
|
7391
7391
|
if (specifierUrl) {
|
|
7392
|
-
return specifierUrl
|
|
7392
|
+
return specifierUrl;
|
|
7393
7393
|
}
|
|
7394
7394
|
|
|
7395
|
-
throw createBareSpecifierError({ specifier, importer })
|
|
7395
|
+
throw createBareSpecifierError({ specifier, importer });
|
|
7396
7396
|
};
|
|
7397
7397
|
|
|
7398
7398
|
const applyMappings = (
|
|
@@ -7416,7 +7416,7 @@ const applyMappings = (
|
|
|
7416
7416
|
before: specifierNormalized,
|
|
7417
7417
|
after: address,
|
|
7418
7418
|
});
|
|
7419
|
-
return address
|
|
7419
|
+
return address;
|
|
7420
7420
|
}
|
|
7421
7421
|
if (specifierIsPrefixOf(specifierCandidate, specifierNormalized)) {
|
|
7422
7422
|
const address = mappings[specifierCandidate];
|
|
@@ -7431,18 +7431,18 @@ const applyMappings = (
|
|
|
7431
7431
|
before: specifierNormalized,
|
|
7432
7432
|
after: addressFinal,
|
|
7433
7433
|
});
|
|
7434
|
-
return addressFinal
|
|
7434
|
+
return addressFinal;
|
|
7435
7435
|
}
|
|
7436
7436
|
}
|
|
7437
7437
|
|
|
7438
|
-
return null
|
|
7438
|
+
return null;
|
|
7439
7439
|
};
|
|
7440
7440
|
|
|
7441
7441
|
const specifierIsPrefixOf = (specifierHref, href) => {
|
|
7442
7442
|
return (
|
|
7443
7443
|
specifierHref[specifierHref.length - 1] === "/" &&
|
|
7444
7444
|
href.startsWith(specifierHref)
|
|
7445
|
-
)
|
|
7445
|
+
);
|
|
7446
7446
|
};
|
|
7447
7447
|
|
|
7448
7448
|
// https://github.com/systemjs/systemjs/blob/89391f92dfeac33919b0223bbf834a1f4eea5750/src/common.js#L136
|
|
@@ -7481,7 +7481,7 @@ const composeTwoImportMaps = (leftImportMap, rightImportMap) => {
|
|
|
7481
7481
|
importMap.scopes = { ...rightScopes };
|
|
7482
7482
|
}
|
|
7483
7483
|
|
|
7484
|
-
return importMap
|
|
7484
|
+
return importMap;
|
|
7485
7485
|
};
|
|
7486
7486
|
|
|
7487
7487
|
const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
@@ -7490,11 +7490,11 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
|
7490
7490
|
Object.keys(leftMappings).forEach((leftSpecifier) => {
|
|
7491
7491
|
if (objectHasKey(rightMappings, leftSpecifier)) {
|
|
7492
7492
|
// will be overidden
|
|
7493
|
-
return
|
|
7493
|
+
return;
|
|
7494
7494
|
}
|
|
7495
7495
|
const leftAddress = leftMappings[leftSpecifier];
|
|
7496
7496
|
const rightSpecifier = Object.keys(rightMappings).find((rightSpecifier) => {
|
|
7497
|
-
return compareAddressAndSpecifier(leftAddress, rightSpecifier)
|
|
7497
|
+
return compareAddressAndSpecifier(leftAddress, rightSpecifier);
|
|
7498
7498
|
});
|
|
7499
7499
|
mappings[leftSpecifier] = rightSpecifier
|
|
7500
7500
|
? rightMappings[rightSpecifier]
|
|
@@ -7505,7 +7505,7 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
|
7505
7505
|
mappings[rightSpecifier] = rightMappings[rightSpecifier];
|
|
7506
7506
|
});
|
|
7507
7507
|
|
|
7508
|
-
return mappings
|
|
7508
|
+
return mappings;
|
|
7509
7509
|
};
|
|
7510
7510
|
|
|
7511
7511
|
const objectHasKey = (object, key) =>
|
|
@@ -7514,7 +7514,7 @@ const objectHasKey = (object, key) =>
|
|
|
7514
7514
|
const compareAddressAndSpecifier = (address, specifier) => {
|
|
7515
7515
|
const addressUrl = resolveUrl(address, "file:///");
|
|
7516
7516
|
const specifierUrl = resolveUrl(specifier, "file:///");
|
|
7517
|
-
return addressUrl === specifierUrl
|
|
7517
|
+
return addressUrl === specifierUrl;
|
|
7518
7518
|
};
|
|
7519
7519
|
|
|
7520
7520
|
const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
@@ -7524,14 +7524,14 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
|
7524
7524
|
if (objectHasKey(rightScopes, leftScopeKey)) {
|
|
7525
7525
|
// will be merged
|
|
7526
7526
|
scopes[leftScopeKey] = leftScopes[leftScopeKey];
|
|
7527
|
-
return
|
|
7527
|
+
return;
|
|
7528
7528
|
}
|
|
7529
7529
|
const topLevelSpecifier = Object.keys(imports).find(
|
|
7530
7530
|
(topLevelSpecifierCandidate) => {
|
|
7531
7531
|
return compareAddressAndSpecifier(
|
|
7532
7532
|
leftScopeKey,
|
|
7533
7533
|
topLevelSpecifierCandidate,
|
|
7534
|
-
)
|
|
7534
|
+
);
|
|
7535
7535
|
},
|
|
7536
7536
|
);
|
|
7537
7537
|
if (topLevelSpecifier) {
|
|
@@ -7554,7 +7554,7 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
|
7554
7554
|
}
|
|
7555
7555
|
});
|
|
7556
7556
|
|
|
7557
|
-
return scopes
|
|
7557
|
+
return scopes;
|
|
7558
7558
|
};
|
|
7559
7559
|
|
|
7560
7560
|
const sortImports = (imports) => {
|
|
@@ -7566,7 +7566,7 @@ const sortImports = (imports) => {
|
|
|
7566
7566
|
mappingsSorted[name] = imports[name];
|
|
7567
7567
|
});
|
|
7568
7568
|
|
|
7569
|
-
return mappingsSorted
|
|
7569
|
+
return mappingsSorted;
|
|
7570
7570
|
};
|
|
7571
7571
|
|
|
7572
7572
|
const sortScopes = (scopes) => {
|
|
@@ -7578,18 +7578,18 @@ const sortScopes = (scopes) => {
|
|
|
7578
7578
|
scopesSorted[scopeSpecifier] = sortImports(scopes[scopeSpecifier]);
|
|
7579
7579
|
});
|
|
7580
7580
|
|
|
7581
|
-
return scopesSorted
|
|
7581
|
+
return scopesSorted;
|
|
7582
7582
|
};
|
|
7583
7583
|
|
|
7584
7584
|
const compareLengthOrLocaleCompare = (a, b) => {
|
|
7585
|
-
return b.length - a.length || a.localeCompare(b)
|
|
7585
|
+
return b.length - a.length || a.localeCompare(b);
|
|
7586
7586
|
};
|
|
7587
7587
|
|
|
7588
7588
|
const normalizeImportMap = (importMap, baseUrl) => {
|
|
7589
7589
|
assertImportMap(importMap);
|
|
7590
7590
|
|
|
7591
7591
|
if (!isStringOrUrl(baseUrl)) {
|
|
7592
|
-
throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }))
|
|
7592
|
+
throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }));
|
|
7593
7593
|
}
|
|
7594
7594
|
|
|
7595
7595
|
const { imports, scopes } = importMap;
|
|
@@ -7597,19 +7597,19 @@ const normalizeImportMap = (importMap, baseUrl) => {
|
|
|
7597
7597
|
return {
|
|
7598
7598
|
imports: imports ? normalizeMappings(imports, baseUrl) : undefined,
|
|
7599
7599
|
scopes: scopes ? normalizeScopes(scopes, baseUrl) : undefined,
|
|
7600
|
-
}
|
|
7600
|
+
};
|
|
7601
7601
|
};
|
|
7602
7602
|
|
|
7603
7603
|
const isStringOrUrl = (value) => {
|
|
7604
7604
|
if (typeof value === "string") {
|
|
7605
|
-
return true
|
|
7605
|
+
return true;
|
|
7606
7606
|
}
|
|
7607
7607
|
|
|
7608
7608
|
if (typeof URL === "function" && value instanceof URL) {
|
|
7609
|
-
return true
|
|
7609
|
+
return true;
|
|
7610
7610
|
}
|
|
7611
7611
|
|
|
7612
|
-
return false
|
|
7612
|
+
return false;
|
|
7613
7613
|
};
|
|
7614
7614
|
|
|
7615
7615
|
const normalizeMappings = (mappings, baseUrl) => {
|
|
@@ -7625,7 +7625,7 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
7625
7625
|
specifier,
|
|
7626
7626
|
}),
|
|
7627
7627
|
);
|
|
7628
|
-
return
|
|
7628
|
+
return;
|
|
7629
7629
|
}
|
|
7630
7630
|
|
|
7631
7631
|
const specifierResolved = resolveSpecifier(specifier, baseUrl) || specifier;
|
|
@@ -7639,7 +7639,7 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
7639
7639
|
specifier,
|
|
7640
7640
|
}),
|
|
7641
7641
|
);
|
|
7642
|
-
return
|
|
7642
|
+
return;
|
|
7643
7643
|
}
|
|
7644
7644
|
|
|
7645
7645
|
if (specifier.endsWith("/") && !addressUrl.endsWith("/")) {
|
|
@@ -7649,12 +7649,12 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
7649
7649
|
specifier,
|
|
7650
7650
|
}),
|
|
7651
7651
|
);
|
|
7652
|
-
return
|
|
7652
|
+
return;
|
|
7653
7653
|
}
|
|
7654
7654
|
mappingsNormalized[specifierResolved] = addressUrl;
|
|
7655
7655
|
});
|
|
7656
7656
|
|
|
7657
|
-
return sortImports(mappingsNormalized)
|
|
7657
|
+
return sortImports(mappingsNormalized);
|
|
7658
7658
|
};
|
|
7659
7659
|
|
|
7660
7660
|
const normalizeScopes = (scopes, baseUrl) => {
|
|
@@ -7670,13 +7670,13 @@ const normalizeScopes = (scopes, baseUrl) => {
|
|
|
7670
7670
|
baseUrl,
|
|
7671
7671
|
}),
|
|
7672
7672
|
);
|
|
7673
|
-
return
|
|
7673
|
+
return;
|
|
7674
7674
|
}
|
|
7675
7675
|
const scopeValueNormalized = normalizeMappings(scopeMappings, baseUrl);
|
|
7676
7676
|
scopesNormalized[scopeUrl] = scopeValueNormalized;
|
|
7677
7677
|
});
|
|
7678
7678
|
|
|
7679
|
-
return sortScopes(scopesNormalized)
|
|
7679
|
+
return sortScopes(scopesNormalized);
|
|
7680
7680
|
};
|
|
7681
7681
|
|
|
7682
7682
|
const formulateBaseUrlMustBeStringOrUrl = ({
|
|
@@ -7734,9 +7734,9 @@ const pathnameToExtension = (pathname) => {
|
|
|
7734
7734
|
}
|
|
7735
7735
|
|
|
7736
7736
|
const dotLastIndex = pathname.lastIndexOf(".");
|
|
7737
|
-
if (dotLastIndex === -1) return ""
|
|
7737
|
+
if (dotLastIndex === -1) return "";
|
|
7738
7738
|
// if (dotLastIndex === pathname.length - 1) return ""
|
|
7739
|
-
return pathname.slice(dotLastIndex)
|
|
7739
|
+
return pathname.slice(dotLastIndex);
|
|
7740
7740
|
};
|
|
7741
7741
|
|
|
7742
7742
|
const resolveImport = ({
|
|
@@ -7764,20 +7764,20 @@ const resolveImport = ({
|
|
|
7764
7764
|
url = applyDefaultExtension({ url, importer, defaultExtension });
|
|
7765
7765
|
}
|
|
7766
7766
|
|
|
7767
|
-
return url
|
|
7767
|
+
return url;
|
|
7768
7768
|
};
|
|
7769
7769
|
|
|
7770
7770
|
const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
|
|
7771
7771
|
if (urlToPathname(url).endsWith("/")) {
|
|
7772
|
-
return url
|
|
7772
|
+
return url;
|
|
7773
7773
|
}
|
|
7774
7774
|
|
|
7775
7775
|
if (typeof defaultExtension === "string") {
|
|
7776
7776
|
const extension = pathnameToExtension(url);
|
|
7777
7777
|
if (extension === "") {
|
|
7778
|
-
return `${url}${defaultExtension}
|
|
7778
|
+
return `${url}${defaultExtension}`;
|
|
7779
7779
|
}
|
|
7780
|
-
return url
|
|
7780
|
+
return url;
|
|
7781
7781
|
}
|
|
7782
7782
|
|
|
7783
7783
|
if (defaultExtension === true) {
|
|
@@ -7785,11 +7785,11 @@ const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
|
|
|
7785
7785
|
if (extension === "" && importer) {
|
|
7786
7786
|
const importerPathname = urlToPathname(importer);
|
|
7787
7787
|
const importerExtension = pathnameToExtension(importerPathname);
|
|
7788
|
-
return `${url}${importerExtension}
|
|
7788
|
+
return `${url}${importerExtension}`;
|
|
7789
7789
|
}
|
|
7790
7790
|
}
|
|
7791
7791
|
|
|
7792
|
-
return url
|
|
7792
|
+
return url;
|
|
7793
7793
|
};
|
|
7794
7794
|
|
|
7795
7795
|
const isEscaped = (i, string) => {
|