@jsenv/core 24.6.4 → 25.0.0-alpha.2
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/browser_runtime/asset-manifest.json +2 -1
- package/dist/browser_runtime/{browser_runtime-bb0e3aa4.js → browser_runtime_91c5a3b8.js} +137 -26
- package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +1089 -0
- package/dist/build_manifest.js +6 -6
- package/dist/compile_proxy/asset-manifest.json +2 -1
- package/dist/compile_proxy/{compile_proxy-6eb67db4.html → compile_proxy_7ad5faa6.html} +119 -26
- package/dist/compile_proxy/{compile_proxy.html__inline__20-9e168143.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +6 -6
- package/dist/event_source_client/asset-manifest.json +2 -1
- package/dist/event_source_client/{event_source_client-9f14c8b9.js → event_source_client_80644aee.js} +2 -2
- package/dist/event_source_client/{event_source_client-9f14c8b9.js.map → event_source_client_80644aee.js.map} +4 -3
- package/dist/redirector/asset-manifest.json +2 -1
- package/dist/redirector/{redirector.html__inline__15-3a34a156.js.map → redirector_e3b0c442_e391410e.js.map} +6 -6
- package/dist/redirector/{redirector-b6ad84bf.html → redirector_eb92e8a7.html} +119 -26
- package/dist/toolbar/asset-manifest.json +11 -10
- package/dist/toolbar/assets/{compilation.css-209d68b4.map → compilation.css_e37c747b.map} +1 -1
- package/dist/toolbar/assets/{eventsource.css-38cd0a36.map → eventsource.css_c0c71e7b.map} +1 -1
- package/dist/toolbar/assets/{execution.css-0ebe522f.map → execution.css_f3377c10.map} +1 -1
- package/dist/toolbar/assets/{focus.css-3f9c156d.map → focus.css_896f3e45.map} +1 -1
- package/dist/toolbar/assets/{light-theme.css-78b19a80.map → light-theme.css_72a60fa3.map} +1 -1
- package/dist/toolbar/assets/{overflow-menu.css-d9688a1c.map → overflow-menu.css_2859d519.map} +1 -1
- package/dist/toolbar/assets/{settings.css-2b81b245.map → settings.css_61548139.map} +1 -1
- package/dist/toolbar/assets/{toolbar.main.css-846920e9.map → toolbar.main.css_269d7ce2.map} +9 -9
- package/dist/toolbar/assets/{tooltip.css-03395ee6.map → tooltip.css_a94a8bdd.map} +1 -1
- package/dist/toolbar/{toolbar.main-a5ef2c60.js.map → toolbar.main2_6c1b3d82.js.map} +8 -8
- package/dist/toolbar/{toolbar-1fbf8dcb.html → toolbar_04ba410c.html} +129 -36
- package/dist/toolbar_injector/asset-manifest.json +3 -2
- package/dist/toolbar_injector/assets/{jsenv-logo-188b9ca6.svg → jsenv-logo_188b9ca6.svg} +0 -0
- package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js → toolbar_injector_4a48bc53.js} +3 -3
- package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js.map → toolbar_injector_4a48bc53.js.map} +2 -2
- package/package.json +5 -4
- package/readme.md +24 -91
- package/src/buildProject.js +42 -27
- package/src/dev_server.js +8 -2
- package/src/execute.js +7 -1
- package/src/executeTestPlan.js +17 -0
- package/src/internal/browser_feature_detection/browser_feature_detection.js +18 -25
- package/src/internal/browser_runtime/browser_runtime.js +2 -2
- package/src/internal/browser_runtime/createBrowserRuntime.js +1 -1
- package/src/internal/browser_runtime/displayErrorInDocument.js +2 -0
- package/src/internal/browser_runtime/displayErrorNotification.js +1 -1
- package/src/internal/building/buildUsingRollup.js +12 -15
- package/src/internal/building/build_logs.js +2 -2
- package/src/internal/building/build_stats.js +11 -1
- package/src/internal/building/html/parseHtmlRessource.js +2 -26
- package/src/internal/building/js/parseJsRessource.js +3 -2
- package/src/internal/building/json_module.js +11 -0
- package/src/internal/building/parseRessource.js +1 -1
- package/src/internal/building/ressource_builder.js +210 -216
- package/src/internal/building/rollup_plugin_jsenv.js +530 -365
- package/src/internal/building/url_loader.js +8 -145
- package/src/internal/building/url_versioning.js +220 -0
- package/src/internal/compiling/compileHtml.js +8 -1
- package/src/internal/compiling/createCompiledFileService.js +28 -40
- package/src/internal/compiling/html_source_file_service.js +66 -51
- package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +23 -0
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -12
- package/src/internal/compiling/js-compilation-service/transformJs.js +2 -0
- package/src/internal/compiling/jsenvCompilerForHtml.js +43 -44
- package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +9 -0
- package/src/internal/compiling/startCompileServer.js +29 -5
- package/src/internal/dev_server/event_source_client/livereload_preference.js +1 -1
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -9
- package/src/internal/executing/executePlan.js +6 -0
- package/src/internal/generateGroupMap/{jsenvBabelPluginCompatMap.js → babel_plugins_compatibility.js} +0 -0
- package/src/internal/generateGroupMap/{featuresCompatMap.js → features_compatibility.js} +9 -1
- package/src/internal/generateGroupMap/generateGroupMap.js +6 -35
- package/src/internal/generateGroupMap/one_runtime_compat.js +9 -12
- package/src/internal/generateGroupMap/runtime_compat.js +10 -15
- package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -2
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +21 -0
- package/src/internal/import-resolution/importmap_default.js +52 -0
- package/src/internal/node_feature_detection/node_feature_detection.js +25 -19
- package/src/internal/runtime/s.js +101 -6
- package/src/internal/unevalException.js +1 -1
- package/src/jsenvServiceWorkerFinalizer.js +10 -9
- package/dist/browser_runtime/browser_runtime-bb0e3aa4.js.map +0 -1067
- package/src/internal/building/asset_url_versioning.js +0 -50
- package/src/internal/building/rollup_build_sourcemap.js +0 -54
- package/src/internal/building/url-versioning.js +0 -96
- package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
- package/src/internal/import-resolution/importmap-default.js +0 -34
- package/src/internal/renderNamePattern.js +0 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs"
|
|
2
|
+
|
|
3
|
+
import { jsenvCoreDirectoryUrl } from "@jsenv/core/src/internal/jsenvCoreDirectoryUrl.js"
|
|
4
|
+
|
|
5
|
+
export const babelPluginSystemJsPrepend = (api) => {
|
|
6
|
+
api.assertVersion(7)
|
|
7
|
+
const systemJsUrl = new URL(
|
|
8
|
+
"src/internal/runtime/s.js",
|
|
9
|
+
jsenvCoreDirectoryUrl,
|
|
10
|
+
)
|
|
11
|
+
return {
|
|
12
|
+
name: "systemjs-prepend",
|
|
13
|
+
visitor: {
|
|
14
|
+
Program: {
|
|
15
|
+
exit(path) {
|
|
16
|
+
const code = String(readFileSync(systemJsUrl))
|
|
17
|
+
const ast = api.template.ast`${code}`
|
|
18
|
+
path.node.body.unshift(ast)
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ import { babelPluginImportMetadata } from "@jsenv/core/src/internal/compiling/ba
|
|
|
11
11
|
import { ansiToHTML } from "./ansiToHTML.js"
|
|
12
12
|
import { babelPluginRegeneratorRuntimeAsJsenvImport } from "./babel_plugin_regenerator_runtime_as_jsenv_import.js"
|
|
13
13
|
import { babelPluginBabelHelpersAsJsenvImports } from "./babel_plugin_babel_helpers_as_jsenv_imports.js"
|
|
14
|
+
import { babelPluginSystemJsPrepend } from "./babel_plugin_systemjs_prepend.js"
|
|
14
15
|
import { filePathToBabelHelperName } from "./babelHelper.js"
|
|
15
16
|
|
|
16
17
|
export const jsenvTransform = async ({
|
|
@@ -26,6 +27,7 @@ export const jsenvTransform = async ({
|
|
|
26
27
|
topLevelAwait,
|
|
27
28
|
|
|
28
29
|
babelHelpersInjectionAsImport,
|
|
30
|
+
prependSystemJs,
|
|
29
31
|
transformGenerator,
|
|
30
32
|
regeneratorRuntimeImportPath,
|
|
31
33
|
sourcemapEnabled,
|
|
@@ -77,7 +79,6 @@ export const jsenvTransform = async ({
|
|
|
77
79
|
],
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
|
|
81
82
|
babelPluginMap = {
|
|
82
83
|
...getMinimalBabelPluginMap(),
|
|
83
84
|
"transform-import-meta": [
|
|
@@ -147,6 +148,19 @@ export const jsenvTransform = async ({
|
|
|
147
148
|
: {}),
|
|
148
149
|
"import-metadata": [babelPluginImportMetadata],
|
|
149
150
|
}
|
|
151
|
+
if (moduleOutFormat === "systemjs") {
|
|
152
|
+
babelPluginMap = {
|
|
153
|
+
...babelPluginMap,
|
|
154
|
+
"proposal-dynamic-import": [proposalDynamicImport],
|
|
155
|
+
"transform-modules-systemjs": [transformModulesSystemJs],
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (prependSystemJs) {
|
|
159
|
+
babelPluginMap = {
|
|
160
|
+
...babelPluginMap,
|
|
161
|
+
"systemjs-prepend": [babelPluginSystemJsPrepend],
|
|
162
|
+
}
|
|
163
|
+
}
|
|
150
164
|
|
|
151
165
|
const asyncToPromise = babelPluginMap["transform-async-to-promises"]
|
|
152
166
|
if (topLevelAwait && asyncToPromise) {
|
|
@@ -158,17 +172,7 @@ export const jsenvTransform = async ({
|
|
|
158
172
|
code,
|
|
159
173
|
options: {
|
|
160
174
|
...options,
|
|
161
|
-
plugins: babelPluginsFromBabelPluginMap(
|
|
162
|
-
...babelPluginMap,
|
|
163
|
-
...(moduleOutFormat === "systemjs"
|
|
164
|
-
? {
|
|
165
|
-
"proposal-dynamic-import": [proposalDynamicImport],
|
|
166
|
-
...(moduleOutFormat === "systemjs"
|
|
167
|
-
? { "transform-modules-systemjs": [transformModulesSystemJs] }
|
|
168
|
-
: {}),
|
|
169
|
-
}
|
|
170
|
-
: {}),
|
|
171
|
-
}),
|
|
175
|
+
plugins: babelPluginsFromBabelPluginMap(babelPluginMap),
|
|
172
176
|
},
|
|
173
177
|
})
|
|
174
178
|
code = babelTransformReturnValue.code
|
|
@@ -12,6 +12,7 @@ export const transformJs = async ({
|
|
|
12
12
|
moduleOutFormat = "esmodule",
|
|
13
13
|
importMetaFormat = moduleOutFormat,
|
|
14
14
|
babelHelpersInjectionAsImport = moduleOutFormat === "esmodule",
|
|
15
|
+
prependSystemJs,
|
|
15
16
|
topLevelAwait,
|
|
16
17
|
transformGenerator = true,
|
|
17
18
|
sourcemapEnabled = true,
|
|
@@ -51,6 +52,7 @@ export const transformJs = async ({
|
|
|
51
52
|
importMetaFormat,
|
|
52
53
|
|
|
53
54
|
babelHelpersInjectionAsImport,
|
|
55
|
+
prependSystemJs,
|
|
54
56
|
topLevelAwait,
|
|
55
57
|
transformGenerator,
|
|
56
58
|
sourcemapEnabled,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
TOOLBAR_INJECTOR_BUILD_URL,
|
|
9
9
|
} from "@jsenv/core/dist/build_manifest.js"
|
|
10
10
|
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
11
|
-
import {
|
|
11
|
+
import { getDefaultImportmap } from "@jsenv/core/src/internal/import-resolution/importmap_default.js"
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
setJavaScriptSourceMappingUrl,
|
|
@@ -120,83 +120,82 @@ export const compileHtml = async ({
|
|
|
120
120
|
importmapInfo = {
|
|
121
121
|
script,
|
|
122
122
|
url: resolveUrl(src, url),
|
|
123
|
-
|
|
123
|
+
load: async () => {
|
|
124
124
|
const importMapResponse = await fetchUrl(importmapInfo.url)
|
|
125
|
-
if (importMapResponse.status
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"importmap url": importmapInfo.url,
|
|
133
|
-
"html url": url,
|
|
134
|
-
},
|
|
135
|
-
),
|
|
125
|
+
if (importMapResponse.status === 200) {
|
|
126
|
+
const importmapAsText = await importMapResponse.text()
|
|
127
|
+
let htmlImportmap = JSON.parse(importmapAsText)
|
|
128
|
+
htmlImportmap = moveImportMap(
|
|
129
|
+
htmlImportmap,
|
|
130
|
+
importmapInfo.url,
|
|
131
|
+
url,
|
|
136
132
|
)
|
|
137
|
-
|
|
133
|
+
sources.push(importmapInfo.url)
|
|
134
|
+
sourcesContent.push(importmapAsText)
|
|
135
|
+
return htmlImportmap
|
|
138
136
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
importMapMoved,
|
|
150
|
-
null,
|
|
151
|
-
" ",
|
|
137
|
+
logger.warn(
|
|
138
|
+
createDetailedMessage(
|
|
139
|
+
importMapResponse.status === 404
|
|
140
|
+
? `importmap script file cannot be found.`
|
|
141
|
+
: `importmap script file unexpected response status (${importMapResponse.status}).`,
|
|
142
|
+
{
|
|
143
|
+
"importmap url": importmapInfo.url,
|
|
144
|
+
"html url": url,
|
|
145
|
+
},
|
|
146
|
+
),
|
|
152
147
|
)
|
|
153
|
-
return
|
|
148
|
+
return {}
|
|
154
149
|
},
|
|
155
150
|
}
|
|
156
151
|
} else {
|
|
157
152
|
importmapInfo = {
|
|
158
153
|
script,
|
|
159
154
|
url: compiledUrl,
|
|
160
|
-
|
|
155
|
+
load: () => {
|
|
156
|
+
const jsenvImportmap = getDefaultImportmap(compiledUrl, {
|
|
157
|
+
projectDirectoryUrl,
|
|
158
|
+
compileDirectoryUrl: `${projectDirectoryUrl}${compileId}/${outDirectoryRelativeUrl}`,
|
|
159
|
+
})
|
|
160
|
+
const htmlImportmap = JSON.parse(
|
|
161
|
+
getHtmlNodeTextNode(script).value,
|
|
162
|
+
)
|
|
163
|
+
const importmap = composeTwoImportMaps(
|
|
164
|
+
jsenvImportmap,
|
|
165
|
+
htmlImportmap,
|
|
166
|
+
)
|
|
167
|
+
return importmap
|
|
168
|
+
},
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
173
|
})
|
|
166
174
|
if (importmapInfo) {
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
importMapFileUrl: compiledUrl,
|
|
170
|
-
projectDirectoryUrl,
|
|
171
|
-
compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${compileId}/`,
|
|
172
|
-
})
|
|
173
|
-
const mappings = composeTwoImportMaps(importMapFromJsenv, htmlImportMap)
|
|
174
|
-
const importmapAsText = JSON.stringify(mappings, null, " ")
|
|
175
|
+
const importmap = await importmapInfo.load()
|
|
176
|
+
const importmapAsText = JSON.stringify(importmap, null, " ")
|
|
175
177
|
replaceHtmlNode(
|
|
176
178
|
importmapInfo.script,
|
|
177
179
|
`<script type="${
|
|
178
|
-
moduleOutFormat === "systemjs" ? "
|
|
180
|
+
moduleOutFormat === "systemjs" ? "systemjs-importmap" : "importmap"
|
|
179
181
|
}">${importmapAsText}</script>`,
|
|
180
182
|
{
|
|
181
183
|
attributesToIgnore: ["src"],
|
|
182
184
|
},
|
|
183
185
|
)
|
|
184
186
|
importmapInfo.inlinedFrom = importmapInfo.url
|
|
185
|
-
importmapInfo.url = compiledUrl
|
|
186
187
|
importmapInfo.text = importmapAsText
|
|
187
188
|
} else {
|
|
188
|
-
|
|
189
|
-
const defaultImportMap = getDefaultImportMap({
|
|
190
|
-
importMapFileUrl: compiledUrl,
|
|
189
|
+
const defaultImportMap = getDefaultImportmap(compiledUrl, {
|
|
191
190
|
projectDirectoryUrl,
|
|
192
|
-
|
|
191
|
+
compileDirectoryUrl: `${projectDirectoryUrl}${outDirectoryRelativeUrl}${compileId}/`,
|
|
193
192
|
})
|
|
194
193
|
const importmapAsText = JSON.stringify(defaultImportMap, null, " ")
|
|
195
194
|
manipulateHtmlAst(htmlAst, {
|
|
196
195
|
scriptInjections: [
|
|
197
196
|
{
|
|
198
197
|
type:
|
|
199
|
-
moduleOutFormat === "systemjs" ? "
|
|
198
|
+
moduleOutFormat === "systemjs" ? "systemjs-importmap" : "importmap",
|
|
200
199
|
// in case there is no importmap, force the presence
|
|
201
200
|
// so that '@jsenv/core/' are still remapped
|
|
202
201
|
text: importmapAsText,
|
|
@@ -1,89 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* allows the following:
|
|
3
|
-
*
|
|
4
|
-
* import "@jsenv/core/helpers/regenerator-runtime/regenerator-runtime.js"
|
|
5
|
-
* -> searches a file inside @jsenv/core/*
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { urlToRelativeUrl, urlIsInsideOf } from "@jsenv/filesystem"
|
|
10
1
|
import { composeTwoImportMaps } from "@jsenv/importmap"
|
|
11
2
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
export const compileImportmap = async ({ code, url }) => {
|
|
15
|
-
const importMapForProject = JSON.parse(code)
|
|
16
|
-
|
|
17
|
-
const topLevelRemappingForJsenvCore = {
|
|
18
|
-
"@jsenv/core/": urlToRelativeUrlRemapping(jsenvCoreDirectoryUrl, url),
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const importmapForSelfImport = {
|
|
22
|
-
imports: topLevelRemappingForJsenvCore,
|
|
23
|
-
scopes: generateJsenvCoreScopes({
|
|
24
|
-
importMapForProject,
|
|
25
|
-
topLevelRemappingForJsenvCore,
|
|
26
|
-
}),
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const importMap = [importmapForSelfImport, importMapForProject].reduce(
|
|
30
|
-
(previous, current) => composeTwoImportMaps(previous, current),
|
|
31
|
-
{},
|
|
32
|
-
)
|
|
3
|
+
import { getDefaultImportmap } from "@jsenv/core/src/internal/import-resolution/importmap_default.js"
|
|
33
4
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
5
|
+
export const compileImportmap = async ({
|
|
6
|
+
code,
|
|
7
|
+
url,
|
|
8
|
+
compiledUrl,
|
|
9
|
+
projectDirectoryUrl,
|
|
10
|
+
outDirectoryRelativeUrl,
|
|
11
|
+
compileId,
|
|
12
|
+
}) => {
|
|
13
|
+
const jsenvImportmap = getDefaultImportmap(compiledUrl, {
|
|
14
|
+
projectDirectoryUrl,
|
|
15
|
+
compileDirectoryUrl: `${projectDirectoryUrl}${outDirectoryRelativeUrl}${compileId}/`,
|
|
43
16
|
})
|
|
17
|
+
const projectImportmap = JSON.parse(code)
|
|
18
|
+
const importmap = composeTwoImportMaps(jsenvImportmap, projectImportmap)
|
|
44
19
|
|
|
45
20
|
return {
|
|
46
21
|
contentType: "application/importmap+json",
|
|
47
|
-
compiledSource: JSON.stringify(
|
|
22
|
+
compiledSource: JSON.stringify(importmap, null, " "),
|
|
48
23
|
sources: [url],
|
|
49
24
|
sourcesContent: [code],
|
|
50
25
|
assets: [],
|
|
51
26
|
assetsContent: [],
|
|
52
27
|
}
|
|
53
28
|
}
|
|
54
|
-
|
|
55
|
-
// this function just here to ensure relative urls starts with './'
|
|
56
|
-
// so that importmap do not consider them as bare specifiers
|
|
57
|
-
const urlToRelativeUrlRemapping = (url, baseUrl) => {
|
|
58
|
-
const relativeUrl = urlToRelativeUrl(url, baseUrl)
|
|
59
|
-
|
|
60
|
-
if (urlIsInsideOf(url, baseUrl)) {
|
|
61
|
-
if (relativeUrl.startsWith("../")) return relativeUrl
|
|
62
|
-
if (relativeUrl.startsWith("./")) return relativeUrl
|
|
63
|
-
return `./${relativeUrl}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return relativeUrl
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const generateJsenvCoreScopes = ({
|
|
70
|
-
importMapForProject,
|
|
71
|
-
topLevelRemappingForJsenvCore,
|
|
72
|
-
}) => {
|
|
73
|
-
const { scopes } = importMapForProject
|
|
74
|
-
|
|
75
|
-
if (!scopes) {
|
|
76
|
-
return undefined
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// I must ensure jsenvCoreImports wins by default in every scope
|
|
80
|
-
// because scope may contains stuff like
|
|
81
|
-
// "/": "/"
|
|
82
|
-
// "/": "/folder/"
|
|
83
|
-
// to achieve this, we set jsenvCoreImports into every scope
|
|
84
|
-
const scopesForJsenvCore = {}
|
|
85
|
-
Object.keys(scopes).forEach((scopeKey) => {
|
|
86
|
-
scopesForJsenvCore[scopeKey] = topLevelRemappingForJsenvCore
|
|
87
|
-
})
|
|
88
|
-
return scopesForJsenvCore
|
|
89
|
-
}
|
|
@@ -9,13 +9,21 @@ export const compileJavascript = async ({
|
|
|
9
9
|
projectDirectoryUrl,
|
|
10
10
|
|
|
11
11
|
babelPluginMap,
|
|
12
|
+
workerUrls,
|
|
13
|
+
serviceWorkerUrls,
|
|
12
14
|
moduleOutFormat,
|
|
13
15
|
importMetaFormat,
|
|
14
16
|
topLevelAwait,
|
|
17
|
+
prependSystemJs,
|
|
15
18
|
|
|
16
19
|
sourcemapExcludeSources,
|
|
17
20
|
sourcemapMethod,
|
|
18
21
|
}) => {
|
|
22
|
+
if (prependSystemJs === undefined) {
|
|
23
|
+
prependSystemJs =
|
|
24
|
+
workerUrls.includes(url) || serviceWorkerUrls.includes(url)
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
const transformResult = await transformJs({
|
|
20
28
|
code,
|
|
21
29
|
map,
|
|
@@ -27,6 +35,7 @@ export const compileJavascript = async ({
|
|
|
27
35
|
moduleOutFormat,
|
|
28
36
|
importMetaFormat,
|
|
29
37
|
topLevelAwait,
|
|
38
|
+
prependSystemJs,
|
|
30
39
|
})
|
|
31
40
|
|
|
32
41
|
return transformResultToCompilationResult(
|
|
@@ -95,10 +95,13 @@ export const startCompileServer = async ({
|
|
|
95
95
|
babelPluginMap,
|
|
96
96
|
babelConfigFileUrl,
|
|
97
97
|
customCompilers = {},
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
workers = [],
|
|
99
|
+
serviceWorkers = [],
|
|
100
|
+
importMapInWebWorkers = false,
|
|
101
|
+
prependSystemJs,
|
|
100
102
|
runtimeSupport,
|
|
101
103
|
|
|
104
|
+
// remaining options
|
|
102
105
|
livereloadWatchConfig = {
|
|
103
106
|
"./**": true,
|
|
104
107
|
"./**/.*/": false, // any folder starting with a dot is ignored (includes .git for instance)
|
|
@@ -138,9 +141,14 @@ export const startCompileServer = async ({
|
|
|
138
141
|
jsenvDirectoryUrl,
|
|
139
142
|
projectDirectoryUrl,
|
|
140
143
|
)
|
|
141
|
-
|
|
142
144
|
const logger = createLogger({ logLevel })
|
|
143
145
|
|
|
146
|
+
const workerUrls = workers.map((worker) =>
|
|
147
|
+
resolveUrl(worker, projectDirectoryUrl),
|
|
148
|
+
)
|
|
149
|
+
const serviceWorkerUrls = serviceWorkers.map((serviceWorker) =>
|
|
150
|
+
resolveUrl(serviceWorker, projectDirectoryUrl),
|
|
151
|
+
)
|
|
144
152
|
const browser = isBrowserPartOfSupportedRuntimes(runtimeSupport)
|
|
145
153
|
const babelPluginMapFromFile = await loadBabelPluginMapFromFile({
|
|
146
154
|
projectDirectoryUrl,
|
|
@@ -177,7 +185,19 @@ export const startCompileServer = async ({
|
|
|
177
185
|
const { babelSyntaxPluginMap, babelPluginMapWithoutSyntax } =
|
|
178
186
|
extractSyntaxBabelPluginMap(babelPluginMap)
|
|
179
187
|
const compileServerGroupMap = generateGroupMap({
|
|
180
|
-
|
|
188
|
+
featureNames: [
|
|
189
|
+
...(browser
|
|
190
|
+
? [
|
|
191
|
+
"module",
|
|
192
|
+
"importmap",
|
|
193
|
+
"import_assertion_type_json",
|
|
194
|
+
"import_assertion_type_css",
|
|
195
|
+
]
|
|
196
|
+
: []),
|
|
197
|
+
...(browser && workerUrls.length > 0 ? ["worker_type_module"] : []),
|
|
198
|
+
...(browser && importMapInWebWorkers ? ["worker_importmap"] : []),
|
|
199
|
+
...Object.keys(babelPluginMapWithoutSyntax),
|
|
200
|
+
],
|
|
181
201
|
runtimeSupport,
|
|
182
202
|
})
|
|
183
203
|
|
|
@@ -188,7 +208,7 @@ export const startCompileServer = async ({
|
|
|
188
208
|
// It happens for module written in ESM but also using process.env.NODE_ENV
|
|
189
209
|
// for example "react-redux"
|
|
190
210
|
// This babel plugin won't force compilation because it's added after "generateGroupMap"
|
|
191
|
-
// however it will be used even if not part of "
|
|
211
|
+
// however it will be used even if not part of "missingFeatureNames"
|
|
192
212
|
// as visible in "babelPluginMapFromCompileId"
|
|
193
213
|
// This is a quick workaround to get things working because:
|
|
194
214
|
// - If none of your code needs to be compiled but one of your dependency
|
|
@@ -314,6 +334,10 @@ export const startCompileServer = async ({
|
|
|
314
334
|
groupMap: compileServerGroupMap,
|
|
315
335
|
babelPluginMap,
|
|
316
336
|
customCompilers,
|
|
337
|
+
workerUrls,
|
|
338
|
+
serviceWorkerUrls,
|
|
339
|
+
importMapInWebWorkers,
|
|
340
|
+
prependSystemJs,
|
|
317
341
|
moduleOutFormat,
|
|
318
342
|
importMetaFormat,
|
|
319
343
|
jsenvEventSourceClientInjection,
|
|
@@ -14,7 +14,7 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
14
14
|
canAvoidCompilation,
|
|
15
15
|
featuresReport,
|
|
16
16
|
customCompilerPatterns,
|
|
17
|
-
|
|
17
|
+
missingFeatureNames,
|
|
18
18
|
inlineImportMapIntoHTML,
|
|
19
19
|
outDirectoryRelativeUrl,
|
|
20
20
|
compileId,
|
|
@@ -38,7 +38,7 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
38
38
|
missingOnly: true,
|
|
39
39
|
featuresReport,
|
|
40
40
|
customCompilerPatterns,
|
|
41
|
-
|
|
41
|
+
missingFeatureNames,
|
|
42
42
|
inlineImportMapIntoHTML,
|
|
43
43
|
},
|
|
44
44
|
)}`,
|
|
@@ -54,7 +54,7 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
54
54
|
{
|
|
55
55
|
featuresReport,
|
|
56
56
|
customCompilerPatterns,
|
|
57
|
-
|
|
57
|
+
missingFeatureNames,
|
|
58
58
|
inlineImportMapIntoHTML,
|
|
59
59
|
},
|
|
60
60
|
)}`,
|
|
@@ -70,7 +70,7 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
70
70
|
{
|
|
71
71
|
featuresReport,
|
|
72
72
|
customCompilerPatterns,
|
|
73
|
-
|
|
73
|
+
missingFeatureNames,
|
|
74
74
|
inlineImportMapIntoHTML,
|
|
75
75
|
},
|
|
76
76
|
)}`,
|
|
@@ -128,7 +128,7 @@ const getBrowserSupportMessage = ({
|
|
|
128
128
|
missingOnly,
|
|
129
129
|
featuresReport,
|
|
130
130
|
customCompilerPatterns,
|
|
131
|
-
|
|
131
|
+
missingFeatureNames,
|
|
132
132
|
inlineImportMapIntoHTML,
|
|
133
133
|
}) => {
|
|
134
134
|
const parts = []
|
|
@@ -161,14 +161,14 @@ const getBrowserSupportMessage = ({
|
|
|
161
161
|
parts.push(`top level await is not supported`)
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
164
|
+
const missingFeatureCount = missingFeatureNames.length
|
|
165
|
+
if (missingFeatureCount === 0) {
|
|
166
166
|
if (!missingOnly) {
|
|
167
|
-
parts.push(`all
|
|
167
|
+
parts.push(`all features are natively supported`)
|
|
168
168
|
}
|
|
169
169
|
} else {
|
|
170
170
|
parts.push(
|
|
171
|
-
`${
|
|
171
|
+
`${missingFeatureCount} features are missing: ${missingFeatureNames}`,
|
|
172
172
|
)
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -51,6 +51,9 @@ export const executePlan = async (
|
|
|
51
51
|
compileServerCanWriteOnFilesystem,
|
|
52
52
|
babelPluginMap,
|
|
53
53
|
babelConfigFileUrl,
|
|
54
|
+
workers,
|
|
55
|
+
serviceWorkers,
|
|
56
|
+
importMapInWebWorkers,
|
|
54
57
|
customCompilers,
|
|
55
58
|
} = {},
|
|
56
59
|
) => {
|
|
@@ -123,6 +126,9 @@ export const executePlan = async (
|
|
|
123
126
|
keepProcessAlive: true, // to be sure it stays alive
|
|
124
127
|
babelPluginMap,
|
|
125
128
|
babelConfigFileUrl,
|
|
129
|
+
workers,
|
|
130
|
+
serviceWorkers,
|
|
131
|
+
importMapInWebWorkers,
|
|
126
132
|
customCompilers,
|
|
127
133
|
runtimeSupport,
|
|
128
134
|
})
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsenvBabelPluginCompatMap } from "./babel_plugins_compatibility.js"
|
|
2
2
|
|
|
3
3
|
export const featuresCompatMap = {
|
|
4
4
|
module: {
|
|
@@ -26,4 +26,12 @@ export const featuresCompatMap = {
|
|
|
26
26
|
chrome: "93",
|
|
27
27
|
edge: "93",
|
|
28
28
|
},
|
|
29
|
+
worker_type_module: {
|
|
30
|
+
chrome: "80",
|
|
31
|
+
edge: "80",
|
|
32
|
+
opera: "67",
|
|
33
|
+
android: "80",
|
|
34
|
+
},
|
|
35
|
+
worker_importmap: {},
|
|
36
|
+
...jsenvBabelPluginCompatMap,
|
|
29
37
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
{
|
|
19
19
|
"best": {
|
|
20
|
-
"
|
|
20
|
+
"missingFeatureNames" : [
|
|
21
21
|
"transform-block-scoping",
|
|
22
22
|
],
|
|
23
23
|
"minRuntimeVersions": {
|
|
@@ -33,40 +33,20 @@ Take chars below to update legends
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
import { COMPILE_ID_OTHERWISE, COMPILE_ID_BEST } from "../CONSTANTS.js"
|
|
36
|
-
import { jsenvBabelPluginCompatMap } from "./jsenvBabelPluginCompatMap.js"
|
|
37
|
-
import { jsenvPluginCompatMap } from "./jsenvPluginCompatMap.js"
|
|
38
36
|
import { createRuntimeCompat } from "./runtime_compat.js"
|
|
39
37
|
|
|
40
|
-
export const generateGroupMap = ({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
babelPluginCompatMap = jsenvBabelPluginCompatMap,
|
|
44
|
-
// jsenv plugin are for later, for now, nothing is using them
|
|
45
|
-
jsenvPluginMap = {},
|
|
46
|
-
}) => {
|
|
47
|
-
if (typeof babelPluginMap !== "object") {
|
|
48
|
-
throw new TypeError(
|
|
49
|
-
`babelPluginMap must be an object, got ${babelPluginMap}`,
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
if (typeof jsenvPluginMap !== "object") {
|
|
53
|
-
throw new TypeError(
|
|
54
|
-
`jsenvPluginMap must be an object, got ${jsenvPluginMap}`,
|
|
55
|
-
)
|
|
38
|
+
export const generateGroupMap = ({ featureNames, runtimeSupport }) => {
|
|
39
|
+
if (!Array.isArray(featureNames)) {
|
|
40
|
+
throw new TypeError(`featureNames must be an array, got ${featureNames}`)
|
|
56
41
|
}
|
|
57
42
|
if (typeof runtimeSupport !== "object") {
|
|
58
43
|
throw new TypeError(
|
|
59
44
|
`runtimeSupport must be an object, got ${runtimeSupport}`,
|
|
60
45
|
)
|
|
61
46
|
}
|
|
62
|
-
|
|
63
47
|
const runtimeNames = Object.keys(runtimeSupport)
|
|
64
|
-
|
|
65
48
|
const groupWithoutFeature = {
|
|
66
|
-
|
|
67
|
-
...Object.keys(babelPluginMap),
|
|
68
|
-
...Object.keys(jsenvPluginMap),
|
|
69
|
-
],
|
|
49
|
+
missingFeatureNames: featureNames,
|
|
70
50
|
minRuntimeVersions: {},
|
|
71
51
|
}
|
|
72
52
|
if (runtimeNames.length === 0) {
|
|
@@ -74,19 +54,10 @@ export const generateGroupMap = ({
|
|
|
74
54
|
[COMPILE_ID_OTHERWISE]: groupWithoutFeature,
|
|
75
55
|
}
|
|
76
56
|
}
|
|
77
|
-
|
|
78
57
|
const runtimeCompat = createRuntimeCompat({
|
|
79
58
|
runtimeSupport,
|
|
80
|
-
|
|
81
|
-
...babelPluginMap,
|
|
82
|
-
...jsenvPluginMap,
|
|
83
|
-
},
|
|
84
|
-
pluginCompatMap: {
|
|
85
|
-
...babelPluginCompatMap,
|
|
86
|
-
...jsenvPluginCompatMap,
|
|
87
|
-
},
|
|
59
|
+
featureNames,
|
|
88
60
|
})
|
|
89
|
-
|
|
90
61
|
return {
|
|
91
62
|
[COMPILE_ID_BEST]: runtimeCompat,
|
|
92
63
|
[COMPILE_ID_OTHERWISE]: groupWithoutFeature,
|
|
@@ -3,18 +3,16 @@ import { findHighestVersion } from "../semantic_versioning/index.js"
|
|
|
3
3
|
export const createOneRuntimeCompat = ({
|
|
4
4
|
runtimeName,
|
|
5
5
|
runtimeVersion,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
pluginCompatMap,
|
|
6
|
+
featureNames,
|
|
7
|
+
featuresCompatMap,
|
|
9
8
|
}) => {
|
|
10
|
-
const
|
|
9
|
+
const missingFeatureNames = []
|
|
11
10
|
// will be the first runtime version compatible with all features not listed in
|
|
12
|
-
//
|
|
11
|
+
// missingFeatureNames
|
|
13
12
|
let minRuntimeVersion
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const runtimeVersionCompatible = pluginCompat[runtimeName] || "Infinity"
|
|
13
|
+
featureNames.forEach((featureName) => {
|
|
14
|
+
const featureCompat = featuresCompatMap[featureName] || {}
|
|
15
|
+
const runtimeVersionCompatible = featureCompat[runtimeName] || "Infinity"
|
|
18
16
|
|
|
19
17
|
const highestVersion = findHighestVersion(
|
|
20
18
|
runtimeVersion,
|
|
@@ -22,7 +20,7 @@ export const createOneRuntimeCompat = ({
|
|
|
22
20
|
)
|
|
23
21
|
const compatible = highestVersion === runtimeVersion
|
|
24
22
|
if (!compatible) {
|
|
25
|
-
|
|
23
|
+
missingFeatureNames.push(featureName)
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
if (compatible && runtimeVersionCompatible !== "Infinity") {
|
|
@@ -33,9 +31,8 @@ export const createOneRuntimeCompat = ({
|
|
|
33
31
|
)
|
|
34
32
|
}
|
|
35
33
|
})
|
|
36
|
-
|
|
37
34
|
return {
|
|
38
|
-
|
|
35
|
+
missingFeatureNames,
|
|
39
36
|
minRuntimeVersion: minRuntimeVersion || runtimeVersion,
|
|
40
37
|
}
|
|
41
38
|
}
|