@jsenv/core 25.3.0-alpha.0 → 25.4.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 -2
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
- package/dist/build_manifest.js +5 -5
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/compile_proxy.html__inline__20_f4285042.js.map +343 -0
- package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_ab528227.html} +358 -397
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/redirector.html__inline__12_404b8295.js.map +349 -0
- package/dist/redirector/{redirector_3e9a97b9.html → redirector_6df2620a.html} +369 -407
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/toolbar.main_279b3a68.js.map +764 -0
- package/dist/toolbar/{toolbar_361afb84.html → toolbar_0a91ca3b.html} +1509 -1583
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/{toolbar_injector_fac1e995.js → toolbar_injector_34f6ad8e.js} +18 -15
- package/dist/toolbar_injector/{toolbar_injector_fac1e995.js.map → toolbar_injector_34f6ad8e.js.map} +15 -15
- package/package.json +10 -10
- package/src/buildProject.js +31 -26
- package/src/dev_server.js +111 -92
- package/src/execute.js +3 -8
- package/src/importUsingChildProcess.js +1 -0
- package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
- package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
- package/src/internal/browser_launcher/from_playwright.js +6 -4
- package/src/internal/browser_runtime/browser_runtime.js +12 -14
- package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
- package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
- package/src/internal/browser_utils/fetchJson.js +1 -1
- package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
- package/src/internal/building/buildUsingRollup.js +41 -57
- package/src/internal/building/rollup_plugin_jsenv.js +28 -8
- package/src/internal/compiling/babel_parse_error.js +9 -0
- package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +53 -36
- package/src/internal/compiling/compileFile.js +2 -2
- package/src/internal/compiling/compileHtml.js +1 -1
- package/src/internal/compiling/createCompiledFileService.js +25 -74
- package/src/internal/compiling/js-compilation-service/transformJs.js +151 -23
- package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
- package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
- package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
- package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
- package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
- package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
- package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
- package/src/internal/compiling/sse_service/sse_service.js +369 -0
- package/src/internal/compiling/startCompileServer.js +157 -804
- package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
- package/src/internal/dev_server/exploring/exploring.js +10 -8
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +92 -78
- package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
- package/src/internal/dev_server/toolbar/toolbar.html +46 -16
- package/src/internal/dev_server/toolbar/toolbar.injector.js +17 -15
- package/src/internal/dev_server/toolbar/toolbar.main.js +12 -16
- package/src/internal/executing/executeConcurrently.js +1 -1
- package/src/internal/executing/executePlan.js +2 -3
- package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
- package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detection.js +89 -0
- package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
- package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
- package/src/internal/features/features_compat_from_runtime.js +38 -0
- package/src/internal/features/features_compat_from_runtime_support.js +31 -0
- package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
- package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
- package/src/internal/node_launcher/createControllableNodeProcess.js +4 -6
- package/src/internal/node_launcher/node_runtime_report.js +15 -9
- package/src/internal/node_runtime/fetchSource.js +2 -4
- package/src/internal/node_runtime/nodeControllableFile.mjs +1 -5
- package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
- package/src/internal/redirector/redirector.html +40 -0
- package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
- package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
- package/src/internal/url_conversion.js +12 -17
- package/src/launchNode.js +29 -41
- package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
- package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
- package/dist/toolbar/toolbar.main_6c1b3d82.js.map +0 -802
- package/src/internal/CONSTANTS.js +0 -11
- package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
- package/src/internal/dev_server/redirector/redirector.html +0 -48
- package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
- package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
- package/src/internal/generateGroupMap/runtime_compat.js +0 -34
- package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
- package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
- package/src/internal/node_runtime/detectNode.js +0 -3
- package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
- package/src/internal/runtime/resolveGroup.js +0 -13
- package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
package/src/dev_server.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { setupRoutes } from "@jsenv/server"
|
|
1
2
|
import {
|
|
2
3
|
normalizeStructuredMetaMap,
|
|
3
4
|
collectFiles,
|
|
4
5
|
urlToRelativeUrl,
|
|
5
6
|
} from "@jsenv/filesystem"
|
|
6
|
-
import { setupRoutes } from "@jsenv/server"
|
|
7
7
|
|
|
8
8
|
import { REDIRECTOR_BUILD_URL } from "@jsenv/core/dist/build_manifest.js"
|
|
9
|
+
import { setUrlSearchParamsDescriptor } from "@jsenv/core/src/internal/url_utils.js"
|
|
9
10
|
import { jsenvCoreDirectoryUrl } from "./internal/jsenvCoreDirectoryUrl.js"
|
|
10
11
|
import {
|
|
11
12
|
assertProjectDirectoryUrl,
|
|
@@ -13,14 +14,13 @@ import {
|
|
|
13
14
|
} from "./internal/argUtils.js"
|
|
14
15
|
import {
|
|
15
16
|
startCompileServer,
|
|
16
|
-
|
|
17
|
+
assertAndNormalizeJsenvDirectoryRelativeUrl,
|
|
17
18
|
} from "./internal/compiling/startCompileServer.js"
|
|
18
|
-
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
19
|
-
|
|
20
19
|
import {
|
|
21
20
|
sourcemapMainFileInfo,
|
|
22
21
|
sourcemapMappingFileInfo,
|
|
23
22
|
} from "./internal/jsenvInternalFiles.js"
|
|
23
|
+
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
24
24
|
|
|
25
25
|
export const startDevServer = async ({
|
|
26
26
|
signal = new AbortController().signal,
|
|
@@ -28,7 +28,7 @@ export const startDevServer = async ({
|
|
|
28
28
|
port,
|
|
29
29
|
ip,
|
|
30
30
|
protocol,
|
|
31
|
-
http2,
|
|
31
|
+
http2 = false, // disable by default for now because it is buggy on safari
|
|
32
32
|
certificate,
|
|
33
33
|
privateKey,
|
|
34
34
|
plugins,
|
|
@@ -38,7 +38,6 @@ export const startDevServer = async ({
|
|
|
38
38
|
explorableConfig = jsenvExplorableConfig,
|
|
39
39
|
mainFileRelativeUrl,
|
|
40
40
|
jsenvDirectoryRelativeUrl,
|
|
41
|
-
outDirectoryName = "dev",
|
|
42
41
|
jsenvToolbar = true,
|
|
43
42
|
livereloading = true,
|
|
44
43
|
inlineImportMapIntoHTML = true,
|
|
@@ -66,7 +65,6 @@ export const startDevServer = async ({
|
|
|
66
65
|
}) => {
|
|
67
66
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
68
67
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
69
|
-
|
|
70
68
|
if (mainFileRelativeUrl === undefined) {
|
|
71
69
|
mainFileRelativeUrl = urlToRelativeUrl(
|
|
72
70
|
new URL(
|
|
@@ -76,13 +74,10 @@ export const startDevServer = async ({
|
|
|
76
74
|
projectDirectoryUrl,
|
|
77
75
|
)
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
|
|
77
|
+
jsenvDirectoryRelativeUrl = assertAndNormalizeJsenvDirectoryRelativeUrl({
|
|
81
78
|
projectDirectoryUrl,
|
|
82
79
|
jsenvDirectoryRelativeUrl,
|
|
83
|
-
outDirectoryName,
|
|
84
80
|
})
|
|
85
|
-
|
|
86
81
|
const compileServer = await startCompileServer({
|
|
87
82
|
signal,
|
|
88
83
|
handleSIGINT,
|
|
@@ -103,14 +98,14 @@ export const startDevServer = async ({
|
|
|
103
98
|
}),
|
|
104
99
|
"jsenv:exploring_json": createExploringJsonService({
|
|
105
100
|
projectDirectoryUrl,
|
|
106
|
-
|
|
101
|
+
jsenvDirectoryRelativeUrl,
|
|
107
102
|
mainFileRelativeUrl,
|
|
108
103
|
explorableConfig,
|
|
109
104
|
livereloading,
|
|
110
105
|
}),
|
|
111
106
|
"jsenv:explorables_json": createExplorableJsonService({
|
|
112
107
|
projectDirectoryUrl,
|
|
113
|
-
|
|
108
|
+
jsenvDirectoryRelativeUrl,
|
|
114
109
|
explorableConfig,
|
|
115
110
|
}),
|
|
116
111
|
},
|
|
@@ -120,7 +115,6 @@ export const startDevServer = async ({
|
|
|
120
115
|
jsenvEventSourceClientInjection: true,
|
|
121
116
|
jsenvToolbarInjection: jsenvToolbar,
|
|
122
117
|
jsenvDirectoryRelativeUrl,
|
|
123
|
-
outDirectoryName,
|
|
124
118
|
inlineImportMapIntoHTML,
|
|
125
119
|
|
|
126
120
|
compileServerCanReadFromFilesystem,
|
|
@@ -155,20 +149,45 @@ const createRedirectorService = async ({
|
|
|
155
149
|
return {
|
|
156
150
|
status: 307,
|
|
157
151
|
headers: {
|
|
158
|
-
location:
|
|
152
|
+
location: setUrlSearchParamsDescriptor(
|
|
153
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
154
|
+
{
|
|
155
|
+
redirect: redirectTarget,
|
|
156
|
+
},
|
|
157
|
+
),
|
|
159
158
|
},
|
|
160
159
|
}
|
|
161
160
|
},
|
|
161
|
+
// compile server (compiled file service to be precised)
|
|
162
|
+
// is already implementing this redirection when a compile id do not exists
|
|
163
|
+
// and "redirect" is not a valid compile id
|
|
164
|
+
// That being said I prefer to keep it to be explicit and shortcircuit the logic
|
|
162
165
|
"/.jsenv/redirect/:rest*": (request) => {
|
|
163
166
|
const redirectTarget = request.ressource.slice("/.jsenv/redirect/".length)
|
|
164
167
|
return {
|
|
165
168
|
status: 307,
|
|
166
169
|
headers: {
|
|
167
|
-
location:
|
|
168
|
-
request.origin
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
location: setUrlSearchParamsDescriptor(
|
|
171
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
172
|
+
{
|
|
173
|
+
redirect: redirectTarget,
|
|
174
|
+
},
|
|
175
|
+
),
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"/.jsenv/force/:rest*": (request) => {
|
|
180
|
+
const redirectTarget = request.ressource.slice("/.jsenv/force/".length)
|
|
181
|
+
return {
|
|
182
|
+
status: 307,
|
|
183
|
+
headers: {
|
|
184
|
+
location: setUrlSearchParamsDescriptor(
|
|
185
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
186
|
+
{
|
|
187
|
+
redirect: redirectTarget,
|
|
188
|
+
force_compilation: 1,
|
|
189
|
+
},
|
|
190
|
+
),
|
|
172
191
|
},
|
|
173
192
|
}
|
|
174
193
|
},
|
|
@@ -177,98 +196,98 @@ const createRedirectorService = async ({
|
|
|
177
196
|
|
|
178
197
|
const createExploringJsonService = ({
|
|
179
198
|
projectDirectoryUrl,
|
|
180
|
-
|
|
199
|
+
jsenvDirectoryRelativeUrl,
|
|
181
200
|
explorableConfig,
|
|
182
201
|
livereloading,
|
|
183
202
|
mainFileRelativeUrl,
|
|
184
203
|
}) => {
|
|
185
204
|
return (request) => {
|
|
186
205
|
if (
|
|
187
|
-
request.ressource
|
|
188
|
-
request.method
|
|
206
|
+
request.ressource !== "/.jsenv/exploring.json" ||
|
|
207
|
+
request.method !== "GET"
|
|
189
208
|
) {
|
|
190
|
-
|
|
209
|
+
return null
|
|
210
|
+
}
|
|
211
|
+
const data = {
|
|
212
|
+
projectDirectoryUrl,
|
|
213
|
+
jsenvDirectoryRelativeUrl,
|
|
214
|
+
jsenvCoreDirectoryRelativeUrl: urlToRelativeUrl(
|
|
215
|
+
jsenvCoreDirectoryUrl,
|
|
191
216
|
projectDirectoryUrl,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
"content-type": "application/json",
|
|
215
|
-
"content-length": Buffer.byteLength(json),
|
|
216
|
-
},
|
|
217
|
-
body: json,
|
|
218
|
-
}
|
|
217
|
+
),
|
|
218
|
+
exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
|
|
219
|
+
sourcemapMainFileRelativeUrl: urlToRelativeUrl(
|
|
220
|
+
sourcemapMainFileInfo.url,
|
|
221
|
+
jsenvCoreDirectoryUrl,
|
|
222
|
+
),
|
|
223
|
+
sourcemapMappingFileRelativeUrl: urlToRelativeUrl(
|
|
224
|
+
sourcemapMappingFileInfo.url,
|
|
225
|
+
jsenvCoreDirectoryUrl,
|
|
226
|
+
),
|
|
227
|
+
explorableConfig,
|
|
228
|
+
livereloading,
|
|
229
|
+
}
|
|
230
|
+
const json = JSON.stringify(data)
|
|
231
|
+
return {
|
|
232
|
+
status: 200,
|
|
233
|
+
headers: {
|
|
234
|
+
"cache-control": "no-store",
|
|
235
|
+
"content-type": "application/json",
|
|
236
|
+
"content-length": Buffer.byteLength(json),
|
|
237
|
+
},
|
|
238
|
+
body: json,
|
|
219
239
|
}
|
|
220
|
-
return null
|
|
221
240
|
}
|
|
222
241
|
}
|
|
223
242
|
|
|
224
243
|
const createExplorableJsonService = ({
|
|
225
244
|
projectDirectoryUrl,
|
|
226
|
-
|
|
245
|
+
jsenvDirectoryRelativeUrl,
|
|
227
246
|
explorableConfig,
|
|
228
247
|
}) => {
|
|
229
248
|
return async (request) => {
|
|
230
249
|
if (
|
|
231
|
-
request.ressource
|
|
232
|
-
request.method
|
|
250
|
+
request.ressource !== "/.jsenv/explorables.json" ||
|
|
251
|
+
request.method !== "GET"
|
|
233
252
|
) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
244
|
-
structuredMetaMapRelativeForExplorable,
|
|
245
|
-
projectDirectoryUrl,
|
|
246
|
-
)
|
|
247
|
-
const matchingFileResultArray = await collectFiles({
|
|
248
|
-
directoryUrl: projectDirectoryUrl,
|
|
249
|
-
structuredMetaMap: structuredMetaMapForExplorable,
|
|
250
|
-
predicate: (meta) =>
|
|
251
|
-
Object.keys(meta).some((explorableGroup) =>
|
|
252
|
-
Boolean(meta[explorableGroup]),
|
|
253
|
-
),
|
|
254
|
-
})
|
|
255
|
-
const explorableFiles = matchingFileResultArray.map(
|
|
256
|
-
({ relativeUrl, meta }) => ({
|
|
257
|
-
relativeUrl,
|
|
258
|
-
meta,
|
|
259
|
-
}),
|
|
260
|
-
)
|
|
261
|
-
const json = JSON.stringify(explorableFiles)
|
|
262
|
-
return {
|
|
263
|
-
status: 200,
|
|
264
|
-
headers: {
|
|
265
|
-
"cache-control": "no-store",
|
|
266
|
-
"content-type": "application/json",
|
|
267
|
-
"content-length": Buffer.byteLength(json),
|
|
268
|
-
},
|
|
269
|
-
body: json,
|
|
253
|
+
return null
|
|
254
|
+
}
|
|
255
|
+
const structuredMetaMapRelativeForExplorable = {}
|
|
256
|
+
Object.keys(explorableConfig).forEach((explorableGroup) => {
|
|
257
|
+
const explorableGroupConfig = explorableConfig[explorableGroup]
|
|
258
|
+
structuredMetaMapRelativeForExplorable[explorableGroup] = {
|
|
259
|
+
"**/.jsenv/": false, // temporary (in theory) to avoid visting .jsenv directory in jsenv itself
|
|
260
|
+
...explorableGroupConfig,
|
|
261
|
+
[jsenvDirectoryRelativeUrl]: false,
|
|
270
262
|
}
|
|
263
|
+
})
|
|
264
|
+
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
265
|
+
structuredMetaMapRelativeForExplorable,
|
|
266
|
+
projectDirectoryUrl,
|
|
267
|
+
)
|
|
268
|
+
const matchingFileResultArray = await collectFiles({
|
|
269
|
+
directoryUrl: projectDirectoryUrl,
|
|
270
|
+
structuredMetaMap: structuredMetaMapForExplorable,
|
|
271
|
+
predicate: (meta) =>
|
|
272
|
+
Object.keys(meta).some((explorableGroup) =>
|
|
273
|
+
Boolean(meta[explorableGroup]),
|
|
274
|
+
),
|
|
275
|
+
})
|
|
276
|
+
const explorableFiles = matchingFileResultArray.map(
|
|
277
|
+
({ relativeUrl, meta }) => ({
|
|
278
|
+
relativeUrl,
|
|
279
|
+
meta,
|
|
280
|
+
}),
|
|
281
|
+
)
|
|
282
|
+
const json = JSON.stringify(explorableFiles)
|
|
283
|
+
return {
|
|
284
|
+
status: 200,
|
|
285
|
+
headers: {
|
|
286
|
+
"cache-control": "no-store",
|
|
287
|
+
"content-type": "application/json",
|
|
288
|
+
"content-length": Buffer.byteLength(json),
|
|
289
|
+
},
|
|
290
|
+
body: json,
|
|
271
291
|
}
|
|
272
|
-
return null
|
|
273
292
|
}
|
|
274
293
|
}
|
package/src/execute.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
2
2
|
|
|
3
|
-
import { normalizeRuntimeSupport } from "@jsenv/core/src/internal/
|
|
3
|
+
import { normalizeRuntimeSupport } from "@jsenv/core/src/internal/runtime_support/runtime_support.js"
|
|
4
4
|
import {
|
|
5
5
|
assertProjectDirectoryUrl,
|
|
6
6
|
assertProjectDirectoryExists,
|
|
@@ -61,14 +61,12 @@ export const execute = async ({
|
|
|
61
61
|
}) => {
|
|
62
62
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
63
63
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
64
|
-
|
|
65
64
|
if (typeof fileRelativeUrl !== "string") {
|
|
66
65
|
throw new TypeError(
|
|
67
66
|
`fileRelativeUrl must be a string, got ${fileRelativeUrl}`,
|
|
68
67
|
)
|
|
69
68
|
}
|
|
70
69
|
fileRelativeUrl = fileRelativeUrl.replace(/\\/g, "/")
|
|
71
|
-
|
|
72
70
|
if (typeof runtime !== "object") {
|
|
73
71
|
throw new TypeError(`runtime must be an object, got ${runtime}`)
|
|
74
72
|
}
|
|
@@ -77,7 +75,6 @@ export const execute = async ({
|
|
|
77
75
|
`runtime.launch must be a function, got ${runtime.launch}`,
|
|
78
76
|
)
|
|
79
77
|
}
|
|
80
|
-
|
|
81
78
|
const executeOperation = Abort.startOperation()
|
|
82
79
|
executeOperation.addAbortSignal(signal)
|
|
83
80
|
if (handleSIGINT) {
|
|
@@ -90,7 +87,6 @@ export const execute = async ({
|
|
|
90
87
|
)
|
|
91
88
|
})
|
|
92
89
|
}
|
|
93
|
-
|
|
94
90
|
try {
|
|
95
91
|
const compileServer = await startCompileServer({
|
|
96
92
|
signal: executeOperation.signal,
|
|
@@ -99,7 +95,6 @@ export const execute = async ({
|
|
|
99
95
|
projectDirectoryUrl,
|
|
100
96
|
jsenvDirectoryRelativeUrl,
|
|
101
97
|
jsenvDirectoryClean,
|
|
102
|
-
outDirectoryName: "dev",
|
|
103
98
|
|
|
104
99
|
importDefaultExtension,
|
|
105
100
|
|
|
@@ -133,7 +128,7 @@ export const execute = async ({
|
|
|
133
128
|
projectDirectoryUrl,
|
|
134
129
|
compileServerOrigin: compileServer.origin,
|
|
135
130
|
compileServerId: compileServer.id,
|
|
136
|
-
|
|
131
|
+
jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
|
|
137
132
|
...runtimeParams,
|
|
138
133
|
},
|
|
139
134
|
executeParams: {
|
|
@@ -161,7 +156,7 @@ export const execute = async ({
|
|
|
161
156
|
|
|
162
157
|
if (collectCompileServerInfo) {
|
|
163
158
|
result.compileServerOrigin = compileServer.origin
|
|
164
|
-
result.
|
|
159
|
+
result.jsenvDirectoryRelativeUrl = compileServer.jsenvDirectoryRelativeUrl
|
|
165
160
|
}
|
|
166
161
|
|
|
167
162
|
if (result.status === "errored") {
|
package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js}
RENAMED
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getBrowserRuntimeProfile = async ({
|
|
2
2
|
page,
|
|
3
|
-
coverageHandledFromOutside,
|
|
4
3
|
runtime,
|
|
5
4
|
compileServerId,
|
|
5
|
+
coverageHandledFromOutside,
|
|
6
|
+
forceSource,
|
|
7
|
+
forceCompilation,
|
|
6
8
|
}) => {
|
|
7
9
|
const cache = cacheFromParams({
|
|
8
10
|
runtime,
|
|
9
11
|
compileServerId,
|
|
10
12
|
coverageHandledFromOutside,
|
|
13
|
+
forceSource,
|
|
14
|
+
forceCompilation,
|
|
11
15
|
})
|
|
12
16
|
const entry = cache.read()
|
|
13
17
|
if (entry) {
|
|
14
18
|
return entry
|
|
15
19
|
}
|
|
16
|
-
const
|
|
20
|
+
const browserRuntimeProfile = await page.evaluate(
|
|
21
|
+
/* eslint-disable no-undef */
|
|
17
22
|
/* istanbul ignore next */
|
|
18
|
-
async ({ coverageHandledFromOutside }) => {
|
|
19
|
-
// eslint-disable-next-line no-undef
|
|
23
|
+
async ({ coverageHandledFromOutside, forceSource, forceCompilation }) => {
|
|
20
24
|
await window.readyPromise
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-undef
|
|
23
|
-
return window.scanBrowserRuntimeFeatures({
|
|
25
|
+
const runtimeProfile = await window.scanBrowserRuntimeFeatures({
|
|
24
26
|
coverageHandledFromOutside,
|
|
25
|
-
|
|
27
|
+
forceSource,
|
|
28
|
+
forceCompilation,
|
|
26
29
|
})
|
|
30
|
+
return runtimeProfile
|
|
27
31
|
},
|
|
28
|
-
|
|
32
|
+
/* eslint-enable no-undef */
|
|
33
|
+
{ coverageHandledFromOutside, forceSource, forceCompilation },
|
|
29
34
|
)
|
|
30
|
-
cache.write(
|
|
31
|
-
return
|
|
35
|
+
cache.write(browserRuntimeProfile)
|
|
36
|
+
return browserRuntimeProfile
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
let currentCacheParams
|
|
@@ -37,13 +42,16 @@ const cacheFromParams = ({
|
|
|
37
42
|
runtime,
|
|
38
43
|
compileServerId,
|
|
39
44
|
coverageHandledFromOutside,
|
|
45
|
+
forceSource,
|
|
46
|
+
forceCompilation,
|
|
40
47
|
}) => {
|
|
41
48
|
const params = {
|
|
42
49
|
compileServerId,
|
|
43
50
|
coverageHandledFromOutside,
|
|
51
|
+
forceSource,
|
|
52
|
+
forceCompilation,
|
|
44
53
|
}
|
|
45
54
|
const runtimeLabel = `${runtime.name}/${runtime.version}`
|
|
46
|
-
|
|
47
55
|
if (!currentCacheParams) {
|
|
48
56
|
currentCacheParams = params
|
|
49
57
|
currentCacheValue = {}
|
|
@@ -54,7 +62,6 @@ const cacheFromParams = ({
|
|
|
54
62
|
},
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
|
|
58
65
|
if (JSON.stringify(currentCacheParams) !== JSON.stringify(params)) {
|
|
59
66
|
return {
|
|
60
67
|
read: () => null,
|
|
@@ -65,7 +72,6 @@ const cacheFromParams = ({
|
|
|
65
72
|
},
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
|
-
|
|
69
75
|
return {
|
|
70
76
|
read: () => currentCacheValue[runtimeLabel],
|
|
71
77
|
write: (value) => {
|
|
@@ -10,7 +10,7 @@ import { filterV8Coverage } from "@jsenv/core/src/internal/executing/coverage_ut
|
|
|
10
10
|
import { composeTwoFileByFileIstanbulCoverages } from "@jsenv/core/src/internal/executing/coverage_utils/istanbul_coverage_composition.js"
|
|
11
11
|
import { evalSource } from "../node_runtime/evalSource.js"
|
|
12
12
|
import { escapeRegexpSpecialCharacters } from "../escapeRegexpSpecialCharacters.js"
|
|
13
|
-
import {
|
|
13
|
+
import { getBrowserRuntimeProfile } from "./browser_runtime_profile.js"
|
|
14
14
|
|
|
15
15
|
export const executeHtmlFile = async (
|
|
16
16
|
fileRelativeUrl,
|
|
@@ -20,7 +20,7 @@ export const executeHtmlFile = async (
|
|
|
20
20
|
projectDirectoryUrl,
|
|
21
21
|
compileServerOrigin,
|
|
22
22
|
compileServerId,
|
|
23
|
-
|
|
23
|
+
jsenvDirectoryRelativeUrl,
|
|
24
24
|
page,
|
|
25
25
|
|
|
26
26
|
// measurePerformance,
|
|
@@ -30,6 +30,7 @@ export const executeHtmlFile = async (
|
|
|
30
30
|
coverageForceIstanbul,
|
|
31
31
|
coveragePlaywrightAPIAvailable,
|
|
32
32
|
transformErrorHook,
|
|
33
|
+
forceSource,
|
|
33
34
|
forceCompilation,
|
|
34
35
|
},
|
|
35
36
|
) => {
|
|
@@ -56,36 +57,42 @@ export const executeHtmlFile = async (
|
|
|
56
57
|
|
|
57
58
|
const coverageHandledFromOutside =
|
|
58
59
|
coveragePlaywrightAPIAvailable && !coverageForceIstanbul
|
|
59
|
-
const
|
|
60
|
+
const browserRuntimeProfile = await getBrowserRuntimeProfile({
|
|
60
61
|
page,
|
|
61
|
-
coverageHandledFromOutside,
|
|
62
62
|
compileServerId,
|
|
63
63
|
runtime,
|
|
64
|
+
// js coverage
|
|
65
|
+
// When instrumentation CAN be handed by playwright
|
|
66
|
+
// https://playwright.dev/docs/api/class-chromiumcoverage#chromiumcoveragestartjscoverageoptions
|
|
67
|
+
// coverageHandledFromOutside is true and "transform-instrument" becomes non mandatory
|
|
68
|
+
coverageHandledFromOutside,
|
|
69
|
+
forceSource,
|
|
70
|
+
forceCompilation,
|
|
64
71
|
})
|
|
65
72
|
|
|
66
73
|
try {
|
|
67
74
|
let executionResult
|
|
68
|
-
const {
|
|
75
|
+
const { compileId } = browserRuntimeProfile
|
|
69
76
|
executeOperation.throwIfAborted()
|
|
70
|
-
if (
|
|
71
|
-
executionResult = await
|
|
77
|
+
if (compileId) {
|
|
78
|
+
executionResult = await executeCompiledVersion({
|
|
72
79
|
projectDirectoryUrl,
|
|
73
80
|
compileServerOrigin,
|
|
74
81
|
fileRelativeUrl,
|
|
75
82
|
page,
|
|
83
|
+
jsenvDirectoryRelativeUrl,
|
|
84
|
+
compileId,
|
|
76
85
|
collectCoverage,
|
|
77
|
-
coverageIgnorePredicate,
|
|
78
86
|
transformErrorHook,
|
|
79
87
|
})
|
|
80
88
|
} else {
|
|
81
|
-
executionResult = await
|
|
89
|
+
executionResult = await executeSource({
|
|
82
90
|
projectDirectoryUrl,
|
|
83
91
|
compileServerOrigin,
|
|
84
92
|
fileRelativeUrl,
|
|
85
93
|
page,
|
|
86
|
-
outDirectoryRelativeUrl,
|
|
87
|
-
compileId,
|
|
88
94
|
collectCoverage,
|
|
95
|
+
coverageIgnorePredicate,
|
|
89
96
|
transformErrorHook,
|
|
90
97
|
})
|
|
91
98
|
}
|
|
@@ -238,7 +245,7 @@ const executeCompiledVersion = async ({
|
|
|
238
245
|
compileServerOrigin,
|
|
239
246
|
fileRelativeUrl,
|
|
240
247
|
page,
|
|
241
|
-
|
|
248
|
+
jsenvDirectoryRelativeUrl,
|
|
242
249
|
compileId,
|
|
243
250
|
collectCoverage,
|
|
244
251
|
transformErrorHook,
|
|
@@ -259,7 +266,7 @@ const executeCompiledVersion = async ({
|
|
|
259
266
|
})
|
|
260
267
|
}
|
|
261
268
|
|
|
262
|
-
const compileDirectoryRelativeUrl = `${
|
|
269
|
+
const compileDirectoryRelativeUrl = `${jsenvDirectoryRelativeUrl}${compileId}/`
|
|
263
270
|
const compileDirectoryRemoteUrl = resolveUrl(
|
|
264
271
|
compileDirectoryRelativeUrl,
|
|
265
272
|
compileServerOrigin,
|
|
@@ -268,11 +275,12 @@ const executeCompiledVersion = async ({
|
|
|
268
275
|
await page.goto(fileClientUrl, { timeout: 0 })
|
|
269
276
|
|
|
270
277
|
const executionResult = await page.evaluate(
|
|
278
|
+
/* eslint-disable no-undef */
|
|
271
279
|
/* istanbul ignore next */
|
|
272
280
|
() => {
|
|
273
|
-
// eslint-disable-next-line no-undef
|
|
274
281
|
return window.__jsenv__.executionResultPromise
|
|
275
282
|
},
|
|
283
|
+
/* eslint-enable no-undef */
|
|
276
284
|
)
|
|
277
285
|
|
|
278
286
|
const { fileExecutionResultMap } = executionResult
|
|
@@ -33,7 +33,8 @@ export const createRuntimeFromPlaywright = ({
|
|
|
33
33
|
|
|
34
34
|
projectDirectoryUrl,
|
|
35
35
|
compileServerOrigin,
|
|
36
|
-
|
|
36
|
+
compileServerId,
|
|
37
|
+
jsenvDirectoryRelativeUrl,
|
|
37
38
|
|
|
38
39
|
collectPerformance,
|
|
39
40
|
measurePerformance,
|
|
@@ -130,7 +131,8 @@ export const createRuntimeFromPlaywright = ({
|
|
|
130
131
|
|
|
131
132
|
projectDirectoryUrl,
|
|
132
133
|
compileServerOrigin,
|
|
133
|
-
|
|
134
|
+
compileServerId,
|
|
135
|
+
jsenvDirectoryRelativeUrl,
|
|
134
136
|
|
|
135
137
|
collectPerformance,
|
|
136
138
|
measurePerformance,
|
|
@@ -264,7 +266,7 @@ const createExecuteHook = ({
|
|
|
264
266
|
projectDirectoryUrl,
|
|
265
267
|
compileServerOrigin,
|
|
266
268
|
compileServerId,
|
|
267
|
-
|
|
269
|
+
jsenvDirectoryRelativeUrl,
|
|
268
270
|
|
|
269
271
|
collectPerformance,
|
|
270
272
|
measurePerformance,
|
|
@@ -287,7 +289,7 @@ const createExecuteHook = ({
|
|
|
287
289
|
projectDirectoryUrl,
|
|
288
290
|
compileServerOrigin,
|
|
289
291
|
compileServerId,
|
|
290
|
-
|
|
292
|
+
jsenvDirectoryRelativeUrl,
|
|
291
293
|
|
|
292
294
|
page,
|
|
293
295
|
measurePerformance,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
|
|
3
3
|
import { installBrowserErrorStackRemapping } from "../error-stack-remapping/installBrowserErrorStackRemapping.js"
|
|
4
|
-
import { fetchUrl } from "../browser_utils/
|
|
4
|
+
import { fetchUrl } from "../browser_utils/fetch_browser.js"
|
|
5
5
|
import { fetchAndEvalUsingFetch } from "../browser_utils/fetchAndEvalUsingFetch.js"
|
|
6
6
|
import { unevalException } from "../unevalException.js"
|
|
7
7
|
import { memoize } from "../memoize.js"
|
|
@@ -165,26 +165,27 @@ const onExecutionError = (
|
|
|
165
165
|
|
|
166
166
|
const getBrowserRuntime = memoize(async () => {
|
|
167
167
|
const compileServerOrigin = document.location.origin
|
|
168
|
-
const
|
|
169
|
-
`${compileServerOrigin}
|
|
168
|
+
const compileServerResponse = await fetchUrl(
|
|
169
|
+
`${compileServerOrigin}/__jsenv_compile_profile__`,
|
|
170
170
|
)
|
|
171
|
-
const
|
|
172
|
-
const {
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
|
|
171
|
+
const compileServerMeta = await compileServerResponse.json()
|
|
172
|
+
const { jsenvDirectoryRelativeUrl, errorStackRemapping } = compileServerMeta
|
|
173
|
+
const jsenvDirectoryServerUrl = `${compileServerOrigin}/${jsenvDirectoryRelativeUrl}`
|
|
174
|
+
const afterJsenvDirectory = document.location.href.slice(
|
|
175
|
+
jsenvDirectoryServerUrl.length,
|
|
176
|
+
)
|
|
177
|
+
const parts = afterJsenvDirectory.split("/")
|
|
176
178
|
const compileId = parts[0]
|
|
177
179
|
|
|
178
180
|
const browserRuntime = await createBrowserRuntime({
|
|
179
181
|
compileServerOrigin,
|
|
180
|
-
|
|
182
|
+
jsenvDirectoryRelativeUrl,
|
|
181
183
|
compileId,
|
|
182
184
|
})
|
|
183
185
|
|
|
184
186
|
if (errorStackRemapping && Error.captureStackTrace) {
|
|
185
187
|
const { sourcemapMainFileRelativeUrl, sourcemapMappingFileRelativeUrl } =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
compileServerMeta
|
|
188
189
|
await fetchAndEvalUsingFetch(
|
|
189
190
|
`${compileServerOrigin}/${sourcemapMainFileRelativeUrl}`,
|
|
190
191
|
)
|
|
@@ -195,7 +196,6 @@ const getBrowserRuntime = memoize(async () => {
|
|
|
195
196
|
const { getErrorOriginalStackString } = installBrowserErrorStackRemapping({
|
|
196
197
|
SourceMapConsumer,
|
|
197
198
|
})
|
|
198
|
-
|
|
199
199
|
const errorTransform = async (error) => {
|
|
200
200
|
// code can throw something else than an error
|
|
201
201
|
// in that case return it unchanged
|
|
@@ -204,13 +204,11 @@ const getBrowserRuntime = memoize(async () => {
|
|
|
204
204
|
error.stack = originalStack
|
|
205
205
|
return error
|
|
206
206
|
}
|
|
207
|
-
|
|
208
207
|
const executeFile = browserRuntime.executeFile
|
|
209
208
|
browserRuntime.executeFile = (file, options = {}) => {
|
|
210
209
|
return executeFile(file, { errorTransform, ...options })
|
|
211
210
|
}
|
|
212
211
|
}
|
|
213
|
-
|
|
214
212
|
return browserRuntime
|
|
215
213
|
})
|
|
216
214
|
|