@jsenv/core 30.2.0 → 30.3.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/controllable_child_process.mjs +1 -1
- package/dist/controllable_worker_thread.mjs +1 -1
- package/dist/js/execute_using_dynamic_import.js +2 -2
- package/dist/js/v8_coverage.js +4 -4
- package/dist/main.js +249 -91
- package/package.json +3 -3
- package/src/build/build.js +153 -44
- package/src/build/{inject_global_version_mappings.js → version_mappings_injection.js} +44 -33
- package/src/dev/file_service.js +12 -4
- package/src/kitchen/compat/features_compatibility.js +59 -0
- package/src/kitchen/kitchen.js +5 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +13 -22
- package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +1 -5
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +1 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.3.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@c88/v8-coverage": "0.1.1",
|
|
68
68
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
69
69
|
"@jsenv/abort": "4.2.4",
|
|
70
|
-
"@jsenv/ast": "2.0.
|
|
70
|
+
"@jsenv/ast": "2.0.1",
|
|
71
71
|
"@jsenv/babel-plugins": "1.1.2",
|
|
72
|
-
"@jsenv/plugin-bundling": "1.1.
|
|
72
|
+
"@jsenv/plugin-bundling": "1.1.1",
|
|
73
73
|
"@jsenv/filesystem": "4.1.9",
|
|
74
74
|
"@jsenv/importmap": "1.2.1",
|
|
75
75
|
"@jsenv/integrity": "0.0.1",
|
package/src/build/build.js
CHANGED
|
@@ -56,9 +56,13 @@ import {
|
|
|
56
56
|
|
|
57
57
|
import { createUrlGraph } from "../kitchen/url_graph.js"
|
|
58
58
|
import { createKitchen } from "../kitchen/kitchen.js"
|
|
59
|
+
import { RUNTIME_COMPAT } from "../kitchen/compat/runtime_compat.js"
|
|
59
60
|
import { createUrlGraphLoader } from "../kitchen/url_graph/url_graph_loader.js"
|
|
60
61
|
import { createUrlGraphSummary } from "../kitchen/url_graph/url_graph_report.js"
|
|
61
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
isWebWorkerEntryPointReference,
|
|
64
|
+
isWebWorkerUrlInfo,
|
|
65
|
+
} from "../kitchen/web_workers.js"
|
|
62
66
|
import { jsenvPluginUrlAnalysis } from "../plugins/url_analysis/jsenv_plugin_url_analysis.js"
|
|
63
67
|
import { jsenvPluginInline } from "../plugins/inline/jsenv_plugin_inline.js"
|
|
64
68
|
import { jsenvPluginAsJsClassic } from "../plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js"
|
|
@@ -66,7 +70,10 @@ import { getCorePlugins } from "../plugins/plugins.js"
|
|
|
66
70
|
|
|
67
71
|
import { GRAPH } from "./graph_utils.js"
|
|
68
72
|
import { createBuildUrlsGenerator } from "./build_urls_generator.js"
|
|
69
|
-
import {
|
|
73
|
+
import {
|
|
74
|
+
injectVersionMappingsAsGlobal,
|
|
75
|
+
injectVersionMappingsAsImportmap,
|
|
76
|
+
} from "./version_mappings_injection.js"
|
|
70
77
|
import { createVersionGenerator } from "./version_generator.js"
|
|
71
78
|
|
|
72
79
|
// default runtimeCompat corresponds to
|
|
@@ -116,13 +123,13 @@ export const build = async ({
|
|
|
116
123
|
signal = new AbortController().signal,
|
|
117
124
|
handleSIGINT = true,
|
|
118
125
|
logLevel = "info",
|
|
119
|
-
runtimeCompat = defaultRuntimeCompat,
|
|
120
126
|
rootDirectoryUrl,
|
|
121
127
|
buildDirectoryUrl,
|
|
122
128
|
assetsDirectory = "",
|
|
123
|
-
base = runtimeCompat.node ? "./" : "/",
|
|
124
129
|
entryPoints = {},
|
|
125
130
|
|
|
131
|
+
runtimeCompat = defaultRuntimeCompat,
|
|
132
|
+
base = runtimeCompat.node ? "./" : "/",
|
|
126
133
|
plugins = [],
|
|
127
134
|
sourcemaps = false,
|
|
128
135
|
sourcemapsSourcesContent,
|
|
@@ -133,6 +140,7 @@ export const build = async ({
|
|
|
133
140
|
transpilation = {},
|
|
134
141
|
versioning = !runtimeCompat.node,
|
|
135
142
|
versioningMethod = "search_param", // "filename", "search_param"
|
|
143
|
+
versioningViaImportmap = true,
|
|
136
144
|
lineBreakNormalization = process.platform === "win32",
|
|
137
145
|
|
|
138
146
|
clientFiles = {
|
|
@@ -221,6 +229,28 @@ build ${entryPointKeys.length} entry points`)
|
|
|
221
229
|
const versioningRedirections = new Map()
|
|
222
230
|
const entryUrls = []
|
|
223
231
|
const rawGraph = createUrlGraph()
|
|
232
|
+
const contextSharedDuringBuild = {
|
|
233
|
+
systemJsTranspilation: (() => {
|
|
234
|
+
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node")
|
|
235
|
+
if (nodeRuntimeEnabled) return false
|
|
236
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "script_type_module"))
|
|
237
|
+
return true
|
|
238
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "import_dynamic"))
|
|
239
|
+
return true
|
|
240
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "import_meta"))
|
|
241
|
+
return true
|
|
242
|
+
if (
|
|
243
|
+
versioning &&
|
|
244
|
+
versioningViaImportmap &&
|
|
245
|
+
!RUNTIME_COMPAT.isSupported(runtimeCompat, "importmap")
|
|
246
|
+
)
|
|
247
|
+
return true
|
|
248
|
+
return false
|
|
249
|
+
})(),
|
|
250
|
+
minification: plugins.some(
|
|
251
|
+
(plugin) => plugin.name === "jsenv:minification",
|
|
252
|
+
),
|
|
253
|
+
}
|
|
224
254
|
const rawGraphKitchen = createKitchen({
|
|
225
255
|
signal,
|
|
226
256
|
logLevel,
|
|
@@ -228,6 +258,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
228
258
|
urlGraph: rawGraph,
|
|
229
259
|
build: true,
|
|
230
260
|
runtimeCompat,
|
|
261
|
+
...contextSharedDuringBuild,
|
|
231
262
|
plugins: [
|
|
232
263
|
...plugins,
|
|
233
264
|
{
|
|
@@ -299,6 +330,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
299
330
|
urlGraph: finalGraph,
|
|
300
331
|
build: true,
|
|
301
332
|
runtimeCompat,
|
|
333
|
+
...contextSharedDuringBuild,
|
|
302
334
|
plugins: [
|
|
303
335
|
urlAnalysisPlugin,
|
|
304
336
|
jsenvPluginAsJsClassic({
|
|
@@ -877,6 +909,75 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
877
909
|
disabled: logger.levels.debug || !logger.levels.info,
|
|
878
910
|
})
|
|
879
911
|
try {
|
|
912
|
+
const canUseImportmap =
|
|
913
|
+
versioningViaImportmap &&
|
|
914
|
+
finalEntryUrls.every((finalEntryUrl) => {
|
|
915
|
+
const finalEntryUrlInfo = finalGraph.getUrlInfo(finalEntryUrl)
|
|
916
|
+
return finalEntryUrlInfo.type === "html"
|
|
917
|
+
}) &&
|
|
918
|
+
finalGraphKitchen.kitchenContext.isSupportedOnCurrentClients(
|
|
919
|
+
"importmap",
|
|
920
|
+
)
|
|
921
|
+
const workerReferenceSet = new Set()
|
|
922
|
+
const isReferencedByWorker = (reference, graph) => {
|
|
923
|
+
if (workerReferenceSet.has(reference)) {
|
|
924
|
+
return true
|
|
925
|
+
}
|
|
926
|
+
const urlInfo = graph.getUrlInfo(reference.url)
|
|
927
|
+
const dependentWorker = graph.findDependent(
|
|
928
|
+
urlInfo,
|
|
929
|
+
(dependentUrlInfo) => {
|
|
930
|
+
return isWebWorkerUrlInfo(dependentUrlInfo)
|
|
931
|
+
},
|
|
932
|
+
)
|
|
933
|
+
if (dependentWorker) {
|
|
934
|
+
workerReferenceSet.add(reference)
|
|
935
|
+
return true
|
|
936
|
+
}
|
|
937
|
+
return Boolean(dependentWorker)
|
|
938
|
+
}
|
|
939
|
+
const preferWithoutVersioning = (reference) => {
|
|
940
|
+
const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl)
|
|
941
|
+
if (parentUrlInfo.jsQuote) {
|
|
942
|
+
return {
|
|
943
|
+
type: "global",
|
|
944
|
+
source: `${parentUrlInfo.jsQuote}+__v__(${JSON.stringify(
|
|
945
|
+
reference.specifier,
|
|
946
|
+
)})+${parentUrlInfo.jsQuote}`,
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
if (reference.type === "js_url") {
|
|
950
|
+
return {
|
|
951
|
+
type: "global",
|
|
952
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`,
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
if (reference.type === "js_import") {
|
|
956
|
+
if (reference.subtype === "import_dynamic") {
|
|
957
|
+
return {
|
|
958
|
+
type: "global",
|
|
959
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`,
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (reference.subtype === "import_meta_resolve") {
|
|
963
|
+
return {
|
|
964
|
+
type: "global",
|
|
965
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`,
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
if (
|
|
969
|
+
canUseImportmap &&
|
|
970
|
+
!isReferencedByWorker(reference, finalGraph)
|
|
971
|
+
) {
|
|
972
|
+
return {
|
|
973
|
+
type: "importmap",
|
|
974
|
+
source: JSON.stringify(reference.specifier),
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return null
|
|
979
|
+
}
|
|
980
|
+
|
|
880
981
|
// see also https://github.com/rollup/rollup/pull/4543
|
|
881
982
|
const contentVersionMap = new Map()
|
|
882
983
|
const hashCallbacks = []
|
|
@@ -939,18 +1040,11 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
939
1040
|
// (inline, data:, sourcemap, shouldHandle is false, ...)
|
|
940
1041
|
return null
|
|
941
1042
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
//
|
|
947
|
-
return null
|
|
948
|
-
}
|
|
949
|
-
if (
|
|
950
|
-
reference.type === "js_url" ||
|
|
951
|
-
reference.subtype === "import_dynamic"
|
|
952
|
-
) {
|
|
953
|
-
// __v__() makes versioning dynamic: no need to take into account
|
|
1043
|
+
if (preferWithoutVersioning(reference)) {
|
|
1044
|
+
// when versioning is dynamic no need to take into account
|
|
1045
|
+
// happend for:
|
|
1046
|
+
// - specifier mapped by window.__v__()
|
|
1047
|
+
// - specifier mapped by importmap
|
|
954
1048
|
return null
|
|
955
1049
|
}
|
|
956
1050
|
return dependencyContentVersion
|
|
@@ -1004,13 +1098,15 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1004
1098
|
})
|
|
1005
1099
|
|
|
1006
1100
|
const versionMappings = {}
|
|
1007
|
-
const
|
|
1101
|
+
const versionMappingsOnGlobalMap = new Set()
|
|
1102
|
+
const versionMappingsOnImportmap = new Set()
|
|
1008
1103
|
const versioningKitchen = createKitchen({
|
|
1009
1104
|
logLevel: logger.level,
|
|
1010
1105
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
1011
1106
|
urlGraph: finalGraph,
|
|
1012
1107
|
build: true,
|
|
1013
1108
|
runtimeCompat,
|
|
1109
|
+
...contextSharedDuringBuild,
|
|
1014
1110
|
plugins: [
|
|
1015
1111
|
urlAnalysisPlugin,
|
|
1016
1112
|
jsenvPluginInline({
|
|
@@ -1085,24 +1181,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1085
1181
|
versioningRedirections.set(reference.url, versionedUrl)
|
|
1086
1182
|
buildUrls.set(versionedSpecifier, versionedUrl)
|
|
1087
1183
|
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
reference.specifier,
|
|
1097
|
-
)})+${parentUrlInfo.jsQuote}`
|
|
1098
|
-
}
|
|
1099
|
-
if (
|
|
1100
|
-
reference.type === "js_url" ||
|
|
1101
|
-
reference.subtype === "import_dynamic" ||
|
|
1102
|
-
reference.subtype === "import_meta_resolve"
|
|
1103
|
-
) {
|
|
1104
|
-
usedVersionMappings.add(reference.specifier)
|
|
1105
|
-
return () => `__v__(${JSON.stringify(reference.specifier)})`
|
|
1184
|
+
const withoutVersioning = preferWithoutVersioning(reference)
|
|
1185
|
+
if (withoutVersioning) {
|
|
1186
|
+
if (withoutVersioning.type === "importmap") {
|
|
1187
|
+
versionMappingsOnImportmap.add(reference.specifier)
|
|
1188
|
+
} else {
|
|
1189
|
+
versionMappingsOnGlobalMap.add(reference.specifier)
|
|
1190
|
+
}
|
|
1191
|
+
return () => withoutVersioning.source
|
|
1106
1192
|
}
|
|
1107
1193
|
return versionedSpecifier
|
|
1108
1194
|
},
|
|
@@ -1154,27 +1240,50 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1154
1240
|
})
|
|
1155
1241
|
})
|
|
1156
1242
|
await versioningUrlGraphLoader.getAllLoadDonePromise(buildOperation)
|
|
1157
|
-
|
|
1243
|
+
workerReferenceSet.clear()
|
|
1244
|
+
const actions = []
|
|
1245
|
+
const visitors = []
|
|
1246
|
+
if (versionMappingsOnImportmap.size) {
|
|
1158
1247
|
const versionMappingsNeeded = {}
|
|
1159
|
-
|
|
1248
|
+
versionMappingsOnImportmap.forEach((specifier) => {
|
|
1160
1249
|
versionMappingsNeeded[specifier] = versionMappings[specifier]
|
|
1161
1250
|
})
|
|
1162
|
-
|
|
1163
|
-
|
|
1251
|
+
visitors.push((urlInfo) => {
|
|
1252
|
+
if (urlInfo.type === "html" && urlInfo.isEntryPoint) {
|
|
1253
|
+
actions.push(async () => {
|
|
1254
|
+
await injectVersionMappingsAsImportmap({
|
|
1255
|
+
urlInfo,
|
|
1256
|
+
kitchen: finalGraphKitchen,
|
|
1257
|
+
versionMappings: versionMappingsNeeded,
|
|
1258
|
+
})
|
|
1259
|
+
})
|
|
1260
|
+
}
|
|
1261
|
+
})
|
|
1262
|
+
}
|
|
1263
|
+
if (versionMappingsOnGlobalMap.size) {
|
|
1264
|
+
const versionMappingsNeeded = {}
|
|
1265
|
+
versionMappingsOnGlobalMap.forEach((specifier) => {
|
|
1266
|
+
versionMappingsNeeded[specifier] = versionMappings[specifier]
|
|
1267
|
+
})
|
|
1268
|
+
visitors.push((urlInfo) => {
|
|
1164
1269
|
if (urlInfo.isEntryPoint) {
|
|
1165
1270
|
actions.push(async () => {
|
|
1166
|
-
await
|
|
1271
|
+
await injectVersionMappingsAsGlobal({
|
|
1167
1272
|
urlInfo,
|
|
1168
1273
|
kitchen: finalGraphKitchen,
|
|
1169
1274
|
versionMappings: versionMappingsNeeded,
|
|
1170
|
-
minification: plugins.some(
|
|
1171
|
-
(plugin) => plugin.name === "jsenv:minification",
|
|
1172
|
-
),
|
|
1173
1275
|
})
|
|
1174
1276
|
})
|
|
1175
1277
|
}
|
|
1176
1278
|
})
|
|
1177
|
-
|
|
1279
|
+
}
|
|
1280
|
+
if (visitors.length) {
|
|
1281
|
+
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1282
|
+
visitors.forEach((visitor) => visitor(urlInfo))
|
|
1283
|
+
})
|
|
1284
|
+
if (actions.length) {
|
|
1285
|
+
await Promise.all(actions.map((action) => action()))
|
|
1286
|
+
}
|
|
1178
1287
|
}
|
|
1179
1288
|
} catch (e) {
|
|
1180
1289
|
versioningTask.fail()
|
|
@@ -10,17 +10,16 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js"
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const injectVersionMappingsAsGlobal = async ({
|
|
14
14
|
urlInfo,
|
|
15
15
|
kitchen,
|
|
16
16
|
versionMappings,
|
|
17
|
-
minification,
|
|
18
17
|
}) => {
|
|
19
18
|
const injector = injectors[urlInfo.type]
|
|
20
19
|
if (injector) {
|
|
21
20
|
const { content, sourcemap } = await injector(urlInfo, {
|
|
22
21
|
versionMappings,
|
|
23
|
-
minification,
|
|
22
|
+
minification: kitchen.kitchenContext.minification,
|
|
24
23
|
})
|
|
25
24
|
kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
|
26
25
|
content,
|
|
@@ -28,12 +27,8 @@ export const injectVersionMappings = async ({
|
|
|
28
27
|
})
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
const injectors = {
|
|
33
31
|
html: (urlInfo, { versionMappings, minification }) => {
|
|
34
|
-
// ideally we would inject an importmap but browser support is too low
|
|
35
|
-
// (even worse for worker/service worker)
|
|
36
|
-
// so for now we inject code into entry points
|
|
37
32
|
const htmlAst = parseHtmlString(urlInfo.content, {
|
|
38
33
|
storeOriginalPositions: false,
|
|
39
34
|
})
|
|
@@ -43,7 +38,7 @@ const injectors = {
|
|
|
43
38
|
tagName: "script",
|
|
44
39
|
textContent: generateClientCodeForVersionMappings(versionMappings, {
|
|
45
40
|
globalName: "window",
|
|
46
|
-
|
|
41
|
+
minification,
|
|
47
42
|
}),
|
|
48
43
|
}),
|
|
49
44
|
"jsenv:versioning",
|
|
@@ -52,49 +47,65 @@ const injectors = {
|
|
|
52
47
|
content: stringifyHtmlAst(htmlAst),
|
|
53
48
|
}
|
|
54
49
|
},
|
|
55
|
-
js_classic: (
|
|
56
|
-
|
|
57
|
-
versionMappings,
|
|
58
|
-
minify: minification || minification.js_classic,
|
|
59
|
-
})
|
|
60
|
-
},
|
|
61
|
-
js_module: (urlInfo, { versionMappings, minification }) => {
|
|
62
|
-
return jsInjector(urlInfo, {
|
|
63
|
-
versionMappings,
|
|
64
|
-
minify: minification || minification.js_module,
|
|
65
|
-
})
|
|
66
|
-
},
|
|
50
|
+
js_classic: (...args) => jsInjector(...args),
|
|
51
|
+
js_module: (...args) => jsInjector(...args),
|
|
67
52
|
}
|
|
68
|
-
|
|
69
|
-
const jsInjector = (urlInfo, { versionMappings, minify }) => {
|
|
53
|
+
const jsInjector = (urlInfo, { versionMappings, minification }) => {
|
|
70
54
|
const magicSource = createMagicSource(urlInfo.content)
|
|
71
55
|
magicSource.prepend(
|
|
72
56
|
generateClientCodeForVersionMappings(versionMappings, {
|
|
73
57
|
globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
|
|
74
|
-
|
|
58
|
+
minification,
|
|
75
59
|
}),
|
|
76
60
|
)
|
|
77
61
|
return magicSource.toContentAndSourcemap()
|
|
78
62
|
}
|
|
79
|
-
|
|
80
63
|
const generateClientCodeForVersionMappings = (
|
|
81
64
|
versionMappings,
|
|
82
|
-
{ globalName,
|
|
65
|
+
{ globalName, minification },
|
|
83
66
|
) => {
|
|
84
|
-
if (
|
|
67
|
+
if (minification) {
|
|
85
68
|
return `;(function(){var m = ${JSON.stringify(
|
|
86
69
|
versionMappings,
|
|
87
70
|
)}; ${globalName}.__v__ = function (s) { return m[s] || s }; })();`
|
|
88
71
|
}
|
|
89
72
|
return `
|
|
90
73
|
;(function() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
|
|
74
|
+
var __versionMappings__ = ${JSON.stringify(versionMappings, null, " ")};
|
|
75
|
+
${globalName}.__v__ = function (specifier) {
|
|
76
|
+
return __versionMappings__[specifier] || specifier
|
|
77
|
+
};
|
|
97
78
|
})();
|
|
98
|
-
|
|
99
79
|
`
|
|
100
80
|
}
|
|
81
|
+
|
|
82
|
+
export const injectVersionMappingsAsImportmap = async ({
|
|
83
|
+
urlInfo,
|
|
84
|
+
kitchen,
|
|
85
|
+
versionMappings,
|
|
86
|
+
}) => {
|
|
87
|
+
const htmlAst = parseHtmlString(urlInfo.content, {
|
|
88
|
+
storeOriginalPositions: false,
|
|
89
|
+
})
|
|
90
|
+
// jsenv_plugin_importmap.js is removing importmap during build
|
|
91
|
+
// it means at this point we know HTML has no importmap in it
|
|
92
|
+
// we can safely inject one
|
|
93
|
+
const importmapNode = createHtmlNode({
|
|
94
|
+
tagName: "script",
|
|
95
|
+
type: "importmap",
|
|
96
|
+
textContent: kitchen.kitchenContext.minification
|
|
97
|
+
? JSON.stringify({ imports: versionMappings })
|
|
98
|
+
: `
|
|
99
|
+
{
|
|
100
|
+
"imports": {${JSON.stringify(versionMappings, null, " ").slice(
|
|
101
|
+
1,
|
|
102
|
+
-1,
|
|
103
|
+
)} }
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
})
|
|
107
|
+
injectScriptNodeAsEarlyAsPossible(htmlAst, importmapNode, "jsenv:versioning")
|
|
108
|
+
kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
|
109
|
+
content: stringifyHtmlAst(htmlAst),
|
|
110
|
+
})
|
|
111
|
+
}
|
package/src/dev/file_service.js
CHANGED
|
@@ -10,6 +10,7 @@ import { URL_META } from "@jsenv/url-meta"
|
|
|
10
10
|
|
|
11
11
|
import { createUrlGraph } from "@jsenv/core/src/kitchen/url_graph.js"
|
|
12
12
|
import { createKitchen } from "@jsenv/core/src/kitchen/kitchen.js"
|
|
13
|
+
import { RUNTIME_COMPAT } from "@jsenv/core/src/kitchen/compat/runtime_compat.js"
|
|
13
14
|
import { getCorePlugins } from "@jsenv/core/src/plugins/plugins.js"
|
|
14
15
|
import { jsenvPluginServerEventsClientInjection } from "@jsenv/core/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js"
|
|
15
16
|
import { parseUserAgentHeader } from "./user_agent.js"
|
|
@@ -111,16 +112,22 @@ export const createFileService = ({
|
|
|
111
112
|
onUrlInfo(urlInfo)
|
|
112
113
|
})
|
|
113
114
|
})
|
|
115
|
+
const clientRuntimeCompat = { [runtimeName]: runtimeVersion }
|
|
114
116
|
const kitchen = createKitchen({
|
|
115
117
|
signal,
|
|
116
118
|
logLevel,
|
|
117
119
|
rootDirectoryUrl,
|
|
120
|
+
urlGraph,
|
|
118
121
|
dev: true,
|
|
119
122
|
runtimeCompat,
|
|
120
|
-
clientRuntimeCompat
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
clientRuntimeCompat,
|
|
124
|
+
systemJsTranspilation:
|
|
125
|
+
!RUNTIME_COMPAT.isSupported(
|
|
126
|
+
clientRuntimeCompat,
|
|
127
|
+
"script_type_module",
|
|
128
|
+
) ||
|
|
129
|
+
!RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_dynamic") ||
|
|
130
|
+
!RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_meta"),
|
|
124
131
|
plugins: [
|
|
125
132
|
...plugins,
|
|
126
133
|
...getCorePlugins({
|
|
@@ -141,6 +148,7 @@ export const createFileService = ({
|
|
|
141
148
|
ribbon,
|
|
142
149
|
}),
|
|
143
150
|
],
|
|
151
|
+
minification: false,
|
|
144
152
|
sourcemaps,
|
|
145
153
|
sourcemapsSourcesProtocol,
|
|
146
154
|
sourcemapsSourcesContent,
|
|
@@ -60,6 +60,7 @@ export const featuresCompatMap = {
|
|
|
60
60
|
chrome: "89",
|
|
61
61
|
opera: "76",
|
|
62
62
|
samsung: "15",
|
|
63
|
+
firefox: "108",
|
|
63
64
|
},
|
|
64
65
|
import_type_json: {
|
|
65
66
|
chrome: "91",
|
|
@@ -155,4 +156,62 @@ export const featuresCompatMap = {
|
|
|
155
156
|
android: "4",
|
|
156
157
|
node: "4",
|
|
157
158
|
},
|
|
159
|
+
arrow_function: {
|
|
160
|
+
chrome: "47",
|
|
161
|
+
opera: "34",
|
|
162
|
+
edge: "13",
|
|
163
|
+
firefox: "45",
|
|
164
|
+
safari: "10",
|
|
165
|
+
node: "6",
|
|
166
|
+
ios: "10",
|
|
167
|
+
samsung: "5",
|
|
168
|
+
electron: "0.36",
|
|
169
|
+
},
|
|
170
|
+
const_bindings: {
|
|
171
|
+
chrome: "41",
|
|
172
|
+
opera: "28",
|
|
173
|
+
edge: "12",
|
|
174
|
+
firefox: "46",
|
|
175
|
+
safari: "10",
|
|
176
|
+
node: "4",
|
|
177
|
+
ie: "11",
|
|
178
|
+
ios: "10",
|
|
179
|
+
samsung: "3.4",
|
|
180
|
+
electron: "0.22",
|
|
181
|
+
},
|
|
182
|
+
object_properties_shorthand: {
|
|
183
|
+
chrome: "43",
|
|
184
|
+
opera: "30",
|
|
185
|
+
edge: "12",
|
|
186
|
+
firefox: "33",
|
|
187
|
+
safari: "9",
|
|
188
|
+
node: "4",
|
|
189
|
+
ios: "9",
|
|
190
|
+
samsung: "4",
|
|
191
|
+
electron: "0.28",
|
|
192
|
+
},
|
|
193
|
+
reserved_words: {
|
|
194
|
+
chrome: "13",
|
|
195
|
+
opera: "10.50",
|
|
196
|
+
edge: "12",
|
|
197
|
+
firefox: "2",
|
|
198
|
+
safari: "3.1",
|
|
199
|
+
node: "0.10",
|
|
200
|
+
ie: "9",
|
|
201
|
+
android: "4.4",
|
|
202
|
+
ios: "6",
|
|
203
|
+
phantom: "2",
|
|
204
|
+
samsung: "1",
|
|
205
|
+
electron: "0.20",
|
|
206
|
+
},
|
|
207
|
+
symbols: {
|
|
208
|
+
chrome: "38",
|
|
209
|
+
opera: "25",
|
|
210
|
+
edge: "12",
|
|
211
|
+
firefox: "36",
|
|
212
|
+
safari: "9",
|
|
213
|
+
ios: "9",
|
|
214
|
+
samsung: "4",
|
|
215
|
+
node: "0.12",
|
|
216
|
+
},
|
|
158
217
|
}
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -28,14 +28,16 @@ export const createKitchen = ({
|
|
|
28
28
|
logLevel,
|
|
29
29
|
|
|
30
30
|
rootDirectoryUrl,
|
|
31
|
+
urlGraph,
|
|
31
32
|
dev = false,
|
|
32
33
|
build = false,
|
|
33
34
|
runtimeCompat,
|
|
34
35
|
// during dev/test clientRuntimeCompat is a single runtime
|
|
35
36
|
// during build clientRuntimeCompat is runtimeCompat
|
|
36
37
|
clientRuntimeCompat = runtimeCompat,
|
|
37
|
-
|
|
38
|
+
systemJsTranspilation,
|
|
38
39
|
plugins,
|
|
40
|
+
minification,
|
|
39
41
|
sourcemaps = dev ? "inline" : "none", // "programmatic" and "file" also allowed
|
|
40
42
|
sourcemapsSourcesProtocol,
|
|
41
43
|
sourcemapsSourcesContent,
|
|
@@ -53,12 +55,14 @@ export const createKitchen = ({
|
|
|
53
55
|
build,
|
|
54
56
|
runtimeCompat,
|
|
55
57
|
clientRuntimeCompat,
|
|
58
|
+
systemJsTranspilation,
|
|
56
59
|
isSupportedOnCurrentClients: (feature) => {
|
|
57
60
|
return RUNTIME_COMPAT.isSupported(clientRuntimeCompat, feature)
|
|
58
61
|
},
|
|
59
62
|
isSupportedOnFutureClients: (feature) => {
|
|
60
63
|
return RUNTIME_COMPAT.isSupported(runtimeCompat, feature)
|
|
61
64
|
},
|
|
65
|
+
minification,
|
|
62
66
|
sourcemaps,
|
|
63
67
|
outDirectoryUrl,
|
|
64
68
|
}
|