@jsenv/core 23.8.9 → 23.8.10
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
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
urlToMeta,
|
|
7
7
|
} from "@jsenv/filesystem"
|
|
8
8
|
|
|
9
|
+
import { featuresCompatMap } from "@jsenv/core/src/internal/generateGroupMap/featuresCompatMap.js"
|
|
10
|
+
import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
|
|
11
|
+
|
|
9
12
|
import { serverUrlToCompileInfo } from "@jsenv/core/src/internal/url_conversion.js"
|
|
10
13
|
import { setUrlExtension } from "../url_utils.js"
|
|
11
14
|
import {
|
|
@@ -52,6 +55,15 @@ export const createCompiledFileService = ({
|
|
|
52
55
|
sourcemapMethod,
|
|
53
56
|
sourcemapExcludeSources,
|
|
54
57
|
}) => {
|
|
58
|
+
const moduleFormats = {}
|
|
59
|
+
Object.keys(groupMap).forEach((groupName) => {
|
|
60
|
+
moduleFormats[groupName] = canAvoidSystemJs({
|
|
61
|
+
runtimeSupport: groupMap[groupName].minRuntimeVersions,
|
|
62
|
+
})
|
|
63
|
+
? "esmodule"
|
|
64
|
+
: "systemjs"
|
|
65
|
+
})
|
|
66
|
+
|
|
55
67
|
Object.keys(customCompilers).forEach((key) => {
|
|
56
68
|
const value = customCompilers[key]
|
|
57
69
|
if (typeof value !== "function") {
|
|
@@ -171,7 +183,10 @@ export const createCompiledFileService = ({
|
|
|
171
183
|
request,
|
|
172
184
|
|
|
173
185
|
runtimeSupport,
|
|
174
|
-
moduleOutFormat
|
|
186
|
+
moduleOutFormat:
|
|
187
|
+
moduleOutFormat === undefined
|
|
188
|
+
? moduleFormats[compileId]
|
|
189
|
+
: moduleOutFormat,
|
|
175
190
|
importMetaFormat,
|
|
176
191
|
transformTopLevelAwait,
|
|
177
192
|
babelPluginMap: babelPluginMapFromCompileId(compileId, {
|
|
@@ -189,6 +204,20 @@ export const createCompiledFileService = ({
|
|
|
189
204
|
}
|
|
190
205
|
}
|
|
191
206
|
|
|
207
|
+
const canAvoidSystemJs = ({ runtimeSupport }) => {
|
|
208
|
+
const runtimeCompatMap = createRuntimeCompat({
|
|
209
|
+
runtimeSupport,
|
|
210
|
+
pluginMap: {
|
|
211
|
+
module: true,
|
|
212
|
+
importmap: true,
|
|
213
|
+
import_assertion_type_json: true,
|
|
214
|
+
import_assertion_type_css: true,
|
|
215
|
+
},
|
|
216
|
+
pluginCompatMap: featuresCompatMap,
|
|
217
|
+
})
|
|
218
|
+
return runtimeCompatMap.pluginRequiredNameArray.length === 0
|
|
219
|
+
}
|
|
220
|
+
|
|
192
221
|
const getCompiler = ({ originalFileUrl, compileMeta }) => {
|
|
193
222
|
const { jsenvCompiler, customCompiler } = urlToMeta({
|
|
194
223
|
url: originalFileUrl,
|
|
@@ -29,12 +29,10 @@ import {
|
|
|
29
29
|
createCallbackListNotifiedOnce,
|
|
30
30
|
} from "@jsenv/abort"
|
|
31
31
|
|
|
32
|
+
import { generateGroupMap } from "@jsenv/core/src/internal/generateGroupMap/generateGroupMap.js"
|
|
32
33
|
import { isBrowserPartOfSupportedRuntimes } from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
|
|
33
34
|
import { loadBabelPluginMapFromFile } from "./load_babel_plugin_map_from_file.js"
|
|
34
35
|
import { extractSyntaxBabelPluginMap } from "./babel_plugins.js"
|
|
35
|
-
import { generateGroupMap } from "../generateGroupMap/generateGroupMap.js"
|
|
36
|
-
import { featuresCompatMap } from "@jsenv/core/src/internal/generateGroupMap/featuresCompatMap.js"
|
|
37
|
-
import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
|
|
38
36
|
import {
|
|
39
37
|
jsenvCompileProxyFileInfo,
|
|
40
38
|
sourcemapMainFileInfo,
|
|
@@ -221,15 +219,6 @@ export const startCompileServer = async ({
|
|
|
221
219
|
...babelPluginMap,
|
|
222
220
|
}
|
|
223
221
|
|
|
224
|
-
if (moduleOutFormat === undefined) {
|
|
225
|
-
moduleOutFormat = canAvoidSystemJs({ runtimeSupport })
|
|
226
|
-
? "esmodule"
|
|
227
|
-
: "systemjs"
|
|
228
|
-
}
|
|
229
|
-
if (importMetaFormat === undefined) {
|
|
230
|
-
importMetaFormat = moduleOutFormat
|
|
231
|
-
}
|
|
232
|
-
|
|
233
222
|
const serverStopCallbackList = createCallbackListNotifiedOnce()
|
|
234
223
|
|
|
235
224
|
let projectFileRequestedCallback = () => {}
|
|
@@ -1060,20 +1049,6 @@ const createCompileProxyService = ({ projectDirectoryUrl }) => {
|
|
|
1060
1049
|
}
|
|
1061
1050
|
}
|
|
1062
1051
|
|
|
1063
|
-
const canAvoidSystemJs = ({ runtimeSupport }) => {
|
|
1064
|
-
const runtimeCompatMap = createRuntimeCompat({
|
|
1065
|
-
runtimeSupport,
|
|
1066
|
-
pluginMap: {
|
|
1067
|
-
module: true,
|
|
1068
|
-
importmap: true,
|
|
1069
|
-
import_assertion_type_json: true,
|
|
1070
|
-
import_assertion_type_css: true,
|
|
1071
|
-
},
|
|
1072
|
-
pluginCompatMap: featuresCompatMap,
|
|
1073
|
-
})
|
|
1074
|
-
return runtimeCompatMap.pluginRequiredNameArray.length === 0
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
1052
|
const readPackage = (packagePath) => {
|
|
1078
1053
|
const buffer = readFileSync(packagePath)
|
|
1079
1054
|
const string = String(buffer)
|
|
@@ -7,22 +7,30 @@ export const createRuntimeCompat = ({
|
|
|
7
7
|
}) => {
|
|
8
8
|
const minRuntimeVersions = {}
|
|
9
9
|
const pluginRequiredNameArray = []
|
|
10
|
-
Object.keys(runtimeSupport)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
pluginMap,
|
|
16
|
-
pluginCompatMap,
|
|
10
|
+
const runtimeNames = Object.keys(runtimeSupport)
|
|
11
|
+
if (runtimeNames.length === 0) {
|
|
12
|
+
// when runtimes are unknown, everything is required
|
|
13
|
+
Object.keys(pluginMap).forEach((pluginName) => {
|
|
14
|
+
pluginRequiredNameArray.push(pluginName)
|
|
17
15
|
})
|
|
16
|
+
} else {
|
|
17
|
+
runtimeNames.forEach((runtimeName) => {
|
|
18
|
+
const runtimeVersion = runtimeSupport[runtimeName]
|
|
19
|
+
const oneRuntimeCompat = createOneRuntimeCompat({
|
|
20
|
+
runtimeName,
|
|
21
|
+
runtimeVersion,
|
|
22
|
+
pluginMap,
|
|
23
|
+
pluginCompatMap,
|
|
24
|
+
})
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
minRuntimeVersions[runtimeName] = oneRuntimeCompat.minRuntimeVersion
|
|
27
|
+
oneRuntimeCompat.pluginRequiredNameArray.forEach((babelPluginName) => {
|
|
28
|
+
if (!pluginRequiredNameArray.includes(babelPluginName)) {
|
|
29
|
+
pluginRequiredNameArray.push(babelPluginName)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
24
32
|
})
|
|
25
|
-
}
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
return {
|
|
28
36
|
pluginRequiredNameArray,
|