@jsenv/core 36.1.3 → 36.2.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/js/{global_this.js → global_this_js_classic.js} +3 -3
- package/dist/js/global_this_js_module.js +20 -0
- package/dist/js/inline_content.js +10 -0
- package/dist/jsenv_core.js +7479 -7675
- package/package.json +20 -20
- package/src/build/build.js +4 -4
- package/src/dev/file_service.js +1 -1
- package/src/kitchen/client/inline_content.js +17 -0
- package/src/kitchen/kitchen.js +7 -1
- package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +4 -1
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +4 -1
- package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +4 -1
- package/src/plugins/plugins.js +1 -1
- package/src/kitchen/compat/features_compatibility.js +0 -220
- package/src/kitchen/compat/runtime_compat.js +0 -56
- package/src/plugins/reference_analysis/inline_content.js +0 -7
- package/src/plugins/transpilation/as_js_module/convert_js_classic_to_js_module.js +0 -45
- package/src/plugins/transpilation/as_js_module/jsenv_plugin_as_js_module.js +0 -78
- package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +0 -34
- package/src/plugins/transpilation/babel/global_this/client/global_this.js +0 -25
- package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +0 -52
- package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +0 -173
- package/src/plugins/transpilation/babel/helpers/babel_plugins_compatibility.js +0 -432
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +0 -100
- package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +0 -142
- package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +0 -381
- package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -33
- package/src/plugins/transpilation/babel/regenerator_runtime/client/regenerator_runtime.js +0 -748
- package/src/plugins/transpilation/babel/require_babel_plugin.js +0 -8
- package/src/plugins/transpilation/css/jsenv_plugin_css_transpilation.js +0 -54
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +0 -248
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_conversion.js +0 -119
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback.js +0 -46
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +0 -240
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +0 -62
- package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +0 -48
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +0 -87
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +0 -56
package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
2
|
-
import { injectJsImport } from "@jsenv/ast";
|
|
3
|
-
|
|
4
|
-
export const globalThisClientFileUrl = new URL(
|
|
5
|
-
"./client/global_this.js",
|
|
6
|
-
import.meta.url,
|
|
7
|
-
).href;
|
|
8
|
-
|
|
9
|
-
export const babelPluginGlobalThisAsJsenvImport = (
|
|
10
|
-
babel,
|
|
11
|
-
{ getImportSpecifier },
|
|
12
|
-
) => {
|
|
13
|
-
return {
|
|
14
|
-
name: "global-this-as-jsenv-import",
|
|
15
|
-
visitor: {
|
|
16
|
-
Identifier(path, opts) {
|
|
17
|
-
const { filename } = opts;
|
|
18
|
-
const fileUrl = pathToFileURL(filename).href;
|
|
19
|
-
if (fileUrl === globalThisClientFileUrl) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const { node } = path;
|
|
23
|
-
// we should do this once, tree shaking will remote it but still
|
|
24
|
-
if (node.name === "globalThis") {
|
|
25
|
-
injectJsImport({
|
|
26
|
-
programPath: path.scope.getProgramParent().path,
|
|
27
|
-
from: getImportSpecifier(globalThisClientFileUrl),
|
|
28
|
-
sideEffect: true,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// https://mathiasbynens.be/notes/globalthis
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-redeclare */
|
|
4
|
-
/* global globalThis */
|
|
5
|
-
let globalObject;
|
|
6
|
-
if (typeof globalThis === "object") {
|
|
7
|
-
globalObject = globalThis;
|
|
8
|
-
} else {
|
|
9
|
-
if (this) {
|
|
10
|
-
globalObject = this;
|
|
11
|
-
} else {
|
|
12
|
-
// eslint-disable-next-line no-extend-native
|
|
13
|
-
Object.defineProperty(Object.prototype, "__global__", {
|
|
14
|
-
get() {
|
|
15
|
-
return this;
|
|
16
|
-
},
|
|
17
|
-
configurable: true,
|
|
18
|
-
});
|
|
19
|
-
// eslint-disable-next-line no-undef
|
|
20
|
-
globalObject = __global__;
|
|
21
|
-
delete Object.prototype.__global__;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
globalObject.globalThis = globalObject;
|
|
25
|
-
}
|
package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
2
|
-
import { injectJsImport } from "@jsenv/ast";
|
|
3
|
-
import {
|
|
4
|
-
getBabelHelperFileUrl,
|
|
5
|
-
babelHelperNameFromUrl,
|
|
6
|
-
} from "@jsenv/babel-plugins";
|
|
7
|
-
|
|
8
|
-
// named import approach found here:
|
|
9
|
-
// https://github.com/rollup/rollup-plugin-babel/blob/18e4232a450f320f44c651aa8c495f21c74d59ac/src/helperPlugin.js#L1
|
|
10
|
-
|
|
11
|
-
// for reference this is how it's done to reference
|
|
12
|
-
// a global babel helper object instead of using
|
|
13
|
-
// a named import
|
|
14
|
-
// https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-plugin-external-helpers/src/index.js
|
|
15
|
-
|
|
16
|
-
export const babelPluginBabelHelpersAsJsenvImports = (
|
|
17
|
-
babel,
|
|
18
|
-
{ getImportSpecifier },
|
|
19
|
-
) => {
|
|
20
|
-
return {
|
|
21
|
-
name: "babel-helper-as-jsenv-import",
|
|
22
|
-
pre: (file) => {
|
|
23
|
-
const cachedHelpers = {};
|
|
24
|
-
file.set("helperGenerator", (name) => {
|
|
25
|
-
// the list of possible helpers name
|
|
26
|
-
// https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-helpers/src/helpers.js#L13
|
|
27
|
-
if (!file.availableHelper(name)) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
if (cachedHelpers[name]) {
|
|
31
|
-
return cachedHelpers[name];
|
|
32
|
-
}
|
|
33
|
-
const filePath = file.opts.filename;
|
|
34
|
-
const fileUrl = pathToFileURL(filePath).href;
|
|
35
|
-
if (babelHelperNameFromUrl(fileUrl) === name) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const babelHelperImportSpecifier = getBabelHelperFileUrl(name);
|
|
39
|
-
const helper = injectJsImport({
|
|
40
|
-
programPath: file.path,
|
|
41
|
-
from: getImportSpecifier(babelHelperImportSpecifier),
|
|
42
|
-
nameHint: `_${name}`,
|
|
43
|
-
// disable interop, useless as we work only with js modules
|
|
44
|
-
importedType: "es6",
|
|
45
|
-
// importedInterop: "uncompiled",
|
|
46
|
-
});
|
|
47
|
-
cachedHelpers[name] = helper;
|
|
48
|
-
return helper;
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { getBabelHelperFileUrl } from "@jsenv/babel-plugins";
|
|
2
|
-
import { requireBabelPlugin } from "../require_babel_plugin.js";
|
|
3
|
-
import { babelPluginCompatMap } from "./babel_plugins_compatibility.js";
|
|
4
|
-
|
|
5
|
-
export const getBaseBabelPluginStructure = ({
|
|
6
|
-
url,
|
|
7
|
-
isSupported,
|
|
8
|
-
// isJsModule,
|
|
9
|
-
// getImportSpecifier,
|
|
10
|
-
}) => {
|
|
11
|
-
const isBabelPluginNeeded = (babelPluginName) => {
|
|
12
|
-
return !isSupported(babelPluginCompatMap[babelPluginName]);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const babelPluginStructure = {};
|
|
16
|
-
if (isBabelPluginNeeded("proposal-numeric-separator")) {
|
|
17
|
-
babelPluginStructure["proposal-numeric-separator"] = requireBabelPlugin(
|
|
18
|
-
"@babel/plugin-proposal-numeric-separator",
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
if (isBabelPluginNeeded("proposal-json-strings")) {
|
|
22
|
-
babelPluginStructure["proposal-json-strings"] = requireBabelPlugin(
|
|
23
|
-
"@babel/plugin-proposal-json-strings",
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
if (isBabelPluginNeeded("proposal-object-rest-spread")) {
|
|
27
|
-
babelPluginStructure["proposal-object-rest-spread"] = requireBabelPlugin(
|
|
28
|
-
"@babel/plugin-proposal-object-rest-spread",
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
if (isBabelPluginNeeded("proposal-optional-catch-binding")) {
|
|
32
|
-
babelPluginStructure["proposal-optional-catch-binding"] =
|
|
33
|
-
requireBabelPlugin("@babel/plugin-proposal-optional-catch-binding");
|
|
34
|
-
}
|
|
35
|
-
if (isBabelPluginNeeded("proposal-unicode-property-regex")) {
|
|
36
|
-
babelPluginStructure["proposal-unicode-property-regex"] =
|
|
37
|
-
requireBabelPlugin("@babel/plugin-proposal-unicode-property-regex");
|
|
38
|
-
}
|
|
39
|
-
if (isBabelPluginNeeded("transform-async-to-promises")) {
|
|
40
|
-
babelPluginStructure["transform-async-to-promises"] = [
|
|
41
|
-
requireBabelPlugin("babel-plugin-transform-async-to-promises"),
|
|
42
|
-
{
|
|
43
|
-
topLevelAwait: "ignore", // will be handled by "jsenv:top_level_await" plugin
|
|
44
|
-
externalHelpers: false,
|
|
45
|
-
// enable once https://github.com/rpetrich/babel-plugin-transform-async-to-promises/pull/83
|
|
46
|
-
// externalHelpers: isJsModule,
|
|
47
|
-
// externalHelpersPath: isJsModule ? getImportSpecifier(
|
|
48
|
-
// "babel-plugin-transform-async-to-promises/helpers.mjs",
|
|
49
|
-
// ) : null
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
if (isBabelPluginNeeded("transform-arrow-functions")) {
|
|
54
|
-
babelPluginStructure["transform-arrow-functions"] = requireBabelPlugin(
|
|
55
|
-
"@babel/plugin-transform-arrow-functions",
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
if (isBabelPluginNeeded("transform-block-scoped-functions")) {
|
|
59
|
-
babelPluginStructure["transform-block-scoped-functions"] =
|
|
60
|
-
requireBabelPlugin("@babel/plugin-transform-block-scoped-functions");
|
|
61
|
-
}
|
|
62
|
-
if (isBabelPluginNeeded("transform-block-scoping")) {
|
|
63
|
-
babelPluginStructure["transform-block-scoping"] = requireBabelPlugin(
|
|
64
|
-
"@babel/plugin-transform-block-scoping",
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
if (isBabelPluginNeeded("transform-classes")) {
|
|
68
|
-
babelPluginStructure["transform-classes"] = requireBabelPlugin(
|
|
69
|
-
"@babel/plugin-transform-classes",
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
if (isBabelPluginNeeded("transform-computed-properties")) {
|
|
73
|
-
babelPluginStructure["transform-computed-properties"] = requireBabelPlugin(
|
|
74
|
-
"@babel/plugin-transform-computed-properties",
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
if (isBabelPluginNeeded("transform-destructuring")) {
|
|
78
|
-
babelPluginStructure["transform-destructuring"] = requireBabelPlugin(
|
|
79
|
-
"@babel/plugin-transform-destructuring",
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (isBabelPluginNeeded("transform-dotall-regex")) {
|
|
83
|
-
babelPluginStructure["transform-dotall-regex"] = requireBabelPlugin(
|
|
84
|
-
"@babel/plugin-transform-dotall-regex",
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
if (isBabelPluginNeeded("transform-duplicate-keys")) {
|
|
88
|
-
babelPluginStructure["transform-duplicate-keys"] = requireBabelPlugin(
|
|
89
|
-
"@babel/plugin-transform-duplicate-keys",
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
if (isBabelPluginNeeded("transform-exponentiation-operator")) {
|
|
93
|
-
babelPluginStructure["transform-exponentiation-operator"] =
|
|
94
|
-
requireBabelPlugin("@babel/plugin-transform-exponentiation-operator");
|
|
95
|
-
}
|
|
96
|
-
if (isBabelPluginNeeded("transform-for-of")) {
|
|
97
|
-
babelPluginStructure["transform-for-of"] = requireBabelPlugin(
|
|
98
|
-
"@babel/plugin-transform-for-of",
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
if (isBabelPluginNeeded("transform-function-name")) {
|
|
102
|
-
babelPluginStructure["transform-function-name"] = requireBabelPlugin(
|
|
103
|
-
"@babel/plugin-transform-function-name",
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
if (isBabelPluginNeeded("transform-literals")) {
|
|
107
|
-
babelPluginStructure["transform-literals"] = requireBabelPlugin(
|
|
108
|
-
"@babel/plugin-transform-literals",
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
if (isBabelPluginNeeded("transform-new-target")) {
|
|
112
|
-
babelPluginStructure["transform-new-target"] = requireBabelPlugin(
|
|
113
|
-
"@babel/plugin-transform-new-target",
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
if (isBabelPluginNeeded("transform-object-super")) {
|
|
117
|
-
babelPluginStructure["transform-object-super"] = requireBabelPlugin(
|
|
118
|
-
"@babel/plugin-transform-object-super",
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
if (isBabelPluginNeeded("transform-parameters")) {
|
|
122
|
-
babelPluginStructure["transform-parameters"] = requireBabelPlugin(
|
|
123
|
-
"@babel/plugin-transform-parameters",
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
if (isBabelPluginNeeded("transform-regenerator")) {
|
|
127
|
-
babelPluginStructure["transform-regenerator"] = [
|
|
128
|
-
requireBabelPlugin("@babel/plugin-transform-regenerator"),
|
|
129
|
-
{
|
|
130
|
-
asyncGenerators: true,
|
|
131
|
-
generators: true,
|
|
132
|
-
async: false,
|
|
133
|
-
},
|
|
134
|
-
];
|
|
135
|
-
}
|
|
136
|
-
if (isBabelPluginNeeded("transform-shorthand-properties")) {
|
|
137
|
-
babelPluginStructure["transform-shorthand-properties"] = [
|
|
138
|
-
requireBabelPlugin("@babel/plugin-transform-shorthand-properties"),
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
if (isBabelPluginNeeded("transform-spread")) {
|
|
142
|
-
babelPluginStructure["transform-spread"] = [
|
|
143
|
-
requireBabelPlugin("@babel/plugin-transform-spread"),
|
|
144
|
-
];
|
|
145
|
-
}
|
|
146
|
-
if (isBabelPluginNeeded("transform-sticky-regex")) {
|
|
147
|
-
babelPluginStructure["transform-sticky-regex"] = [
|
|
148
|
-
requireBabelPlugin("@babel/plugin-transform-sticky-regex"),
|
|
149
|
-
];
|
|
150
|
-
}
|
|
151
|
-
if (isBabelPluginNeeded("transform-template-literals")) {
|
|
152
|
-
babelPluginStructure["transform-template-literals"] = [
|
|
153
|
-
requireBabelPlugin("@babel/plugin-transform-template-literals"),
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
if (
|
|
157
|
-
isBabelPluginNeeded("transform-typeof-symbol") &&
|
|
158
|
-
// prevent "typeof" to be injected into itself:
|
|
159
|
-
// - not needed
|
|
160
|
-
// - would create infinite attempt to transform typeof
|
|
161
|
-
url !== getBabelHelperFileUrl("typeof")
|
|
162
|
-
) {
|
|
163
|
-
babelPluginStructure["transform-typeof-symbol"] = [
|
|
164
|
-
requireBabelPlugin("@babel/plugin-transform-typeof-symbol"),
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
if (isBabelPluginNeeded("transform-unicode-regex")) {
|
|
168
|
-
babelPluginStructure["transform-unicode-regex"] = [
|
|
169
|
-
requireBabelPlugin("@babel/plugin-transform-unicode-regex"),
|
|
170
|
-
];
|
|
171
|
-
}
|
|
172
|
-
return babelPluginStructure;
|
|
173
|
-
};
|