@jsenv/core 25.3.0 → 25.4.0
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_2334a374.js.map +342 -0
- package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_9f737eaf.html} +357 -398
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/redirector.html__inline__12_009c47c7.js.map +348 -0
- package/dist/redirector/{redirector_3e9a97b9.html → redirector_96f74871.html} +378 -421
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/{toolbar.main_6c1b3d82.js.map → toolbar.main_86335f90.js.map} +82 -115
- package/dist/toolbar/{toolbar_361afb84.html → toolbar_d3a918a4.html} +487 -508
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/toolbar_injector_978bbd14.js +267 -0
- package/dist/toolbar_injector/toolbar_injector_978bbd14.js.map +119 -0
- package/package.json +12 -11
- package/src/buildProject.js +31 -26
- package/src/dev_server.js +76 -87
- package/src/execute.js +3 -8
- 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} +58 -9
- 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 +153 -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 +156 -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 +85 -78
- package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
- package/src/internal/dev_server/toolbar/toolbar.html +40 -16
- package/src/internal/dev_server/toolbar/toolbar.injector.js +11 -17
- package/src/internal/dev_server/toolbar/toolbar.main.js +6 -6
- 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 +85 -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 -3
- 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/node_execution_systemjs.js +2 -5
- package/src/internal/{dev_server/redirector → redirector}/redirector.html +8 -18
- 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_injector/toolbar_injector_fac1e995.js +0 -973
- package/dist/toolbar_injector/toolbar_injector_fac1e995.js.map +0 -294
- 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/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,9 +1,9 @@
|
|
|
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
9
|
import { jsenvCoreDirectoryUrl } from "./internal/jsenvCoreDirectoryUrl.js"
|
|
@@ -13,14 +13,13 @@ import {
|
|
|
13
13
|
} from "./internal/argUtils.js"
|
|
14
14
|
import {
|
|
15
15
|
startCompileServer,
|
|
16
|
-
|
|
16
|
+
assertAndNormalizeJsenvDirectoryRelativeUrl,
|
|
17
17
|
} from "./internal/compiling/startCompileServer.js"
|
|
18
|
-
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
19
|
-
|
|
20
18
|
import {
|
|
21
19
|
sourcemapMainFileInfo,
|
|
22
20
|
sourcemapMappingFileInfo,
|
|
23
21
|
} from "./internal/jsenvInternalFiles.js"
|
|
22
|
+
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
24
23
|
|
|
25
24
|
export const startDevServer = async ({
|
|
26
25
|
signal = new AbortController().signal,
|
|
@@ -28,7 +27,7 @@ export const startDevServer = async ({
|
|
|
28
27
|
port,
|
|
29
28
|
ip,
|
|
30
29
|
protocol,
|
|
31
|
-
http2,
|
|
30
|
+
http2 = false, // disable by default for now because it is buggy on safari
|
|
32
31
|
certificate,
|
|
33
32
|
privateKey,
|
|
34
33
|
plugins,
|
|
@@ -38,7 +37,6 @@ export const startDevServer = async ({
|
|
|
38
37
|
explorableConfig = jsenvExplorableConfig,
|
|
39
38
|
mainFileRelativeUrl,
|
|
40
39
|
jsenvDirectoryRelativeUrl,
|
|
41
|
-
outDirectoryName = "dev",
|
|
42
40
|
jsenvToolbar = true,
|
|
43
41
|
livereloading = true,
|
|
44
42
|
inlineImportMapIntoHTML = true,
|
|
@@ -66,7 +64,6 @@ export const startDevServer = async ({
|
|
|
66
64
|
}) => {
|
|
67
65
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
68
66
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
69
|
-
|
|
70
67
|
if (mainFileRelativeUrl === undefined) {
|
|
71
68
|
mainFileRelativeUrl = urlToRelativeUrl(
|
|
72
69
|
new URL(
|
|
@@ -76,13 +73,10 @@ export const startDevServer = async ({
|
|
|
76
73
|
projectDirectoryUrl,
|
|
77
74
|
)
|
|
78
75
|
}
|
|
79
|
-
|
|
80
|
-
const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
|
|
76
|
+
jsenvDirectoryRelativeUrl = assertAndNormalizeJsenvDirectoryRelativeUrl({
|
|
81
77
|
projectDirectoryUrl,
|
|
82
78
|
jsenvDirectoryRelativeUrl,
|
|
83
|
-
outDirectoryName,
|
|
84
79
|
})
|
|
85
|
-
|
|
86
80
|
const compileServer = await startCompileServer({
|
|
87
81
|
signal,
|
|
88
82
|
handleSIGINT,
|
|
@@ -103,14 +97,14 @@ export const startDevServer = async ({
|
|
|
103
97
|
}),
|
|
104
98
|
"jsenv:exploring_json": createExploringJsonService({
|
|
105
99
|
projectDirectoryUrl,
|
|
106
|
-
|
|
100
|
+
jsenvDirectoryRelativeUrl,
|
|
107
101
|
mainFileRelativeUrl,
|
|
108
102
|
explorableConfig,
|
|
109
103
|
livereloading,
|
|
110
104
|
}),
|
|
111
105
|
"jsenv:explorables_json": createExplorableJsonService({
|
|
112
106
|
projectDirectoryUrl,
|
|
113
|
-
|
|
107
|
+
jsenvDirectoryRelativeUrl,
|
|
114
108
|
explorableConfig,
|
|
115
109
|
}),
|
|
116
110
|
},
|
|
@@ -120,7 +114,6 @@ export const startDevServer = async ({
|
|
|
120
114
|
jsenvEventSourceClientInjection: true,
|
|
121
115
|
jsenvToolbarInjection: jsenvToolbar,
|
|
122
116
|
jsenvDirectoryRelativeUrl,
|
|
123
|
-
outDirectoryName,
|
|
124
117
|
inlineImportMapIntoHTML,
|
|
125
118
|
|
|
126
119
|
compileServerCanReadFromFilesystem,
|
|
@@ -177,98 +170,94 @@ const createRedirectorService = async ({
|
|
|
177
170
|
|
|
178
171
|
const createExploringJsonService = ({
|
|
179
172
|
projectDirectoryUrl,
|
|
180
|
-
|
|
173
|
+
jsenvDirectoryRelativeUrl,
|
|
181
174
|
explorableConfig,
|
|
182
175
|
livereloading,
|
|
183
176
|
mainFileRelativeUrl,
|
|
184
177
|
}) => {
|
|
185
178
|
return (request) => {
|
|
186
179
|
if (
|
|
187
|
-
request.ressource
|
|
188
|
-
request.method
|
|
180
|
+
request.ressource !== "/.jsenv/exploring.json" ||
|
|
181
|
+
request.method !== "GET"
|
|
189
182
|
) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
},
|
|
217
|
-
body: json,
|
|
218
|
-
}
|
|
183
|
+
return null
|
|
184
|
+
}
|
|
185
|
+
const data = {
|
|
186
|
+
projectDirectoryUrl,
|
|
187
|
+
jsenvDirectoryRelativeUrl,
|
|
188
|
+
exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
|
|
189
|
+
sourcemapMainFileRelativeUrl: urlToRelativeUrl(
|
|
190
|
+
sourcemapMainFileInfo.url,
|
|
191
|
+
jsenvCoreDirectoryUrl,
|
|
192
|
+
),
|
|
193
|
+
sourcemapMappingFileRelativeUrl: urlToRelativeUrl(
|
|
194
|
+
sourcemapMappingFileInfo.url,
|
|
195
|
+
jsenvCoreDirectoryUrl,
|
|
196
|
+
),
|
|
197
|
+
explorableConfig,
|
|
198
|
+
livereloading,
|
|
199
|
+
}
|
|
200
|
+
const json = JSON.stringify(data)
|
|
201
|
+
return {
|
|
202
|
+
status: 200,
|
|
203
|
+
headers: {
|
|
204
|
+
"cache-control": "no-store",
|
|
205
|
+
"content-type": "application/json",
|
|
206
|
+
"content-length": Buffer.byteLength(json),
|
|
207
|
+
},
|
|
208
|
+
body: json,
|
|
219
209
|
}
|
|
220
|
-
return null
|
|
221
210
|
}
|
|
222
211
|
}
|
|
223
212
|
|
|
224
213
|
const createExplorableJsonService = ({
|
|
225
214
|
projectDirectoryUrl,
|
|
226
|
-
|
|
215
|
+
jsenvDirectoryRelativeUrl,
|
|
227
216
|
explorableConfig,
|
|
228
217
|
}) => {
|
|
229
218
|
return async (request) => {
|
|
230
219
|
if (
|
|
231
|
-
request.ressource
|
|
232
|
-
request.method
|
|
220
|
+
request.ressource !== "/.jsenv/explorables.json" ||
|
|
221
|
+
request.method !== "GET"
|
|
233
222
|
) {
|
|
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,
|
|
223
|
+
return null
|
|
224
|
+
}
|
|
225
|
+
const structuredMetaMapRelativeForExplorable = {}
|
|
226
|
+
Object.keys(explorableConfig).forEach((explorableGroup) => {
|
|
227
|
+
const explorableGroupConfig = explorableConfig[explorableGroup]
|
|
228
|
+
structuredMetaMapRelativeForExplorable[explorableGroup] = {
|
|
229
|
+
"**/.jsenv/": false, // temporary (in theory) to avoid visting .jsenv directory in jsenv itself
|
|
230
|
+
...explorableGroupConfig,
|
|
231
|
+
[jsenvDirectoryRelativeUrl]: false,
|
|
270
232
|
}
|
|
233
|
+
})
|
|
234
|
+
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
235
|
+
structuredMetaMapRelativeForExplorable,
|
|
236
|
+
projectDirectoryUrl,
|
|
237
|
+
)
|
|
238
|
+
const matchingFileResultArray = await collectFiles({
|
|
239
|
+
directoryUrl: projectDirectoryUrl,
|
|
240
|
+
structuredMetaMap: structuredMetaMapForExplorable,
|
|
241
|
+
predicate: (meta) =>
|
|
242
|
+
Object.keys(meta).some((explorableGroup) =>
|
|
243
|
+
Boolean(meta[explorableGroup]),
|
|
244
|
+
),
|
|
245
|
+
})
|
|
246
|
+
const explorableFiles = matchingFileResultArray.map(
|
|
247
|
+
({ relativeUrl, meta }) => ({
|
|
248
|
+
relativeUrl,
|
|
249
|
+
meta,
|
|
250
|
+
}),
|
|
251
|
+
)
|
|
252
|
+
const json = JSON.stringify(explorableFiles)
|
|
253
|
+
return {
|
|
254
|
+
status: 200,
|
|
255
|
+
headers: {
|
|
256
|
+
"cache-control": "no-store",
|
|
257
|
+
"content-type": "application/json",
|
|
258
|
+
"content-length": Buffer.byteLength(json),
|
|
259
|
+
},
|
|
260
|
+
body: json,
|
|
271
261
|
}
|
|
272
|
-
return null
|
|
273
262
|
}
|
|
274
263
|
}
|
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
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { normalizeImportMap } from "@jsenv/importmap/src/normalizeImportMap.js"
|
|
4
4
|
|
|
5
5
|
// do not use memoize from @jsenv/filesystem to avoid pulling @jsenv/filesystem code into the browser build
|
|
6
|
-
import { fetchUrl } from "../browser_utils/
|
|
6
|
+
import { fetchUrl } from "../browser_utils/fetch_browser.js"
|
|
7
7
|
import { createImportResolverForImportmap } from "../import-resolution/import-resolver-importmap.js"
|
|
8
8
|
import { memoize } from "../memoize.js"
|
|
9
9
|
import { measureAsyncFnPerf } from "../perf_browser.js"
|
|
@@ -15,7 +15,7 @@ const memoizedCreateBrowserSystem = memoize(createBrowserSystem)
|
|
|
15
15
|
|
|
16
16
|
export const createBrowserRuntime = async ({
|
|
17
17
|
compileServerOrigin,
|
|
18
|
-
|
|
18
|
+
jsenvDirectoryRelativeUrl,
|
|
19
19
|
compileId,
|
|
20
20
|
}) => {
|
|
21
21
|
const fetchSource = (url, { contentTypeExpected }) => {
|
|
@@ -33,10 +33,11 @@ export const createBrowserRuntime = async ({
|
|
|
33
33
|
return json
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
36
|
+
const compileServerMetaUrl = String(
|
|
37
|
+
new URL("__jsenv_compile_profile__", `${compileServerOrigin}/`),
|
|
38
|
+
)
|
|
39
|
+
const { importDefaultExtension } = await fetchJson(compileServerMetaUrl)
|
|
40
|
+
const compileDirectoryRelativeUrl = `${jsenvDirectoryRelativeUrl}${compileId}/`
|
|
40
41
|
// if there is an importmap in the document we use it instead of fetching.
|
|
41
42
|
// systemjs style with systemjs-importmap
|
|
42
43
|
const importmapScript = document.querySelector(
|