@jsenv/core 25.2.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 +19 -14
- package/readme.md +54 -54
- package/src/buildProject.js +31 -26
- package/src/dev_server.js +78 -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/html/parseHtmlRessource.js +2 -1
- 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/babelHelper.js +10 -13
- package/src/internal/compiling/js-compilation-service/babel_plugin_babel_helpers_as_jsenv_imports.js +4 -2
- package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
- package/src/internal/compiling/jsenvCompilerForHtml.js +34 -34
- 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 +4 -2
- 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/jsenv_remote_directory.js +1 -1
- 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 -243
- 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/integrity/integrity_algorithms.js +0 -26
- package/src/internal/integrity/integrity_parsing.js +0 -50
- package/src/internal/integrity/integrity_update.js +0 -23
- package/src/internal/integrity/integrity_validation.js +0 -49
- 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/buildProject.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
2
1
|
import { resolveDirectoryUrl } from "@jsenv/filesystem"
|
|
2
|
+
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
3
3
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
4
4
|
|
|
5
|
-
import { shakeBabelPluginMap } from "@jsenv/core/src/internal/generateGroupMap/shake_babel_plugin_map.js"
|
|
6
|
-
import { COMPILE_ID_BEST } from "@jsenv/core/src/internal/CONSTANTS.js"
|
|
7
5
|
import {
|
|
8
6
|
assertProjectDirectoryUrl,
|
|
9
7
|
assertProjectDirectoryExists,
|
|
@@ -13,7 +11,11 @@ import { buildUsingRollup } from "@jsenv/core/src/internal/building/buildUsingRo
|
|
|
13
11
|
import {
|
|
14
12
|
jsenvBrowserRuntimeSupport,
|
|
15
13
|
jsenvNodeRuntimeSupport,
|
|
16
|
-
} from "@jsenv/core/src/internal/
|
|
14
|
+
} from "@jsenv/core/src/internal/runtime_support/jsenv_runtime_support.js"
|
|
15
|
+
import {
|
|
16
|
+
isNodePartOfSupportedRuntimes,
|
|
17
|
+
isBrowserPartOfSupportedRuntimes,
|
|
18
|
+
} from "@jsenv/core/src/internal/runtime_support/runtime_support.js"
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Generate optimized version of source files into a directory
|
|
@@ -126,19 +128,15 @@ export const buildProject = async ({
|
|
|
126
128
|
`format must be "systemjs" when importMapInWebWorkers is enabled`,
|
|
127
129
|
)
|
|
128
130
|
}
|
|
129
|
-
|
|
130
131
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
131
132
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
132
|
-
|
|
133
|
-
assertentryPoints({ entryPoints })
|
|
134
|
-
|
|
133
|
+
assertEntryPoints({ entryPoints })
|
|
135
134
|
if (Object.keys(entryPoints).length === 0) {
|
|
136
135
|
logger.error(`entryPoints is an empty object`)
|
|
137
136
|
return {
|
|
138
137
|
rollupBuilds: {},
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
|
-
|
|
142
140
|
assertBuildDirectoryRelativeUrl({ buildDirectoryRelativeUrl })
|
|
143
141
|
const buildDirectoryUrl = resolveDirectoryUrl(
|
|
144
142
|
buildDirectoryRelativeUrl,
|
|
@@ -151,7 +149,6 @@ export const buildProject = async ({
|
|
|
151
149
|
|
|
152
150
|
const buildOperation = Abort.startOperation()
|
|
153
151
|
buildOperation.addAbortSignal(signal)
|
|
154
|
-
|
|
155
152
|
if (handleSIGINT) {
|
|
156
153
|
buildOperation.addAbortSource((abort) => {
|
|
157
154
|
return raceProcessTeardownEvents(
|
|
@@ -162,7 +159,6 @@ export const buildProject = async ({
|
|
|
162
159
|
)
|
|
163
160
|
})
|
|
164
161
|
}
|
|
165
|
-
|
|
166
162
|
const compileServer = await startCompileServer({
|
|
167
163
|
signal: buildOperation.signal,
|
|
168
164
|
logLevel: compileServerLogLevel,
|
|
@@ -210,12 +206,26 @@ export const buildProject = async ({
|
|
|
210
206
|
compileServerCanReadFromFilesystem: filesystemCache,
|
|
211
207
|
compileServerCanWriteOnFilesystem: filesystemCache,
|
|
212
208
|
})
|
|
213
|
-
|
|
214
209
|
buildOperation.addEndCallback(async () => {
|
|
215
210
|
await compileServer.stop(`build cleanup`)
|
|
216
211
|
})
|
|
217
|
-
|
|
218
|
-
const
|
|
212
|
+
const node = isNodePartOfSupportedRuntimes(runtimeSupport)
|
|
213
|
+
const browser = isBrowserPartOfSupportedRuntimes(runtimeSupport)
|
|
214
|
+
const { compileId, compileProfile } =
|
|
215
|
+
await compileServer.createCompileIdFromRuntimeReport({
|
|
216
|
+
env: {
|
|
217
|
+
browser,
|
|
218
|
+
node,
|
|
219
|
+
},
|
|
220
|
+
name: "jsenv_build",
|
|
221
|
+
version: "1",
|
|
222
|
+
runtimeSupport,
|
|
223
|
+
// "rollup_plugin_jsenv.js" expects to hit the compile server
|
|
224
|
+
// so we force compilation by adding a fake feature called "force_compilation"
|
|
225
|
+
// one day we'll test how code behaves if zero transformations is required during
|
|
226
|
+
// the build and update code as needed
|
|
227
|
+
forceCompilation: true,
|
|
228
|
+
})
|
|
219
229
|
|
|
220
230
|
try {
|
|
221
231
|
const result = await buildUsingRollup({
|
|
@@ -224,9 +234,6 @@ export const buildProject = async ({
|
|
|
224
234
|
|
|
225
235
|
entryPoints,
|
|
226
236
|
projectDirectoryUrl,
|
|
227
|
-
compileServerOrigin,
|
|
228
|
-
compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${COMPILE_ID_BEST}/`,
|
|
229
|
-
jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
|
|
230
237
|
buildDirectoryUrl,
|
|
231
238
|
buildDirectoryClean,
|
|
232
239
|
assetManifestFile,
|
|
@@ -244,19 +251,17 @@ export const buildProject = async ({
|
|
|
244
251
|
systemJsUrl,
|
|
245
252
|
globalName,
|
|
246
253
|
globals,
|
|
247
|
-
babelPluginMap: shakeBabelPluginMap({
|
|
248
|
-
babelPluginMap: compileServer.babelPluginMap,
|
|
249
|
-
missingFeatureNames:
|
|
250
|
-
compileServer.compileServerGroupMap[COMPILE_ID_BEST]
|
|
251
|
-
.missingFeatureNames,
|
|
252
|
-
}),
|
|
253
|
-
runtimeSupport,
|
|
254
254
|
workers,
|
|
255
255
|
serviceWorkers,
|
|
256
256
|
serviceWorkerFinalizer,
|
|
257
257
|
classicWorkers,
|
|
258
258
|
classicServiceWorkers,
|
|
259
|
-
|
|
259
|
+
|
|
260
|
+
node,
|
|
261
|
+
browser,
|
|
262
|
+
compileServer,
|
|
263
|
+
compileProfile,
|
|
264
|
+
compileId,
|
|
260
265
|
|
|
261
266
|
urlVersioning,
|
|
262
267
|
lineBreakNormalization,
|
|
@@ -287,7 +292,7 @@ export const buildProject = async ({
|
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
|
|
290
|
-
const
|
|
295
|
+
const assertEntryPoints = ({ entryPoints }) => {
|
|
291
296
|
if (typeof entryPoints !== "object") {
|
|
292
297
|
throw new TypeError(`entryPoints must be an object, got ${entryPoints}`)
|
|
293
298
|
}
|
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,
|
|
@@ -49,6 +47,7 @@ export const startDevServer = async ({
|
|
|
49
47
|
serviceWorkers,
|
|
50
48
|
importMapInWebWorkers,
|
|
51
49
|
customCompilers,
|
|
50
|
+
preservedUrls,
|
|
52
51
|
runtimeSupportDuringDev = {
|
|
53
52
|
// this allows to compile nothing or almost nothing when opening files
|
|
54
53
|
// with a recent chrome. Without this we would compile all the things not yet unsupported
|
|
@@ -65,7 +64,6 @@ export const startDevServer = async ({
|
|
|
65
64
|
}) => {
|
|
66
65
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
67
66
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
68
|
-
|
|
69
67
|
if (mainFileRelativeUrl === undefined) {
|
|
70
68
|
mainFileRelativeUrl = urlToRelativeUrl(
|
|
71
69
|
new URL(
|
|
@@ -75,13 +73,10 @@ export const startDevServer = async ({
|
|
|
75
73
|
projectDirectoryUrl,
|
|
76
74
|
)
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
|
|
76
|
+
jsenvDirectoryRelativeUrl = assertAndNormalizeJsenvDirectoryRelativeUrl({
|
|
80
77
|
projectDirectoryUrl,
|
|
81
78
|
jsenvDirectoryRelativeUrl,
|
|
82
|
-
outDirectoryName,
|
|
83
79
|
})
|
|
84
|
-
|
|
85
80
|
const compileServer = await startCompileServer({
|
|
86
81
|
signal,
|
|
87
82
|
handleSIGINT,
|
|
@@ -102,14 +97,14 @@ export const startDevServer = async ({
|
|
|
102
97
|
}),
|
|
103
98
|
"jsenv:exploring_json": createExploringJsonService({
|
|
104
99
|
projectDirectoryUrl,
|
|
105
|
-
|
|
100
|
+
jsenvDirectoryRelativeUrl,
|
|
106
101
|
mainFileRelativeUrl,
|
|
107
102
|
explorableConfig,
|
|
108
103
|
livereloading,
|
|
109
104
|
}),
|
|
110
105
|
"jsenv:explorables_json": createExplorableJsonService({
|
|
111
106
|
projectDirectoryUrl,
|
|
112
|
-
|
|
107
|
+
jsenvDirectoryRelativeUrl,
|
|
113
108
|
explorableConfig,
|
|
114
109
|
}),
|
|
115
110
|
},
|
|
@@ -119,12 +114,12 @@ export const startDevServer = async ({
|
|
|
119
114
|
jsenvEventSourceClientInjection: true,
|
|
120
115
|
jsenvToolbarInjection: jsenvToolbar,
|
|
121
116
|
jsenvDirectoryRelativeUrl,
|
|
122
|
-
outDirectoryName,
|
|
123
117
|
inlineImportMapIntoHTML,
|
|
124
118
|
|
|
125
119
|
compileServerCanReadFromFilesystem,
|
|
126
120
|
compileServerCanWriteOnFilesystem,
|
|
127
121
|
customCompilers,
|
|
122
|
+
preservedUrls,
|
|
128
123
|
sourcemapMethod,
|
|
129
124
|
babelPluginMap,
|
|
130
125
|
workers,
|
|
@@ -175,98 +170,94 @@ const createRedirectorService = async ({
|
|
|
175
170
|
|
|
176
171
|
const createExploringJsonService = ({
|
|
177
172
|
projectDirectoryUrl,
|
|
178
|
-
|
|
173
|
+
jsenvDirectoryRelativeUrl,
|
|
179
174
|
explorableConfig,
|
|
180
175
|
livereloading,
|
|
181
176
|
mainFileRelativeUrl,
|
|
182
177
|
}) => {
|
|
183
178
|
return (request) => {
|
|
184
179
|
if (
|
|
185
|
-
request.ressource
|
|
186
|
-
request.method
|
|
180
|
+
request.ressource !== "/.jsenv/exploring.json" ||
|
|
181
|
+
request.method !== "GET"
|
|
187
182
|
) {
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
body: json,
|
|
216
|
-
}
|
|
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,
|
|
217
209
|
}
|
|
218
|
-
return null
|
|
219
210
|
}
|
|
220
211
|
}
|
|
221
212
|
|
|
222
213
|
const createExplorableJsonService = ({
|
|
223
214
|
projectDirectoryUrl,
|
|
224
|
-
|
|
215
|
+
jsenvDirectoryRelativeUrl,
|
|
225
216
|
explorableConfig,
|
|
226
217
|
}) => {
|
|
227
218
|
return async (request) => {
|
|
228
219
|
if (
|
|
229
|
-
request.ressource
|
|
230
|
-
request.method
|
|
220
|
+
request.ressource !== "/.jsenv/explorables.json" ||
|
|
221
|
+
request.method !== "GET"
|
|
231
222
|
) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
242
|
-
structuredMetaMapRelativeForExplorable,
|
|
243
|
-
projectDirectoryUrl,
|
|
244
|
-
)
|
|
245
|
-
const matchingFileResultArray = await collectFiles({
|
|
246
|
-
directoryUrl: projectDirectoryUrl,
|
|
247
|
-
structuredMetaMap: structuredMetaMapForExplorable,
|
|
248
|
-
predicate: (meta) =>
|
|
249
|
-
Object.keys(meta).some((explorableGroup) =>
|
|
250
|
-
Boolean(meta[explorableGroup]),
|
|
251
|
-
),
|
|
252
|
-
})
|
|
253
|
-
const explorableFiles = matchingFileResultArray.map(
|
|
254
|
-
({ relativeUrl, meta }) => ({
|
|
255
|
-
relativeUrl,
|
|
256
|
-
meta,
|
|
257
|
-
}),
|
|
258
|
-
)
|
|
259
|
-
const json = JSON.stringify(explorableFiles)
|
|
260
|
-
return {
|
|
261
|
-
status: 200,
|
|
262
|
-
headers: {
|
|
263
|
-
"cache-control": "no-store",
|
|
264
|
-
"content-type": "application/json",
|
|
265
|
-
"content-length": Buffer.byteLength(json),
|
|
266
|
-
},
|
|
267
|
-
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,
|
|
268
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,
|
|
269
261
|
}
|
|
270
|
-
return null
|
|
271
262
|
}
|
|
272
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
|