@jsenv/core 34.1.5 → 34.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/js/s.js.map +2 -2
- package/dist/jsenv.js +101 -194
- package/package.json +2 -2
- package/src/build/build.js +18 -20
- package/src/dev/file_service.js +1 -1
- package/src/dev/start_dev_server.js +17 -16
- package/src/execute/web_server_param.js +5 -1
- package/src/kitchen/url_graph/url_info_transformations.js +1 -1
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +1 -1
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +3 -3
- package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/convert_js_module_to_js_classic.js +6 -2
- package/src/plugins/transpilation/{as_js_classic/jsenv_plugin_as_js_classic_conversion.js → js_module_fallback/jsenv_plugin_js_module_conversion.js} +13 -12
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback.js +45 -0
- package/src/plugins/transpilation/{as_js_classic/jsenv_plugin_as_js_classic_html.js → js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js} +7 -7
- package/src/plugins/transpilation/{as_js_classic/jsenv_plugin_as_js_classic_workers.js → js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js} +3 -3
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +10 -11
- package/src/plugins/url_analysis/jsenv_plugin_reference_expected_types.js +2 -2
- package/src/test/execute_steps.js +1 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +0 -61
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +0 -91
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/async-to-promises.js +0 -0
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/client/s.js +0 -0
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/helpers/babel_plugin_transform_import_meta_resolve.js +0 -0
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/helpers/babel_plugin_transform_import_meta_url.js +0 -0
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/helpers/systemjs_old.js +0 -0
- /package/src/plugins/transpilation/{as_js_classic → js_module_fallback}/helpers-string.js +0 -0
package/dist/js/s.js.map
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"sources": [
|
|
4
4
|
"../../packages/babel-plugins/src/babel_helpers/arrayWithHoles/arrayWithHoles.js",
|
|
5
5
|
"../../packages/babel-plugins/src/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js",
|
|
6
|
-
"../../src/plugins/transpilation/
|
|
6
|
+
"../../src/plugins/transpilation/js_module_fallback/client/s.js",
|
|
7
7
|
"../../packages/babel-plugins/src/babel_helpers/arrayLikeToArray/arrayLikeToArray.js",
|
|
8
8
|
"../../packages/babel-plugins/src/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js",
|
|
9
9
|
"../../packages/babel-plugins/src/babel_helpers/nonIterableRest/nonIterableRest.js",
|
|
10
10
|
"../../packages/babel-plugins/src/babel_helpers/slicedToArray/slicedToArray.js",
|
|
11
11
|
"../../packages/babel-plugins/src/babel_helpers/typeof/typeof.js",
|
|
12
|
-
"../../src/plugins/transpilation/
|
|
12
|
+
"../../src/plugins/transpilation/js_module_fallback/client/s.js?as_js_classic"
|
|
13
13
|
],
|
|
14
14
|
"names": [
|
|
15
15
|
"arr",
|
package/dist/jsenv.js
CHANGED
|
@@ -18,7 +18,6 @@ import { SOURCEMAP, generateSourcemapFileUrl, composeTwoSourcemaps, generateSour
|
|
|
18
18
|
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, parseCssUrls, parseJsUrls, getHtmlNodeText, setHtmlNodeText, removeHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, injectJsImport, analyzeLinkNode, injectHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
|
|
19
19
|
import { createRequire } from "node:module";
|
|
20
20
|
import babelParser from "@babel/parser";
|
|
21
|
-
import { bundleJsModules } from "@jsenv/plugin-bundling";
|
|
22
21
|
import v8, { takeCoverage } from "node:v8";
|
|
23
22
|
import stripAnsi from "strip-ansi";
|
|
24
23
|
import { createId } from "@paralleldrive/cuid2";
|
|
@@ -7872,9 +7871,9 @@ const createUrlInfoTransformer = ({
|
|
|
7872
7871
|
// during build it's urlInfo.url to be inside the build
|
|
7873
7872
|
// but otherwise it's generatedUrl to be inside .jsenv/ directory
|
|
7874
7873
|
const generatedUrlObject = new URL(urlInfo.generatedUrl);
|
|
7874
|
+
generatedUrlObject.searchParams.delete("js_module_fallback");
|
|
7875
7875
|
generatedUrlObject.searchParams.delete("as_js_module");
|
|
7876
7876
|
generatedUrlObject.searchParams.delete("as_js_classic");
|
|
7877
|
-
generatedUrlObject.searchParams.delete("as_js_classic_library");
|
|
7878
7877
|
const urlForSourcemap = generatedUrlObject.href;
|
|
7879
7878
|
urlInfo.sourcemapGeneratedUrl = generateSourcemapFileUrl(urlForSourcemap);
|
|
7880
7879
|
|
|
@@ -9880,7 +9879,7 @@ const jsenvPluginReferenceExpectedTypes = () => {
|
|
|
9880
9879
|
}
|
|
9881
9880
|
if (searchParams.has("js_classic")) {
|
|
9882
9881
|
reference.expectedType = "js_classic";
|
|
9883
|
-
} else if (searchParams.has("
|
|
9882
|
+
} else if (searchParams.has("js_module_fallback") || searchParams.has("as_js_classic")) {
|
|
9884
9883
|
reference.expectedType = "js_classic";
|
|
9885
9884
|
} else if (searchParams.has("as_js_module")) {
|
|
9886
9885
|
reference.expectedType = "js_module";
|
|
@@ -10526,7 +10525,7 @@ ${e.traceMessage}`);
|
|
|
10526
10525
|
// If the inline script was already handled by an other plugin, ignore it
|
|
10527
10526
|
// - we want to preserve inline scripts generated by html supervisor during dev
|
|
10528
10527
|
// - we want to avoid cooking twice a script during build
|
|
10529
|
-
if (!analyzeConvertedScripts && getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:
|
|
10528
|
+
if (!analyzeConvertedScripts && getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:js_module_fallback") {
|
|
10530
10529
|
return;
|
|
10531
10530
|
}
|
|
10532
10531
|
const hotAccept = getHtmlNodeAttribute(scriptNode, "hot-accept") !== undefined;
|
|
@@ -14766,9 +14765,10 @@ function default_1({
|
|
|
14766
14765
|
};
|
|
14767
14766
|
}
|
|
14768
14767
|
|
|
14768
|
+
const systemJsClientFileUrlDefault = new URL("./js/s.js", import.meta.url).href;
|
|
14769
14769
|
const convertJsModuleToJsClassic = async ({
|
|
14770
14770
|
systemJsInjection,
|
|
14771
|
-
systemJsClientFileUrl,
|
|
14771
|
+
systemJsClientFileUrl = systemJsClientFileUrlDefault,
|
|
14772
14772
|
urlInfo,
|
|
14773
14773
|
jsModuleUrlInfo
|
|
14774
14774
|
}) => {
|
|
@@ -14903,10 +14903,10 @@ const babelPluginRelativeImports = babel => {
|
|
|
14903
14903
|
};
|
|
14904
14904
|
|
|
14905
14905
|
/*
|
|
14906
|
-
* - propagate ?
|
|
14907
|
-
* - perform conversion from js module to js classic when url uses ?
|
|
14906
|
+
* - propagate "?js_module_fallback" query string param on urls
|
|
14907
|
+
* - perform conversion from js module to js classic when url uses "?js_module_fallback"
|
|
14908
14908
|
*/
|
|
14909
|
-
const
|
|
14909
|
+
const jsenvPluginJsModuleConversion = ({
|
|
14910
14910
|
systemJsInjection,
|
|
14911
14911
|
systemJsClientFileUrl,
|
|
14912
14912
|
generateJsClassicFilename
|
|
@@ -14920,13 +14920,13 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
14920
14920
|
}
|
|
14921
14921
|
return false;
|
|
14922
14922
|
};
|
|
14923
|
-
const
|
|
14923
|
+
const shouldPropagateJsModuleConversion = (reference, context) => {
|
|
14924
14924
|
if (isReferencingJsModule(reference)) {
|
|
14925
14925
|
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
|
|
14926
14926
|
if (!parentUrlInfo) {
|
|
14927
14927
|
return false;
|
|
14928
14928
|
}
|
|
14929
|
-
const parentGotAsJsClassic = new URL(parentUrlInfo.url).searchParams.has("
|
|
14929
|
+
const parentGotAsJsClassic = new URL(parentUrlInfo.url).searchParams.has("js_module_fallback");
|
|
14930
14930
|
return parentGotAsJsClassic;
|
|
14931
14931
|
}
|
|
14932
14932
|
return false;
|
|
@@ -14937,16 +14937,16 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
14937
14937
|
};
|
|
14938
14938
|
const turnIntoJsClassicProxy = reference => {
|
|
14939
14939
|
const urlTransformed = injectQueryParams(reference.url, {
|
|
14940
|
-
|
|
14940
|
+
js_module_fallback: ""
|
|
14941
14941
|
});
|
|
14942
14942
|
markAsJsClassicProxy(reference);
|
|
14943
14943
|
return urlTransformed;
|
|
14944
14944
|
};
|
|
14945
14945
|
return {
|
|
14946
|
-
name: "jsenv:
|
|
14946
|
+
name: "jsenv:js_module_conversion",
|
|
14947
14947
|
appliesDuring: "*",
|
|
14948
14948
|
redirectUrl: (reference, context) => {
|
|
14949
|
-
if (reference.searchParams.has("
|
|
14949
|
+
if (reference.searchParams.has("js_module_fallback")) {
|
|
14950
14950
|
markAsJsClassicProxy(reference);
|
|
14951
14951
|
return null;
|
|
14952
14952
|
}
|
|
@@ -14956,7 +14956,7 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
14956
14956
|
// (because it's the transpiled equivalent of static and dynamic imports)
|
|
14957
14957
|
// And not other references otherwise we could try to transform inline resources
|
|
14958
14958
|
// or specifiers inside new URL()...
|
|
14959
|
-
if (
|
|
14959
|
+
if (shouldPropagateJsModuleConversion(reference, context)) {
|
|
14960
14960
|
return turnIntoJsClassicProxy(reference);
|
|
14961
14961
|
}
|
|
14962
14962
|
return null;
|
|
@@ -14965,9 +14965,9 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
14965
14965
|
const [jsModuleReference, jsModuleUrlInfo] = context.getWithoutSearchParam({
|
|
14966
14966
|
urlInfo,
|
|
14967
14967
|
context,
|
|
14968
|
-
searchParam: "
|
|
14968
|
+
searchParam: "js_module_fallback",
|
|
14969
14969
|
// override the expectedType to "js_module"
|
|
14970
|
-
// because when there is ?
|
|
14970
|
+
// because when there is ?js_module_fallback it means the underlying resource
|
|
14971
14971
|
// is a js_module
|
|
14972
14972
|
expectedType: "js_module"
|
|
14973
14973
|
});
|
|
@@ -15012,21 +15012,21 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
15012
15012
|
|
|
15013
15013
|
/*
|
|
15014
15014
|
* when <script type="module"> cannot be used:
|
|
15015
|
-
* - ?
|
|
15015
|
+
* - ?js_module_fallback is injected into the src of <script type="module">
|
|
15016
15016
|
* - js inside <script type="module"> is transformed into classic js
|
|
15017
15017
|
* - <link rel="modulepreload"> are converted to <link rel="preload">
|
|
15018
15018
|
*/
|
|
15019
|
-
const
|
|
15019
|
+
const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
15020
15020
|
systemJsInjection,
|
|
15021
15021
|
systemJsClientFileUrl
|
|
15022
15022
|
}) => {
|
|
15023
15023
|
const turnIntoJsClassicProxy = reference => {
|
|
15024
15024
|
return injectQueryParams(reference.url, {
|
|
15025
|
-
|
|
15025
|
+
js_module_fallback: ""
|
|
15026
15026
|
});
|
|
15027
15027
|
};
|
|
15028
15028
|
return {
|
|
15029
|
-
name: "jsenv:
|
|
15029
|
+
name: "jsenv:js_module_fallback_inside_html",
|
|
15030
15030
|
appliesDuring: "*",
|
|
15031
15031
|
redirectUrl: {
|
|
15032
15032
|
link_href: (reference, context) => {
|
|
@@ -15179,7 +15179,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
15179
15179
|
injectScriptNodeAsEarlyAsPossible(htmlAst, createHtmlNode({
|
|
15180
15180
|
tagName: "script",
|
|
15181
15181
|
textContent: systemJsUrlInfo.content
|
|
15182
|
-
}), "jsenv:
|
|
15182
|
+
}), "jsenv:js_module_fallback");
|
|
15183
15183
|
});
|
|
15184
15184
|
}
|
|
15185
15185
|
}
|
|
@@ -15202,7 +15202,7 @@ const isOrWasExpectingJsModule = reference => {
|
|
|
15202
15202
|
return false;
|
|
15203
15203
|
};
|
|
15204
15204
|
const isExpectingJsModule = reference => {
|
|
15205
|
-
return reference.expectedType === "js_module" || reference.searchParams.has("
|
|
15205
|
+
return reference.expectedType === "js_module" || reference.searchParams.has("js_module_fallback") || reference.searchParams.has("as_js_classic");
|
|
15206
15206
|
};
|
|
15207
15207
|
|
|
15208
15208
|
/*
|
|
@@ -15217,7 +15217,7 @@ const isExpectingJsModule = reference => {
|
|
|
15217
15217
|
* transformed into
|
|
15218
15218
|
* new SharedWorker("shared_worker.js?as_js_classic", { type: "classic" })
|
|
15219
15219
|
*/
|
|
15220
|
-
const
|
|
15220
|
+
const jsenvPluginJsModuleFallbackOnWorkers = () => {
|
|
15221
15221
|
const turnIntoJsClassicProxy = reference => {
|
|
15222
15222
|
reference.mutation = magicSource => {
|
|
15223
15223
|
magicSource.replace({
|
|
@@ -15227,11 +15227,11 @@ const jsenvPluginAsJsClassicWorkers = () => {
|
|
|
15227
15227
|
});
|
|
15228
15228
|
};
|
|
15229
15229
|
return injectQueryParams(reference.url, {
|
|
15230
|
-
|
|
15230
|
+
js_module_fallback: ""
|
|
15231
15231
|
});
|
|
15232
15232
|
};
|
|
15233
15233
|
return {
|
|
15234
|
-
name: "jsenv:
|
|
15234
|
+
name: "jsenv:js_module_fallback_on_workers",
|
|
15235
15235
|
appliesDuring: "*",
|
|
15236
15236
|
redirectUrl: {
|
|
15237
15237
|
js_url: (reference, context) => {
|
|
@@ -15262,132 +15262,36 @@ const jsenvPluginAsJsClassicWorkers = () => {
|
|
|
15262
15262
|
};
|
|
15263
15263
|
};
|
|
15264
15264
|
|
|
15265
|
-
const
|
|
15266
|
-
systemJsInjection,
|
|
15267
|
-
systemJsClientFileUrl
|
|
15268
|
-
generateJsClassicFilename
|
|
15269
|
-
}) => {
|
|
15270
|
-
const markAsJsClassicLibraryProxy = reference => {
|
|
15271
|
-
reference.expectedType = "js_classic";
|
|
15272
|
-
reference.filename = generateJsClassicFilename(reference.url);
|
|
15273
|
-
};
|
|
15274
|
-
return {
|
|
15275
|
-
name: "jsenv:as_js_classic_library",
|
|
15276
|
-
appliesDuring: "*",
|
|
15277
|
-
redirectUrl: reference => {
|
|
15278
|
-
if (reference.searchParams.has("as_js_classic_library")) {
|
|
15279
|
-
markAsJsClassicLibraryProxy(reference);
|
|
15280
|
-
}
|
|
15281
|
-
},
|
|
15282
|
-
fetchUrlContent: async (urlInfo, context) => {
|
|
15283
|
-
const [jsModuleReference, jsModuleUrlInfo] = context.getWithoutSearchParam({
|
|
15284
|
-
urlInfo,
|
|
15285
|
-
context,
|
|
15286
|
-
searchParam: "as_js_classic_library",
|
|
15287
|
-
// override the expectedType to "js_module"
|
|
15288
|
-
// because when there is ?as_js_classic_library it means the underlying resource
|
|
15289
|
-
// is a js_module
|
|
15290
|
-
expectedType: "js_module"
|
|
15291
|
-
});
|
|
15292
|
-
if (!jsModuleReference) {
|
|
15293
|
-
return null;
|
|
15294
|
-
}
|
|
15295
|
-
// cook it to get content + dependencies
|
|
15296
|
-
await context.cook(jsModuleUrlInfo, {
|
|
15297
|
-
reference: jsModuleReference
|
|
15298
|
-
});
|
|
15299
|
-
const loader = createUrlGraphLoader(context);
|
|
15300
|
-
loader.loadReferencedUrlInfos(jsModuleUrlInfo, {
|
|
15301
|
-
// we ignore dynamic import to cook lazyly (as browser request the server)
|
|
15302
|
-
// these dynamic imports must inherit "?as_js_classic_library"
|
|
15303
|
-
// This is done inside rollup for convenience
|
|
15304
|
-
ignoreDynamicImport: true
|
|
15305
|
-
});
|
|
15306
|
-
await loader.getAllLoadDonePromise();
|
|
15307
|
-
const bundleUrlInfos = await bundleJsModules({
|
|
15308
|
-
jsModuleUrlInfos: [jsModuleUrlInfo],
|
|
15309
|
-
context: {
|
|
15310
|
-
...context,
|
|
15311
|
-
buildDirectoryUrl: new URL("./", import.meta.url)
|
|
15312
|
-
},
|
|
15313
|
-
preserveDynamicImport: true
|
|
15314
|
-
});
|
|
15315
|
-
const jsModuleBundledUrlInfo = bundleUrlInfos[jsModuleUrlInfo.url];
|
|
15316
|
-
if (context.dev) {
|
|
15317
|
-
jsModuleBundledUrlInfo.sourceUrls.forEach(sourceUrl => {
|
|
15318
|
-
context.referenceUtils.inject({
|
|
15319
|
-
type: "js_url",
|
|
15320
|
-
specifier: sourceUrl,
|
|
15321
|
-
isImplicit: true
|
|
15322
|
-
});
|
|
15323
|
-
});
|
|
15324
|
-
} else if (context.build) {
|
|
15325
|
-
jsModuleBundledUrlInfo.sourceUrls.forEach(sourceUrl => {
|
|
15326
|
-
const sourceUrlInfo = context.urlGraph.getUrlInfo(sourceUrl);
|
|
15327
|
-
if (sourceUrlInfo && sourceUrlInfo.dependents.size === 0) {
|
|
15328
|
-
context.urlGraph.deleteUrlInfo(sourceUrl);
|
|
15329
|
-
}
|
|
15330
|
-
});
|
|
15331
|
-
}
|
|
15332
|
-
const {
|
|
15333
|
-
content,
|
|
15334
|
-
sourcemap
|
|
15335
|
-
} = await convertJsModuleToJsClassic({
|
|
15336
|
-
rootDirectoryUrl: context.rootDirectoryUrl,
|
|
15337
|
-
systemJsInjection,
|
|
15338
|
-
systemJsClientFileUrl,
|
|
15339
|
-
urlInfo,
|
|
15340
|
-
jsModuleUrlInfo: jsModuleBundledUrlInfo
|
|
15341
|
-
});
|
|
15342
|
-
return {
|
|
15343
|
-
content,
|
|
15344
|
-
contentType: "text/javascript",
|
|
15345
|
-
type: "js_classic",
|
|
15346
|
-
originalUrl: urlInfo.originalUrl,
|
|
15347
|
-
originalContent: jsModuleUrlInfo.originalContent,
|
|
15348
|
-
sourcemap,
|
|
15349
|
-
data: jsModuleUrlInfo.data
|
|
15350
|
-
};
|
|
15351
|
-
}
|
|
15352
|
-
};
|
|
15353
|
-
};
|
|
15354
|
-
|
|
15355
|
-
const jsenvPluginAsJsClassic = ({
|
|
15356
|
-
jsClassicLibrary,
|
|
15357
|
-
jsClassicFallback,
|
|
15358
|
-
systemJsInjection
|
|
15265
|
+
const jsenvPluginJsModuleFallback = ({
|
|
15266
|
+
systemJsInjection = true,
|
|
15267
|
+
systemJsClientFileUrl = systemJsClientFileUrlDefault
|
|
15359
15268
|
}) => {
|
|
15360
|
-
|
|
15361
|
-
const generateJsClassicFilename = url => {
|
|
15362
|
-
const filename = urlToFilename$1(url);
|
|
15363
|
-
let [basename, extension] = splitFileExtension(filename);
|
|
15364
|
-
const {
|
|
15365
|
-
searchParams
|
|
15366
|
-
} = new URL(url);
|
|
15367
|
-
if (searchParams.has("as_json_module") || searchParams.has("as_css_module") || searchParams.has("as_text_module")) {
|
|
15368
|
-
extension = ".js";
|
|
15369
|
-
}
|
|
15370
|
-
return `${basename}.nomodule${extension}`;
|
|
15371
|
-
};
|
|
15372
|
-
const splitFileExtension = filename => {
|
|
15373
|
-
const dotLastIndex = filename.lastIndexOf(".");
|
|
15374
|
-
if (dotLastIndex === -1) {
|
|
15375
|
-
return [filename, ""];
|
|
15376
|
-
}
|
|
15377
|
-
return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)];
|
|
15378
|
-
};
|
|
15379
|
-
return [...(jsClassicLibrary ? [jsenvPluginAsJsClassicLibrary({
|
|
15380
|
-
systemJsInjection,
|
|
15381
|
-
systemJsClientFileUrl,
|
|
15382
|
-
generateJsClassicFilename
|
|
15383
|
-
})] : []), ...(jsClassicFallback ? [jsenvPluginAsJsClassicHtml({
|
|
15269
|
+
return [jsenvPluginJsModuleFallbackInsideHtml({
|
|
15384
15270
|
systemJsInjection,
|
|
15385
15271
|
systemJsClientFileUrl
|
|
15386
|
-
}),
|
|
15272
|
+
}), jsenvPluginJsModuleFallbackOnWorkers(), jsenvPluginJsModuleConversion({
|
|
15387
15273
|
systemJsInjection,
|
|
15388
15274
|
systemJsClientFileUrl,
|
|
15389
15275
|
generateJsClassicFilename
|
|
15390
|
-
})]
|
|
15276
|
+
})];
|
|
15277
|
+
};
|
|
15278
|
+
const generateJsClassicFilename = url => {
|
|
15279
|
+
const filename = urlToFilename$1(url);
|
|
15280
|
+
let [basename, extension] = splitFileExtension$2(filename);
|
|
15281
|
+
const {
|
|
15282
|
+
searchParams
|
|
15283
|
+
} = new URL(url);
|
|
15284
|
+
if (searchParams.has("as_json_module") || searchParams.has("as_css_module") || searchParams.has("as_text_module")) {
|
|
15285
|
+
extension = ".js";
|
|
15286
|
+
}
|
|
15287
|
+
return `${basename}.nomodule${extension}`;
|
|
15288
|
+
};
|
|
15289
|
+
const splitFileExtension$2 = filename => {
|
|
15290
|
+
const dotLastIndex = filename.lastIndexOf(".");
|
|
15291
|
+
if (dotLastIndex === -1) {
|
|
15292
|
+
return [filename, ""];
|
|
15293
|
+
}
|
|
15294
|
+
return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)];
|
|
15391
15295
|
};
|
|
15392
15296
|
|
|
15393
15297
|
// duplicated from @jsenv/log to avoid the dependency
|
|
@@ -19953,12 +19857,10 @@ const jsenvPluginImportMetaResolve = () => {
|
|
|
19953
19857
|
const jsenvPluginTranspilation = ({
|
|
19954
19858
|
importAssertions = true,
|
|
19955
19859
|
css = true,
|
|
19956
|
-
|
|
19957
|
-
// build sets jsClassicFallback: false during first step of the build
|
|
19860
|
+
// build sets jsModuleFallbackOnJsClassic: false during first step of the build
|
|
19958
19861
|
// and re-enable it in the second phase (when performing the bundling)
|
|
19959
19862
|
// so that bundling is applied on js modules THEN it is converted to js classic if needed
|
|
19960
|
-
|
|
19961
|
-
systemJsInjection = true,
|
|
19863
|
+
jsModuleFallbackOnJsClassic = true,
|
|
19962
19864
|
topLevelAwait = true,
|
|
19963
19865
|
importMetaResolve = true,
|
|
19964
19866
|
babelHelpersAsImport = true,
|
|
@@ -19967,18 +19869,17 @@ const jsenvPluginTranspilation = ({
|
|
|
19967
19869
|
if (importAssertions === true) {
|
|
19968
19870
|
importAssertions = {};
|
|
19969
19871
|
}
|
|
19872
|
+
if (jsModuleFallbackOnJsClassic === true) {
|
|
19873
|
+
jsModuleFallbackOnJsClassic = {};
|
|
19874
|
+
}
|
|
19970
19875
|
return [...(importMetaResolve ? [jsenvPluginImportMetaResolve()] : []), ...(importAssertions ? [jsenvPluginImportAssertions(importAssertions)] : []),
|
|
19971
19876
|
// babel also so that rollup can bundle babel helpers for instance
|
|
19972
19877
|
jsenvPluginBabel({
|
|
19973
19878
|
topLevelAwait,
|
|
19974
19879
|
getCustomBabelPlugins,
|
|
19975
19880
|
babelHelpersAsImport
|
|
19976
|
-
}),
|
|
19977
|
-
|
|
19978
|
-
jsClassicFallback,
|
|
19979
|
-
systemJsInjection
|
|
19980
|
-
}), jsenvPluginAsJsModule(),
|
|
19981
|
-
// topLevelAwait must come after jsenvPluginAsJsClassic because it's related to the module format
|
|
19881
|
+
}), ...(jsModuleFallbackOnJsClassic ? [jsenvPluginJsModuleFallback(jsModuleFallbackOnJsClassic)] : []), jsenvPluginAsJsModule(),
|
|
19882
|
+
// topLevelAwait must come after jsModuleFallback because it's related to the module format
|
|
19982
19883
|
// so we want to wait to know the module format before transforming things related to top level await
|
|
19983
19884
|
...(topLevelAwait ? [jsenvPluginTopLevelAwait()] : []), ...(css ? [jsenvPluginCssTranspilation()] : [])];
|
|
19984
19885
|
};
|
|
@@ -20771,9 +20672,9 @@ const jsenvPluginRibbon = ({
|
|
|
20771
20672
|
tagName: "script",
|
|
20772
20673
|
type: "module",
|
|
20773
20674
|
textContent: `
|
|
20774
|
-
import { injectRibbon } from "${ribbonClientFileReference.generatedSpecifier}"
|
|
20775
|
-
|
|
20776
|
-
injectRibbon(${paramsJson})
|
|
20675
|
+
import { injectRibbon } from "${ribbonClientFileReference.generatedSpecifier}"
|
|
20676
|
+
|
|
20677
|
+
injectRibbon(${paramsJson})
|
|
20777
20678
|
`
|
|
20778
20679
|
});
|
|
20779
20680
|
injectHtmlNode(htmlAst, scriptNode, "jsenv:ribbon");
|
|
@@ -21350,7 +21251,7 @@ build "${entryPointKeys[0]}"`);
|
|
|
21350
21251
|
logger.info(`
|
|
21351
21252
|
build ${entryPointKeys.length} entry points`);
|
|
21352
21253
|
}
|
|
21353
|
-
const
|
|
21254
|
+
const explicitJsModuleFallback = entryPointKeys.some(key => entryPoints[key].includes("?js_module_fallback"));
|
|
21354
21255
|
const rawRedirections = new Map();
|
|
21355
21256
|
const bundleRedirections = new Map();
|
|
21356
21257
|
const bundleInternalRedirections = new Map();
|
|
@@ -21401,8 +21302,8 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21401
21302
|
directoryReferenceAllowed,
|
|
21402
21303
|
transpilation: {
|
|
21403
21304
|
...transpilation,
|
|
21404
|
-
babelHelpersAsImport: !
|
|
21405
|
-
|
|
21305
|
+
babelHelpersAsImport: !explicitJsModuleFallback,
|
|
21306
|
+
jsModuleFallbackOnJsClassic: false
|
|
21406
21307
|
},
|
|
21407
21308
|
scenarioPlaceholders
|
|
21408
21309
|
})],
|
|
@@ -21440,9 +21341,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21440
21341
|
build: true,
|
|
21441
21342
|
runtimeCompat,
|
|
21442
21343
|
...contextSharedDuringBuild,
|
|
21443
|
-
plugins: [urlAnalysisPlugin, ...(lineBreakNormalization ? [jsenvPluginLineBreakNormalization()] : []),
|
|
21444
|
-
jsClassicLibrary: false,
|
|
21445
|
-
jsClassicFallback: true,
|
|
21344
|
+
plugins: [urlAnalysisPlugin, ...(lineBreakNormalization ? [jsenvPluginLineBreakNormalization()] : []), jsenvPluginJsModuleFallback({
|
|
21446
21345
|
systemJsInjection: true
|
|
21447
21346
|
}), jsenvPluginInline({
|
|
21448
21347
|
fetchInlineUrls: false
|
|
@@ -21506,9 +21405,9 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21506
21405
|
associateBuildUrlAndRawUrl(buildUrl, rawUrlInfo.url, "inline content");
|
|
21507
21406
|
return buildUrl;
|
|
21508
21407
|
}
|
|
21509
|
-
// from "
|
|
21510
|
-
// - injecting "?
|
|
21511
|
-
// - injecting "?
|
|
21408
|
+
// from "js_module_fallback":
|
|
21409
|
+
// - injecting "?js_module_fallback" for the first time
|
|
21410
|
+
// - injecting "?js_module_fallback" because the parentUrl has it
|
|
21512
21411
|
if (reference.original) {
|
|
21513
21412
|
const urlBeforeRedirect = reference.original.url;
|
|
21514
21413
|
const urlAfterRedirect = reference.url;
|
|
@@ -21540,7 +21439,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21540
21439
|
associateBuildUrlAndRawUrl(buildUrl, rawUrl, "redirected during postbuild");
|
|
21541
21440
|
return buildUrl;
|
|
21542
21441
|
}
|
|
21543
|
-
// from "
|
|
21442
|
+
// from "js_module_fallback":
|
|
21544
21443
|
// - to inject "s.js"
|
|
21545
21444
|
if (reference.injected) {
|
|
21546
21445
|
const buildUrl = buildUrlsGenerator.generate(reference.url, {
|
|
@@ -21558,7 +21457,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21558
21457
|
// files from root directory but not given to rollup nor postcss
|
|
21559
21458
|
if (rawUrlInfo) {
|
|
21560
21459
|
const referencedUrlObject = new URL(reference.url);
|
|
21561
|
-
referencedUrlObject.searchParams.delete("
|
|
21460
|
+
referencedUrlObject.searchParams.delete("as_js_classic");
|
|
21562
21461
|
const buildUrl = buildUrlsGenerator.generate(referencedUrlObject.href, {
|
|
21563
21462
|
urlInfo: rawUrlInfo,
|
|
21564
21463
|
parentUrlInfo
|
|
@@ -21600,8 +21499,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21600
21499
|
const generatedUrlObject = new URL(reference.generatedUrl);
|
|
21601
21500
|
generatedUrlObject.searchParams.delete("js_classic");
|
|
21602
21501
|
generatedUrlObject.searchParams.delete("js_module");
|
|
21502
|
+
generatedUrlObject.searchParams.delete("js_module_fallback");
|
|
21603
21503
|
generatedUrlObject.searchParams.delete("as_js_classic");
|
|
21604
|
-
generatedUrlObject.searchParams.delete("as_js_classic_library");
|
|
21605
21504
|
generatedUrlObject.searchParams.delete("as_js_module");
|
|
21606
21505
|
generatedUrlObject.searchParams.delete("as_json_module");
|
|
21607
21506
|
generatedUrlObject.searchParams.delete("as_css_module");
|
|
@@ -21648,7 +21547,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21648
21547
|
reference
|
|
21649
21548
|
} = context;
|
|
21650
21549
|
// reference injected during "postbuild":
|
|
21651
|
-
// - happens for "
|
|
21550
|
+
// - happens for "js_module_fallback" injecting "s.js"
|
|
21652
21551
|
if (reference.injected) {
|
|
21653
21552
|
const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({
|
|
21654
21553
|
...reference,
|
|
@@ -21663,7 +21562,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21663
21562
|
return fromBundleOrRawGraph(reference.url);
|
|
21664
21563
|
}
|
|
21665
21564
|
// reference updated during "postbuild":
|
|
21666
|
-
// - happens for "
|
|
21565
|
+
// - happens for "js_module_fallback"
|
|
21667
21566
|
if (reference.original) {
|
|
21668
21567
|
return fromBundleOrRawGraph(reference.original.url);
|
|
21669
21568
|
}
|
|
@@ -21753,7 +21652,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21753
21652
|
// cleanup unused urls (avoid bundling things that are not actually used)
|
|
21754
21653
|
// happens for:
|
|
21755
21654
|
// - js import assertions
|
|
21756
|
-
// -
|
|
21655
|
+
// - as_js_classic
|
|
21757
21656
|
if (!isUsed(rawUrlInfo)) {
|
|
21758
21657
|
rawGraph.deleteUrlInfo(rawUrlInfo.url);
|
|
21759
21658
|
return;
|
|
@@ -22078,10 +21977,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22078
21977
|
}
|
|
22079
21978
|
versionMap.set(urlInfo.url, version);
|
|
22080
21979
|
const buildUrlObject = new URL(urlInfo.url);
|
|
22081
|
-
// remove ?
|
|
21980
|
+
// remove ?js_module_fallback
|
|
22082
21981
|
// this information is already hold into ".nomodule"
|
|
21982
|
+
buildUrlObject.searchParams.delete("js_module_fallback");
|
|
22083
21983
|
buildUrlObject.searchParams.delete("as_js_classic");
|
|
22084
|
-
buildUrlObject.searchParams.delete("as_js_classic_library");
|
|
22085
21984
|
buildUrlObject.searchParams.delete("as_js_module");
|
|
22086
21985
|
buildUrlObject.searchParams.delete("as_json_module");
|
|
22087
21986
|
buildUrlObject.searchParams.delete("as_css_module");
|
|
@@ -22464,7 +22363,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22464
22363
|
const buildInlineRelativeUrls = [];
|
|
22465
22364
|
const getBuildRelativeUrl = url => {
|
|
22466
22365
|
const urlObject = new URL(url);
|
|
22467
|
-
urlObject.searchParams.delete("
|
|
22366
|
+
urlObject.searchParams.delete("js_module_fallback");
|
|
22468
22367
|
urlObject.searchParams.delete("as_css_module");
|
|
22469
22368
|
urlObject.searchParams.delete("as_json_module");
|
|
22470
22369
|
urlObject.searchParams.delete("as_text_module");
|
|
@@ -23054,7 +22953,7 @@ const createFileService = ({
|
|
|
23054
22953
|
if (code === "PARSE_ERROR") {
|
|
23055
22954
|
// when possible let browser re-throw the syntax error
|
|
23056
22955
|
// it's not possible to do that when url info content is not available
|
|
23057
|
-
// (happens for as_js_classic
|
|
22956
|
+
// (happens for as_js_classic for instance)
|
|
23058
22957
|
if (urlInfo.content !== undefined) {
|
|
23059
22958
|
return {
|
|
23060
22959
|
url: reference.url,
|
|
@@ -23235,20 +23134,12 @@ const startDevServer = async ({
|
|
|
23235
23134
|
port,
|
|
23236
23135
|
requestWaitingMs: 60_000,
|
|
23237
23136
|
services: [{
|
|
23238
|
-
injectResponseHeaders: () => {
|
|
23239
|
-
return {
|
|
23240
|
-
"x-server-name": "jsenv_dev_server"
|
|
23241
|
-
};
|
|
23242
|
-
}
|
|
23243
|
-
}, jsenvServiceCORS({
|
|
23244
|
-
accessControlAllowRequestOrigin: true,
|
|
23245
|
-
accessControlAllowRequestMethod: true,
|
|
23246
|
-
accessControlAllowRequestHeaders: true,
|
|
23247
|
-
accessControlAllowedRequestHeaders: [...jsenvAccessControlAllowedHeaders, "x-jsenv-execution-id"],
|
|
23248
|
-
accessControlAllowCredentials: true,
|
|
23249
|
-
timingAllowOrigin: true
|
|
23250
|
-
}), {
|
|
23251
23137
|
handleRequest: request => {
|
|
23138
|
+
if (request.headers["x-server-inspect"]) {
|
|
23139
|
+
return {
|
|
23140
|
+
status: 200
|
|
23141
|
+
};
|
|
23142
|
+
}
|
|
23252
23143
|
if (request.pathname === "/__params__.json") {
|
|
23253
23144
|
const json = JSON.stringify({
|
|
23254
23145
|
sourceDirectoryUrl
|
|
@@ -23263,8 +23154,20 @@ const startDevServer = async ({
|
|
|
23263
23154
|
};
|
|
23264
23155
|
}
|
|
23265
23156
|
return null;
|
|
23157
|
+
},
|
|
23158
|
+
injectResponseHeaders: () => {
|
|
23159
|
+
return {
|
|
23160
|
+
server: "jsenv_dev_server/1"
|
|
23161
|
+
};
|
|
23266
23162
|
}
|
|
23267
|
-
},
|
|
23163
|
+
}, jsenvServiceCORS({
|
|
23164
|
+
accessControlAllowRequestOrigin: true,
|
|
23165
|
+
accessControlAllowRequestMethod: true,
|
|
23166
|
+
accessControlAllowRequestHeaders: true,
|
|
23167
|
+
accessControlAllowedRequestHeaders: [...jsenvAccessControlAllowedHeaders, "x-jsenv-execution-id"],
|
|
23168
|
+
accessControlAllowCredentials: true,
|
|
23169
|
+
timingAllowOrigin: true
|
|
23170
|
+
}), ...services, {
|
|
23268
23171
|
name: "jsenv:omega_file_service",
|
|
23269
23172
|
handleRequest: createFileService({
|
|
23270
23173
|
signal,
|
|
@@ -23483,9 +23386,13 @@ const assertAndNormalizeWebServer = async webServer => {
|
|
|
23483
23386
|
const {
|
|
23484
23387
|
headers
|
|
23485
23388
|
} = await basicFetch(webServer.origin, {
|
|
23486
|
-
|
|
23389
|
+
method: "GET",
|
|
23390
|
+
rejectUnauthorized: false,
|
|
23391
|
+
headers: {
|
|
23392
|
+
"x-server-inspect": "1"
|
|
23393
|
+
}
|
|
23487
23394
|
});
|
|
23488
|
-
if (headers["
|
|
23395
|
+
if (String(headers["server"]).includes("jsenv_dev_server")) {
|
|
23489
23396
|
webServer.isJsenvDevServer = true;
|
|
23490
23397
|
const {
|
|
23491
23398
|
json
|
|
@@ -24975,7 +24882,7 @@ const executeSteps = async (executionSteps, {
|
|
|
24975
24882
|
}
|
|
24976
24883
|
const isLastExecutionLog = executionIndex === executionSteps.length - 1;
|
|
24977
24884
|
const cancelRemaining = failFast && executionResult.status !== "completed" && counters.done < counters.total;
|
|
24978
|
-
if (isLastExecutionLog) {
|
|
24885
|
+
if (isLastExecutionLog && logger.levels.info) {
|
|
24979
24886
|
executionLog.write("\n");
|
|
24980
24887
|
}
|
|
24981
24888
|
if (cancelRemaining) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "34.1
|
|
3
|
+
"version": "34.2.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"@jsenv/integrity": "0.0.1",
|
|
73
73
|
"@jsenv/log": "3.3.4",
|
|
74
74
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
75
|
-
"@jsenv/plugin-bundling": "2.1.5",
|
|
76
75
|
"@jsenv/server": "15.0.2",
|
|
77
76
|
"@jsenv/sourcemap": "1.0.10",
|
|
78
77
|
"@jsenv/uneval": "1.6.0",
|
|
@@ -106,6 +105,7 @@
|
|
|
106
105
|
"@jsenv/plugin-globals": "./packages/jsenv-plugin-globals/",
|
|
107
106
|
"@jsenv/plugin-minification": "./packages/jsenv-plugin-minification/",
|
|
108
107
|
"@jsenv/plugin-placeholders": "./packages/jsenv-plugin-placeholders/",
|
|
108
|
+
"@jsenv/plugin-as-js-classic": "./packages/jsenv-plugin-as-js-classic/",
|
|
109
109
|
"eslint": "8.38.0",
|
|
110
110
|
"eslint-plugin-html": "7.1.0",
|
|
111
111
|
"eslint-plugin-import": "2.27.5",
|