@jsenv/core 27.0.0-alpha.84 → 27.0.0-alpha.87
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/html/explorer.html +1 -1
- package/dist/js/controllable_file.mjs +1 -1
- package/dist/js/event_source_client.js +3 -3
- package/dist/js/html_supervisor_installer.js +1 -1
- package/dist/js/s.js +2 -2
- package/dist/js/uneval.js +804 -0
- package/dist/main.js +11910 -1028
- package/dist/s.js +2 -2
- package/dist/s.js.map +1 -1
- package/package.json +17 -13
- package/src/build/build.js +2 -14
- package/src/build/inject_global_version_mappings.js +3 -3
- package/src/build/inject_service_worker_urls.js +1 -1
- package/src/build/resync_ressource_hints.js +17 -18
- package/src/build/version_generator.js +60 -0
- package/src/dev/plugins/explorer/client/explorer.html +1 -1
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +1 -1
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -3
- package/src/omega/kitchen.js +2 -0
- package/src/plugins/autoreload/dev_sse/client/reload.js +6 -3
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +3 -3
- package/src/plugins/bundling/css/bundle_css.js +1 -2
- package/src/plugins/bundling/js_module/bundle_js_module.js +85 -66
- package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +1 -1
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +11 -3
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +62 -74
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +10 -6
- package/src/plugins/import_meta_hot/html_hot_dependencies.js +9 -15
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +1 -2
- package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +1 -1
- package/src/plugins/importmap/jsenv_plugin_importmap.js +24 -25
- package/src/plugins/inject_globals/inject_globals.js +3 -3
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +39 -41
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +1 -1
- package/src/plugins/minification/css/minify_css.js +1 -1
- package/src/plugins/transpilation/as_js_classic/client/s.js +2 -2
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +2 -2
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +41 -63
- package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +2 -3
- package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +2 -2
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +1 -1
- package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +2 -2
- package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +2 -2
- package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +1 -1
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +1 -1
- package/src/plugins/url_analysis/css/css_urls.js +1 -2
- package/src/plugins/url_analysis/html/html_urls.js +98 -113
- package/src/plugins/url_analysis/js/js_urls.js +1 -1
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +13 -6
- package/src/test/coverage/empty_coverage_factory.js +1 -1
|
@@ -2,13 +2,14 @@ import { generateInlineContentUrl } from "@jsenv/urls"
|
|
|
2
2
|
import {
|
|
3
3
|
parseHtmlString,
|
|
4
4
|
stringifyHtmlAst,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
visitHtmlNodes,
|
|
6
|
+
getHtmlNodeText,
|
|
7
|
+
getHtmlNodePosition,
|
|
8
|
+
analyzeScriptNode,
|
|
9
|
+
setHtmlNodeAttributes,
|
|
10
|
+
setHtmlNodeText,
|
|
11
|
+
getHtmlNodeAttribute,
|
|
12
|
+
} from "@jsenv/ast"
|
|
12
13
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
|
|
13
14
|
|
|
14
15
|
export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
@@ -20,16 +21,13 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
20
21
|
const htmlAst = parseHtmlString(urlInfo.content)
|
|
21
22
|
const actions = []
|
|
22
23
|
const handleInlineStyle = (node) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const textNode = getHtmlNodeTextNode(node)
|
|
27
|
-
if (!textNode) {
|
|
24
|
+
const htmlNodeText = getHtmlNodeText(node)
|
|
25
|
+
if (!htmlNodeText) {
|
|
28
26
|
return
|
|
29
27
|
}
|
|
30
28
|
actions.push(async () => {
|
|
31
29
|
const { line, column, lineEnd, columnEnd, isOriginal } =
|
|
32
|
-
|
|
30
|
+
getHtmlNodePosition(node, {
|
|
33
31
|
preferOriginal: true,
|
|
34
32
|
})
|
|
35
33
|
const inlineStyleUrl = generateInlineContentUrl({
|
|
@@ -52,43 +50,39 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
52
50
|
specifierColumn: column,
|
|
53
51
|
specifier: inlineStyleUrl,
|
|
54
52
|
contentType: "text/css",
|
|
55
|
-
content:
|
|
53
|
+
content: htmlNodeText,
|
|
56
54
|
})
|
|
57
55
|
await context.cook(inlineStyleUrlInfo, {
|
|
58
56
|
reference: inlineStyleReference,
|
|
59
57
|
})
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
setHtmlNodeText(node, inlineStyleUrlInfo.content)
|
|
59
|
+
setHtmlNodeAttributes(node, {
|
|
60
|
+
"generated-by": "jsenv:html_inline_content",
|
|
63
61
|
})
|
|
64
62
|
})
|
|
65
63
|
}
|
|
66
64
|
const handleInlineScript = (node) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
const textNode = getHtmlNodeTextNode(node)
|
|
71
|
-
if (!textNode) {
|
|
65
|
+
const htmlNodeText = getHtmlNodeText(node)
|
|
66
|
+
if (!htmlNodeText) {
|
|
72
67
|
return
|
|
73
68
|
}
|
|
74
69
|
// If the inline script was already handled by an other plugin, ignore it
|
|
75
70
|
// - we want to preserve inline scripts generated by html supervisor during dev
|
|
76
71
|
// - we want to avoid cooking twice a script during build
|
|
77
|
-
const generatedBy =
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
72
|
+
const generatedBy = getHtmlNodeAttribute(node, "generated-by")
|
|
73
|
+
if (
|
|
74
|
+
generatedBy === "jsenv:as_js_classic_html" &&
|
|
75
|
+
!analyzeConvertedScripts
|
|
76
|
+
) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
if (generatedBy === "jsenv:html_supervisor") {
|
|
80
|
+
return
|
|
87
81
|
}
|
|
88
82
|
actions.push(async () => {
|
|
89
|
-
const scriptCategory =
|
|
83
|
+
const scriptCategory = analyzeScriptNode(node)
|
|
90
84
|
const { line, column, lineEnd, columnEnd, isOriginal } =
|
|
91
|
-
|
|
85
|
+
getHtmlNodePosition(node, {
|
|
92
86
|
preferOriginal: true,
|
|
93
87
|
})
|
|
94
88
|
// from MDN about [type] attribute:
|
|
@@ -131,21 +125,25 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
131
125
|
isOriginalPosition: isOriginal,
|
|
132
126
|
specifier: inlineScriptUrl,
|
|
133
127
|
contentType,
|
|
134
|
-
content:
|
|
128
|
+
content: htmlNodeText,
|
|
135
129
|
})
|
|
136
130
|
|
|
137
131
|
await context.cook(inlineScriptUrlInfo, {
|
|
138
132
|
reference: inlineScriptReference,
|
|
139
133
|
})
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
setHtmlNodeText(node, inlineScriptUrlInfo.content)
|
|
135
|
+
setHtmlNodeAttributes(node, {
|
|
136
|
+
"generated-by": "jsenv:html_inline_content",
|
|
143
137
|
})
|
|
144
138
|
})
|
|
145
139
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
visitHtmlNodes(htmlAst, {
|
|
141
|
+
style: (node) => {
|
|
142
|
+
handleInlineStyle(node)
|
|
143
|
+
},
|
|
144
|
+
script: (node) => {
|
|
145
|
+
handleInlineScript(node)
|
|
146
|
+
},
|
|
149
147
|
})
|
|
150
148
|
if (actions.length === 0) {
|
|
151
149
|
return null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
2
2
|
import { createMagicSource } from "@jsenv/sourcemap"
|
|
3
|
+
import { applyBabelPlugins } from "@jsenv/ast"
|
|
3
4
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
|
|
4
5
|
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js"
|
|
5
|
-
import { applyBabelPlugins } from "@jsenv/utils/src/js_ast/apply_babel_plugins.js"
|
|
6
6
|
|
|
7
7
|
export const jsenvPluginJsInlineContent = ({ allowEscapeForVersioning }) => {
|
|
8
8
|
const parseAndTransformInlineContentCalls = async (urlInfo, context) => {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
}
|
|
44
44
|
System.register = (deps, declare) => {
|
|
45
45
|
if (!document.currentScript) {
|
|
46
|
-
throw new Error("unexpected call")
|
|
46
|
+
throw new Error("unexpected call to System.register (document.currentScript is undefined)")
|
|
47
47
|
}
|
|
48
48
|
if (document.currentScript.__s__) {
|
|
49
49
|
registerRegistry[document.currentScript.src] = [deps, declare]
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
|
|
170
170
|
System.register = async (deps, declare) => {
|
|
171
171
|
System.register = () => {
|
|
172
|
-
throw new Error("unexpected call")
|
|
172
|
+
throw new Error("unexpected call to System.register (called outside url instantiation)")
|
|
173
173
|
}
|
|
174
174
|
const url = self.location.href
|
|
175
175
|
registerRegistry[url] = [deps, declare]
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
15
15
|
import { readFileSync } from "@jsenv/filesystem"
|
|
16
16
|
import { createMagicSource, composeTwoSourcemaps } from "@jsenv/sourcemap"
|
|
17
|
-
import {
|
|
18
|
-
import { applyBabelPlugins } from "@jsenv/utils/src/js_ast/apply_babel_plugins.js"
|
|
17
|
+
import { applyBabelPlugins } from "@jsenv/ast"
|
|
19
18
|
|
|
19
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
20
20
|
import { requireBabelPlugin } from "../babel/require_babel_plugin.js"
|
|
21
21
|
import { babelPluginTransformImportMetaUrl } from "./helpers/babel_plugin_transform_import_meta_url.js"
|
|
22
22
|
import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_as_js_classic_html.js"
|
|
@@ -3,18 +3,17 @@ import {
|
|
|
3
3
|
injectQueryParamsIntoSpecifier,
|
|
4
4
|
} from "@jsenv/urls"
|
|
5
5
|
import {
|
|
6
|
-
getHtmlNodeAttributeByName,
|
|
7
|
-
getHtmlNodeTextNode,
|
|
8
6
|
parseHtmlString,
|
|
9
|
-
|
|
10
|
-
assignHtmlNodeAttributes,
|
|
7
|
+
visitHtmlNodes,
|
|
11
8
|
stringifyHtmlAst,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
getHtmlNodeAttribute,
|
|
10
|
+
getHtmlNodeText,
|
|
11
|
+
getHtmlNodePosition,
|
|
12
|
+
setHtmlNodeAttributes,
|
|
13
|
+
setHtmlNodeText,
|
|
14
|
+
injectScriptNodeAsEarlyAsPossible,
|
|
16
15
|
createHtmlNode,
|
|
17
|
-
} from "@jsenv/
|
|
16
|
+
} from "@jsenv/ast"
|
|
18
17
|
|
|
19
18
|
export const jsenvPluginAsJsClassicHtml = ({
|
|
20
19
|
systemJsInjection,
|
|
@@ -35,18 +34,13 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
35
34
|
const moduleScriptNodes = []
|
|
36
35
|
const classicScriptNodes = []
|
|
37
36
|
const visitLinkNodes = (node) => {
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
const relAttribute = getHtmlNodeAttributeByName(node, "rel")
|
|
42
|
-
const rel = relAttribute ? relAttribute.value : undefined
|
|
37
|
+
const rel = getHtmlNodeAttribute(node, "rel")
|
|
43
38
|
if (rel === "modulepreload") {
|
|
44
39
|
modulePreloadNodes.push(node)
|
|
45
40
|
return
|
|
46
41
|
}
|
|
47
42
|
if (rel === "preload") {
|
|
48
|
-
const
|
|
49
|
-
const asValue = asAttribute ? asAttribute.value : undefined
|
|
43
|
+
const asValue = getHtmlNodeAttribute(node, "as")
|
|
50
44
|
if (asValue === "script") {
|
|
51
45
|
preloadAsScriptNodes.push(node)
|
|
52
46
|
}
|
|
@@ -54,11 +48,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
50
|
const visitScriptNodes = (node) => {
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
const typeAttribute = getHtmlNodeAttributeByName(node, "type")
|
|
61
|
-
const type = typeAttribute ? typeAttribute.value : undefined
|
|
51
|
+
const type = getHtmlNodeAttribute(node, "type")
|
|
62
52
|
if (type === "module") {
|
|
63
53
|
moduleScriptNodes.push(node)
|
|
64
54
|
return
|
|
@@ -68,9 +58,13 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
68
58
|
return
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
visitHtmlNodes(htmlAst, {
|
|
62
|
+
link: (node) => {
|
|
63
|
+
visitLinkNodes(node)
|
|
64
|
+
},
|
|
65
|
+
script: (node) => {
|
|
66
|
+
visitScriptNodes(node)
|
|
67
|
+
},
|
|
74
68
|
})
|
|
75
69
|
|
|
76
70
|
const actions = []
|
|
@@ -113,15 +107,11 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
classicScriptNodes.forEach((classicScriptNode) => {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
"src",
|
|
119
|
-
)
|
|
120
|
-
if (srcAttribute) {
|
|
110
|
+
const src = getHtmlNodeAttribute(classicScriptNode, "src")
|
|
111
|
+
if (src !== undefined) {
|
|
121
112
|
const reference = urlInfo.references.find(
|
|
122
113
|
(ref) =>
|
|
123
|
-
ref.generatedSpecifier ===
|
|
124
|
-
ref.type === "script_src",
|
|
114
|
+
ref.generatedSpecifier === src && ref.type === "script_src",
|
|
125
115
|
)
|
|
126
116
|
const urlObject = new URL(reference.url)
|
|
127
117
|
if (urlObject.searchParams.has("as_js_classic")) {
|
|
@@ -138,14 +128,11 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
138
128
|
}
|
|
139
129
|
})
|
|
140
130
|
moduleScriptNodes.forEach((moduleScriptNode) => {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
"src",
|
|
144
|
-
)
|
|
145
|
-
if (srcAttribute) {
|
|
131
|
+
const src = getHtmlNodeAttribute(moduleScriptNode, "src")
|
|
132
|
+
if (src !== undefined) {
|
|
146
133
|
const reference = urlInfo.references.find(
|
|
147
134
|
(ref) =>
|
|
148
|
-
ref.generatedSpecifier ===
|
|
135
|
+
ref.generatedSpecifier === src &&
|
|
149
136
|
ref.type === "script_src" &&
|
|
150
137
|
ref.expectedType === "js_module",
|
|
151
138
|
)
|
|
@@ -158,17 +145,19 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
158
145
|
cookIt: true,
|
|
159
146
|
},
|
|
160
147
|
)
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
setHtmlNodeAttributes(moduleScriptNode, {
|
|
149
|
+
type: undefined,
|
|
150
|
+
src: newReference.generatedSpecifier,
|
|
151
|
+
})
|
|
163
152
|
})
|
|
164
153
|
}
|
|
165
154
|
return
|
|
166
155
|
}
|
|
167
156
|
if (shouldTransformScriptTypeModule) {
|
|
168
|
-
const
|
|
157
|
+
const htmlNodeText = getHtmlNodeText(moduleScriptNode)
|
|
169
158
|
actions.push(async () => {
|
|
170
159
|
const { line, column, lineEnd, columnEnd, isOriginal } =
|
|
171
|
-
|
|
160
|
+
getHtmlNodePosition(moduleScriptNode, {
|
|
172
161
|
preferOriginal: true,
|
|
173
162
|
})
|
|
174
163
|
let inlineScriptUrl = generateInlineContentUrl({
|
|
@@ -191,27 +180,23 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
191
180
|
specifierColumn: column,
|
|
192
181
|
specifier: inlineScriptUrl,
|
|
193
182
|
contentType: "text/javascript",
|
|
194
|
-
content:
|
|
183
|
+
content: htmlNodeText,
|
|
195
184
|
})
|
|
196
185
|
const [, newUrlInfo] = await getReferenceAsJsClassic(
|
|
197
186
|
inlineReference,
|
|
198
187
|
{ cookIt: true },
|
|
199
188
|
)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
setHtmlNodeText(moduleScriptNode, newUrlInfo.content)
|
|
190
|
+
setHtmlNodeAttributes(moduleScriptNode, {
|
|
191
|
+
"type": undefined,
|
|
192
|
+
"generated-by": "jsenv:as_js_classic_html",
|
|
204
193
|
})
|
|
205
194
|
})
|
|
206
195
|
}
|
|
207
196
|
})
|
|
208
197
|
if (shouldTransformScriptTypeModule) {
|
|
209
198
|
preloadAsScriptNodes.forEach((preloadAsScriptNode) => {
|
|
210
|
-
const
|
|
211
|
-
preloadAsScriptNode,
|
|
212
|
-
"href",
|
|
213
|
-
)
|
|
214
|
-
const href = hrefAttribute.value
|
|
199
|
+
const href = getHtmlNodeAttribute(preloadAsScriptNode, "href")
|
|
215
200
|
const reference = urlInfo.references.find(
|
|
216
201
|
(ref) =>
|
|
217
202
|
ref.generatedSpecifier === href &&
|
|
@@ -233,22 +218,15 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
233
218
|
// but it's unlikely to happen and people should use "modulepreload" in that case anyway
|
|
234
219
|
;[newReference] = await getReferenceAsJsClassic(reference)
|
|
235
220
|
}
|
|
236
|
-
|
|
221
|
+
setHtmlNodeAttributes(preloadAsScriptNode, {
|
|
237
222
|
href: newReference.generatedSpecifier,
|
|
223
|
+
crossorigin: undefined,
|
|
238
224
|
})
|
|
239
|
-
removeHtmlNodeAttributeByName(
|
|
240
|
-
preloadAsScriptNode,
|
|
241
|
-
"crossorigin",
|
|
242
|
-
)
|
|
243
225
|
})
|
|
244
226
|
}
|
|
245
227
|
})
|
|
246
228
|
modulePreloadNodes.forEach((modulePreloadNode) => {
|
|
247
|
-
const
|
|
248
|
-
modulePreloadNode,
|
|
249
|
-
"href",
|
|
250
|
-
)
|
|
251
|
-
const href = hrefAttribute.value
|
|
229
|
+
const href = getHtmlNodeAttribute(modulePreloadNode, "href")
|
|
252
230
|
const reference = urlInfo.references.find(
|
|
253
231
|
(ref) =>
|
|
254
232
|
ref.generatedSpecifier === href &&
|
|
@@ -262,7 +240,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
262
240
|
} else {
|
|
263
241
|
;[newReference] = await getReferenceAsJsClassic(reference)
|
|
264
242
|
}
|
|
265
|
-
|
|
243
|
+
setHtmlNodeAttributes(modulePreloadNode, {
|
|
266
244
|
rel: "preload",
|
|
267
245
|
as: "script",
|
|
268
246
|
href: newReference.generatedSpecifier,
|
|
@@ -287,7 +265,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
287
265
|
expectedType: "js_classic",
|
|
288
266
|
specifier: systemJsClientFileUrl,
|
|
289
267
|
})
|
|
290
|
-
|
|
268
|
+
injectScriptNodeAsEarlyAsPossible(
|
|
291
269
|
htmlAst,
|
|
292
270
|
createHtmlNode({
|
|
293
271
|
"tagName": "script",
|
package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
|
|
3
|
-
import { injectImport } from "@jsenv/utils/src/js_ast/babel_utils.js"
|
|
2
|
+
import { injectJsImport } from "@jsenv/ast"
|
|
4
3
|
|
|
5
4
|
export const babelPluginGlobalThisAsJsenvImport = (
|
|
6
5
|
babel,
|
|
@@ -23,7 +22,7 @@ export const babelPluginGlobalThisAsJsenvImport = (
|
|
|
23
22
|
const { node } = path
|
|
24
23
|
// we should do this once, tree shaking will remote it but still
|
|
25
24
|
if (node.name === "globalThis") {
|
|
26
|
-
|
|
25
|
+
injectJsImport({
|
|
27
26
|
programPath: path.scope.getProgramParent().path,
|
|
28
27
|
from: getImportSpecifier(globalThisClientFileUrl),
|
|
29
28
|
sideEffect: true,
|
package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
import {
|
|
2
|
+
import { injectJsImport } from "@jsenv/ast"
|
|
3
3
|
import {
|
|
4
4
|
getBabelHelperFileUrl,
|
|
5
5
|
babelHelperNameFromUrl,
|
|
@@ -36,7 +36,7 @@ export const babelPluginBabelHelpersAsJsenvImports = (
|
|
|
36
36
|
return undefined
|
|
37
37
|
}
|
|
38
38
|
const babelHelperImportSpecifier = getBabelHelperFileUrl(name)
|
|
39
|
-
const helper =
|
|
39
|
+
const helper = injectJsImport({
|
|
40
40
|
programPath: file.path,
|
|
41
41
|
from: getImportSpecifier(babelHelperImportSpecifier),
|
|
42
42
|
nameHint: `_${name}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyBabelPlugins } from "@jsenv/
|
|
1
|
+
import { applyBabelPlugins } from "@jsenv/ast"
|
|
2
2
|
|
|
3
3
|
import { RUNTIME_COMPAT } from "@jsenv/core/src/omega/compat/runtime_compat.js"
|
|
4
4
|
import { getBaseBabelPluginStructure } from "./helpers/babel_plugin_structure.js"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
import {
|
|
2
|
+
import { injectJsImport } from "@jsenv/ast"
|
|
3
3
|
|
|
4
4
|
export const babelPluginNewStylesheetAsJsenvImport = (
|
|
5
5
|
babel,
|
|
@@ -84,7 +84,7 @@ export const babelPluginNewStylesheetAsJsenvImport = (
|
|
|
84
84
|
},
|
|
85
85
|
})
|
|
86
86
|
if (usesNewStylesheet) {
|
|
87
|
-
|
|
87
|
+
injectJsImport({
|
|
88
88
|
programPath,
|
|
89
89
|
from: getImportSpecifier(newStylesheetClientFileUrl),
|
|
90
90
|
sideEffect: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
import {
|
|
2
|
+
import { injectJsImport } from "@jsenv/ast"
|
|
3
3
|
|
|
4
4
|
export const babelPluginRegeneratorRuntimeAsJsenvImport = (
|
|
5
5
|
babel,
|
|
@@ -21,7 +21,7 @@ export const babelPluginRegeneratorRuntimeAsJsenvImport = (
|
|
|
21
21
|
}
|
|
22
22
|
const { node } = path
|
|
23
23
|
if (node.name === "regeneratorRuntime") {
|
|
24
|
-
|
|
24
|
+
injectJsImport({
|
|
25
25
|
programPath: path.scope.getProgramParent().path,
|
|
26
26
|
from: getImportSpecifier(regeneratorRuntimeClientFileUrl),
|
|
27
27
|
sideEffect: true,
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { createMagicSource } from "@jsenv/sourcemap"
|
|
6
|
-
import { applyPostCss } from "@jsenv/
|
|
7
|
-
import { postCssPluginUrlVisitor } from "@jsenv/utils/src/css_ast/postcss_plugin_url_visitor.js"
|
|
6
|
+
import { applyPostCss, postCssPluginUrlVisitor } from "@jsenv/ast"
|
|
8
7
|
|
|
9
8
|
export const parseAndTransformCssUrls = async (urlInfo, context) => {
|
|
10
9
|
const actions = []
|