@jsenv/js-module-fallback 1.1.0 → 1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/js-module-fallback",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"/dist/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/parser": "7.22.
|
|
29
|
+
"@babel/parser": "7.22.7",
|
|
30
30
|
"@babel/plugin-proposal-dynamic-import": "7.18.6",
|
|
31
31
|
"@babel/plugin-transform-modules-umd": "7.22.5",
|
|
32
32
|
"@babel/plugin-transform-modules-systemjs": "7.22.5",
|
|
33
33
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
34
|
-
"@jsenv/ast": "
|
|
35
|
-
"@jsenv/sourcemap": "1.0
|
|
36
|
-
"@jsenv/urls": "2.
|
|
34
|
+
"@jsenv/ast": "5.0.1",
|
|
35
|
+
"@jsenv/sourcemap": "1.1.0",
|
|
36
|
+
"@jsenv/urls": "2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html"
|
|
@@ -29,7 +29,7 @@ export const convertJsModuleToJsClassic = async ({
|
|
|
29
29
|
// proposal-dynamic-import required with systemjs for babel8:
|
|
30
30
|
// https://github.com/babel/babel/issues/10746
|
|
31
31
|
require("@babel/plugin-proposal-dynamic-import"),
|
|
32
|
-
[babelPluginRelativeImports, { rootUrl:
|
|
32
|
+
[babelPluginRelativeImports, { rootUrl: outputUrl }],
|
|
33
33
|
require("@babel/plugin-transform-modules-systemjs"),
|
|
34
34
|
[
|
|
35
35
|
customAsyncToPromises,
|
|
@@ -49,7 +49,7 @@ export const convertJsModuleToJsClassic = async ({
|
|
|
49
49
|
],
|
|
50
50
|
babelPluginTransformImportMetaUrl,
|
|
51
51
|
babelPluginTransformImportMetaResolve,
|
|
52
|
-
[babelPluginRelativeImports, { rootUrl:
|
|
52
|
+
[babelPluginRelativeImports, { rootUrl: outputUrl }],
|
|
53
53
|
require("@babel/plugin-transform-modules-umd"),
|
|
54
54
|
]),
|
|
55
55
|
],
|
|
@@ -83,7 +83,15 @@ const babelPluginRelativeImports = (babel) => {
|
|
|
83
83
|
const { searchParams } = specifierUrlObject;
|
|
84
84
|
searchParams.delete("dynamic_import");
|
|
85
85
|
specifier = specifierUrlObject.href;
|
|
86
|
-
const
|
|
86
|
+
const rootUrl = state.opts.rootUrl;
|
|
87
|
+
let specifierRelative = urlToRelativeUrl(specifier, rootUrl);
|
|
88
|
+
if (
|
|
89
|
+
!specifierRelative.startsWith("file://") &&
|
|
90
|
+
specifierRelative[0] !== "."
|
|
91
|
+
) {
|
|
92
|
+
// so avoid applying node module resolution or importmap
|
|
93
|
+
specifierRelative = `./${specifierRelative}`;
|
|
94
|
+
}
|
|
87
95
|
path.replaceWith(t.stringLiteral(specifierRelative));
|
|
88
96
|
}
|
|
89
97
|
};
|