@jsenv/core 32.2.0 → 32.2.1
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/main.js
CHANGED
|
@@ -17174,21 +17174,19 @@ const jsenvPluginUrlResolution = ({
|
|
|
17174
17174
|
Object.keys(urlResolution).forEach(urlType => {
|
|
17175
17175
|
const resolver = urlResolution[urlType];
|
|
17176
17176
|
if (typeof resolver !== "object") {
|
|
17177
|
-
throw new Error(`
|
|
17178
|
-
"${urlType}" resolution value must be an object, got ${resolver}`);
|
|
17177
|
+
throw new Error(`urlResolution values must be objects, got ${resolver} on "${urlType}"`);
|
|
17179
17178
|
}
|
|
17180
17179
|
let {
|
|
17181
17180
|
web,
|
|
17182
17181
|
node_esm,
|
|
17183
17182
|
...rest
|
|
17184
17183
|
} = resolver;
|
|
17185
|
-
const
|
|
17186
|
-
if (
|
|
17187
|
-
throw new
|
|
17188
|
-
"${urlType}" resolution key must be "web" or "node_esm", found "${Object.keys(rest)[0]}"`);
|
|
17184
|
+
const unexpectedKeys = Object.keys(rest);
|
|
17185
|
+
if (unexpectedKeys.length) {
|
|
17186
|
+
throw new TypeError(`${unexpectedKeys.join(",")}: there is no such configuration on "${urlType}"`);
|
|
17189
17187
|
}
|
|
17190
17188
|
if (node_esm === undefined) {
|
|
17191
|
-
node_esm = urlType === "js_import"
|
|
17189
|
+
node_esm = urlType === "js_import";
|
|
17192
17190
|
}
|
|
17193
17191
|
if (web === undefined) {
|
|
17194
17192
|
web = true;
|
|
@@ -17208,11 +17206,20 @@ const jsenvPluginUrlResolution = ({
|
|
|
17208
17206
|
resolvers[urlType] = resolveUrlUsingWebResolution;
|
|
17209
17207
|
}
|
|
17210
17208
|
});
|
|
17209
|
+
const nodeEsmResolverDefault = createNodeEsmResolver({
|
|
17210
|
+
runtimeCompat,
|
|
17211
|
+
preservesSymlink: true
|
|
17212
|
+
});
|
|
17211
17213
|
if (!resolvers.js_module) {
|
|
17212
|
-
resolvers.js_module =
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17214
|
+
resolvers.js_module = nodeEsmResolverDefault;
|
|
17215
|
+
}
|
|
17216
|
+
if (!resolvers.js_classic) {
|
|
17217
|
+
resolvers.js_classic = (reference, context) => {
|
|
17218
|
+
if (reference.subtype === "self_import_scripts_arg") {
|
|
17219
|
+
return nodeEsmResolverDefault(reference, context);
|
|
17220
|
+
}
|
|
17221
|
+
return resolveUrlUsingWebResolution(reference);
|
|
17222
|
+
};
|
|
17216
17223
|
}
|
|
17217
17224
|
if (!resolvers["*"]) {
|
|
17218
17225
|
resolvers["*"] = resolveUrlUsingWebResolution;
|
|
@@ -17230,17 +17237,13 @@ const jsenvPluginUrlResolution = ({
|
|
|
17230
17237
|
if (reference.type === "sourcemap_comment") {
|
|
17231
17238
|
return resolveUrlUsingWebResolution(reference);
|
|
17232
17239
|
}
|
|
17233
|
-
let
|
|
17234
|
-
let subtype;
|
|
17235
|
-
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
|
|
17240
|
+
let urlType;
|
|
17236
17241
|
if (reference.injected) {
|
|
17237
|
-
|
|
17238
|
-
subtype = reference.expectedSubtype;
|
|
17242
|
+
urlType = reference.expectedType;
|
|
17239
17243
|
} else {
|
|
17240
|
-
|
|
17241
|
-
|
|
17244
|
+
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
|
|
17245
|
+
urlType = parentUrlInfo ? parentUrlInfo.type : "entry_point";
|
|
17242
17246
|
}
|
|
17243
|
-
const urlType = subtype === "self_import_scripts_arg" ? "js_import_script" : type;
|
|
17244
17247
|
const resolver = resolvers[urlType] || resolvers["*"];
|
|
17245
17248
|
return resolver(reference, context);
|
|
17246
17249
|
},
|
package/package.json
CHANGED
|
@@ -50,22 +50,20 @@ export const jsenvPluginUrlResolution = ({
|
|
|
50
50
|
const resolver = urlResolution[urlType]
|
|
51
51
|
if (typeof resolver !== "object") {
|
|
52
52
|
throw new Error(
|
|
53
|
-
`
|
|
54
|
-
"${urlType}" resolution value must be an object, got ${resolver}`,
|
|
53
|
+
`urlResolution values must be objects, got ${resolver} on "${urlType}"`,
|
|
55
54
|
)
|
|
56
55
|
}
|
|
57
56
|
let { web, node_esm, ...rest } = resolver
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
throw new
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
}"`,
|
|
57
|
+
const unexpectedKeys = Object.keys(rest)
|
|
58
|
+
if (unexpectedKeys.length) {
|
|
59
|
+
throw new TypeError(
|
|
60
|
+
`${unexpectedKeys.join(
|
|
61
|
+
",",
|
|
62
|
+
)}: there is no such configuration on "${urlType}"`,
|
|
65
63
|
)
|
|
66
64
|
}
|
|
67
65
|
if (node_esm === undefined) {
|
|
68
|
-
node_esm = urlType === "js_import"
|
|
66
|
+
node_esm = urlType === "js_import"
|
|
69
67
|
}
|
|
70
68
|
if (web === undefined) {
|
|
71
69
|
web = true
|
|
@@ -83,11 +81,20 @@ export const jsenvPluginUrlResolution = ({
|
|
|
83
81
|
}
|
|
84
82
|
})
|
|
85
83
|
|
|
84
|
+
const nodeEsmResolverDefault = createNodeEsmResolver({
|
|
85
|
+
runtimeCompat,
|
|
86
|
+
preservesSymlink: true,
|
|
87
|
+
})
|
|
86
88
|
if (!resolvers.js_module) {
|
|
87
|
-
resolvers.js_module =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
resolvers.js_module = nodeEsmResolverDefault
|
|
90
|
+
}
|
|
91
|
+
if (!resolvers.js_classic) {
|
|
92
|
+
resolvers.js_classic = (reference, context) => {
|
|
93
|
+
if (reference.subtype === "self_import_scripts_arg") {
|
|
94
|
+
return nodeEsmResolverDefault(reference, context)
|
|
95
|
+
}
|
|
96
|
+
return resolveUrlUsingWebResolution(reference, context)
|
|
97
|
+
}
|
|
91
98
|
}
|
|
92
99
|
if (!resolvers["*"]) {
|
|
93
100
|
resolvers["*"] = resolveUrlUsingWebResolution
|
|
@@ -107,19 +114,13 @@ export const jsenvPluginUrlResolution = ({
|
|
|
107
114
|
if (reference.type === "sourcemap_comment") {
|
|
108
115
|
return resolveUrlUsingWebResolution(reference, context)
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
let type
|
|
112
|
-
let subtype
|
|
113
|
-
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
|
|
117
|
+
let urlType
|
|
114
118
|
if (reference.injected) {
|
|
115
|
-
|
|
116
|
-
subtype = reference.expectedSubtype
|
|
119
|
+
urlType = reference.expectedType
|
|
117
120
|
} else {
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
|
|
122
|
+
urlType = parentUrlInfo ? parentUrlInfo.type : "entry_point"
|
|
120
123
|
}
|
|
121
|
-
const urlType =
|
|
122
|
-
subtype === "self_import_scripts_arg" ? "js_import_script" : type
|
|
123
124
|
const resolver = resolvers[urlType] || resolvers["*"]
|
|
124
125
|
return resolver(reference, context)
|
|
125
126
|
},
|