@jsenv/core 27.0.0-alpha.94 → 27.0.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/README.md +62 -0
- package/dist/js/s.js +580 -380
- package/dist/js/s.js.map +207 -0
- package/dist/main.js +4834 -457
- package/package.json +10 -10
- package/src/build/build.js +1 -1
- package/src/build/start_build_server.js +49 -46
- package/src/dev/plugins/toolbar/client/jsenv_logo.svg +59 -63
- package/src/dev/start_dev_server.js +58 -51
- package/src/omega/kitchen.js +1 -0
- package/src/omega/server/file_service.js +8 -1
- package/src/omega/url_graph.js +43 -21
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +48 -48
- package/src/plugins/plugin_controller.js +1 -0
- package/src/plugins/plugins.js +5 -0
- package/src/plugins/transpilation/as_js_classic/async-to-promises.js +3844 -0
- package/src/plugins/transpilation/as_js_classic/client/s.js +63 -54
- package/src/plugins/transpilation/as_js_classic/helpers-string.js +1 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +5 -3
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +8 -0
- package/src/test/coverage/coverage_reporter_html_directory.js +8 -12
- package/src/test/coverage/coverage_reporter_json_file.js +5 -10
- package/src/test/coverage/coverage_reporter_text_log.js +3 -3
- package/src/test/execute_plan.js +13 -14
- package/src/test/execute_test_plan.js +35 -30
- package/dist/s.js +0 -626
- package/dist/s.js.map +0 -205
- package/readme.md +0 -372
|
@@ -18,10 +18,19 @@ import {
|
|
|
18
18
|
|
|
19
19
|
export const jsenvPluginNodeEsmResolution = ({
|
|
20
20
|
rootDirectoryUrl,
|
|
21
|
+
urlGraph,
|
|
21
22
|
runtimeCompat,
|
|
22
23
|
packageConditions,
|
|
23
24
|
filesInvalidatingCache = ["package.json", "package-lock.json"],
|
|
24
25
|
}) => {
|
|
26
|
+
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node")
|
|
27
|
+
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
28
|
+
packageConditions = packageConditions || [
|
|
29
|
+
...readCustomConditionsFromProcessArgs(),
|
|
30
|
+
nodeRuntimeEnabled ? "node" : "browser",
|
|
31
|
+
"import",
|
|
32
|
+
]
|
|
33
|
+
|
|
25
34
|
const packageScopesCache = new Map()
|
|
26
35
|
const lookupPackageScope = (url) => {
|
|
27
36
|
const fromCache = packageScopesCache.get(url)
|
|
@@ -44,65 +53,63 @@ export const jsenvPluginNodeEsmResolution = ({
|
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
const unregisters = []
|
|
56
|
+
const onFileChange = () => {
|
|
57
|
+
packageScopesCache.clear()
|
|
58
|
+
packageJsonsCache.clear()
|
|
59
|
+
Object.keys(urlGraph.urlInfos).forEach((url) => {
|
|
60
|
+
const urlInfo = urlGraph.getUrlInfo(url)
|
|
61
|
+
if (urlInfo.dependsOnPackageJson) {
|
|
62
|
+
urlGraph.considerModified(urlInfo)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
47
66
|
filesInvalidatingCache.forEach((file) => {
|
|
48
67
|
const unregister = registerFileLifecycle(new URL(file, rootDirectoryUrl), {
|
|
49
68
|
added: () => {
|
|
50
|
-
|
|
51
|
-
packageJsonsCache.clear()
|
|
69
|
+
onFileChange()
|
|
52
70
|
},
|
|
53
71
|
updated: () => {
|
|
54
|
-
|
|
55
|
-
packageJsonsCache.clear()
|
|
72
|
+
onFileChange()
|
|
56
73
|
},
|
|
57
74
|
removed: () => {
|
|
58
|
-
|
|
59
|
-
packageJsonsCache.clear()
|
|
75
|
+
onFileChange()
|
|
60
76
|
},
|
|
61
77
|
keepProcessAlive: false,
|
|
62
78
|
})
|
|
63
79
|
unregisters.push(unregister)
|
|
64
80
|
})
|
|
65
81
|
|
|
66
|
-
return [
|
|
67
|
-
jsenvPluginNodeEsmResolver({
|
|
68
|
-
runtimeCompat,
|
|
69
|
-
packageConditions,
|
|
70
|
-
lookupPackageScope,
|
|
71
|
-
readPackageJson,
|
|
72
|
-
}),
|
|
73
|
-
jsenvPluginNodeModulesVersionInUrls({
|
|
74
|
-
lookupPackageScope,
|
|
75
|
-
readPackageJson,
|
|
76
|
-
}),
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const jsenvPluginNodeEsmResolver = ({
|
|
81
|
-
runtimeCompat,
|
|
82
|
-
packageConditions,
|
|
83
|
-
lookupPackageScope,
|
|
84
|
-
readPackageJson,
|
|
85
|
-
}) => {
|
|
86
|
-
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node")
|
|
87
|
-
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
88
|
-
packageConditions = packageConditions || [
|
|
89
|
-
...readCustomConditionsFromProcessArgs(),
|
|
90
|
-
nodeRuntimeEnabled ? "node" : "browser",
|
|
91
|
-
"import",
|
|
92
|
-
]
|
|
93
82
|
return {
|
|
94
|
-
name: "jsenv:
|
|
83
|
+
name: "jsenv:node_esm_resolution",
|
|
95
84
|
appliesDuring: "*",
|
|
96
85
|
resolveUrl: {
|
|
97
86
|
js_import_export: (reference) => {
|
|
98
87
|
const { parentUrl, specifier } = reference
|
|
99
|
-
const { url } = applyNodeEsmResolution({
|
|
88
|
+
const { type, url } = applyNodeEsmResolution({
|
|
100
89
|
conditions: packageConditions,
|
|
101
90
|
parentUrl,
|
|
102
91
|
specifier,
|
|
103
92
|
lookupPackageScope,
|
|
104
93
|
readPackageJson,
|
|
105
94
|
})
|
|
95
|
+
|
|
96
|
+
// this reference depend on package.json and node_modules
|
|
97
|
+
// to be resolved. Each file using this specifier
|
|
98
|
+
// must be invalidated when package.json or package_lock.json
|
|
99
|
+
// changes
|
|
100
|
+
const dependsOnPackageJson =
|
|
101
|
+
type !== "relative_specifier" &&
|
|
102
|
+
type !== "absolute_specifier" &&
|
|
103
|
+
type !== "node_builtin_specifier"
|
|
104
|
+
const relatedUrlInfos = urlGraph.getRelatedUrlInfos(reference.parentUrl)
|
|
105
|
+
relatedUrlInfos.forEach((relatedUrlInfo) => {
|
|
106
|
+
if (relatedUrlInfo.dependsOnPackageJson) {
|
|
107
|
+
// the url may depend due to an other reference
|
|
108
|
+
// in that case keep dependsOnPackageJson to true
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
relatedUrlInfo.dependsOnPackageJson = dependsOnPackageJson
|
|
112
|
+
})
|
|
106
113
|
return url
|
|
107
114
|
},
|
|
108
115
|
},
|
|
@@ -116,20 +123,10 @@ const jsenvPluginNodeEsmResolver = ({
|
|
|
116
123
|
}
|
|
117
124
|
return null
|
|
118
125
|
},
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const jsenvPluginNodeModulesVersionInUrls = ({
|
|
123
|
-
lookupPackageScope,
|
|
124
|
-
readPackageJson,
|
|
125
|
-
}) => {
|
|
126
|
-
return {
|
|
127
|
-
name: "jsenv:node_modules_version_in_urls",
|
|
128
|
-
appliesDuring: {
|
|
129
|
-
dev: true,
|
|
130
|
-
test: true,
|
|
131
|
-
},
|
|
132
126
|
transformUrlSearchParams: (reference, context) => {
|
|
127
|
+
if (context.scenario === "build") {
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
133
130
|
if (!reference.url.startsWith("file:")) {
|
|
134
131
|
return null
|
|
135
132
|
}
|
|
@@ -158,5 +155,8 @@ const jsenvPluginNodeModulesVersionInUrls = ({
|
|
|
158
155
|
v: packageVersion,
|
|
159
156
|
}
|
|
160
157
|
},
|
|
158
|
+
destroy: () => {
|
|
159
|
+
unregisters.forEach((unregister) => unregister())
|
|
160
|
+
},
|
|
161
161
|
}
|
|
162
162
|
}
|
package/src/plugins/plugins.js
CHANGED
|
@@ -45,6 +45,9 @@ export const getCorePlugins = ({
|
|
|
45
45
|
if (nodeEsmResolution === true) {
|
|
46
46
|
nodeEsmResolution = {}
|
|
47
47
|
}
|
|
48
|
+
if (clientAutoreload === true) {
|
|
49
|
+
clientAutoreload = {}
|
|
50
|
+
}
|
|
48
51
|
return [
|
|
49
52
|
jsenvPluginUrlAnalysis({ rootDirectoryUrl, ...urlAnalysis }),
|
|
50
53
|
jsenvPluginTranspilation(transpilation),
|
|
@@ -62,6 +65,7 @@ export const getCorePlugins = ({
|
|
|
62
65
|
// before url resolution to handle "js_import_export" resolution
|
|
63
66
|
jsenvPluginNodeEsmResolution({
|
|
64
67
|
rootDirectoryUrl,
|
|
68
|
+
urlGraph,
|
|
65
69
|
runtimeCompat,
|
|
66
70
|
...nodeEsmResolution,
|
|
67
71
|
}),
|
|
@@ -78,6 +82,7 @@ export const getCorePlugins = ({
|
|
|
78
82
|
...(clientAutoreload
|
|
79
83
|
? [
|
|
80
84
|
jsenvPluginAutoreload({
|
|
85
|
+
...clientAutoreload,
|
|
81
86
|
rootDirectoryUrl,
|
|
82
87
|
urlGraph,
|
|
83
88
|
scenario,
|