@jsenv/core 25.2.1 → 25.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/browser_runtime/asset-manifest.json +2 -2
  2. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
  3. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
  4. package/dist/build_manifest.js +5 -5
  5. package/dist/compile_proxy/asset-manifest.json +2 -2
  6. package/dist/compile_proxy/compile_proxy.html__inline__20_f4285042.js.map +343 -0
  7. package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_ab528227.html} +358 -397
  8. package/dist/redirector/asset-manifest.json +2 -2
  9. package/dist/redirector/redirector.html__inline__12_404b8295.js.map +349 -0
  10. package/dist/redirector/{redirector_3e9a97b9.html → redirector_6df2620a.html} +369 -407
  11. package/dist/toolbar/asset-manifest.json +2 -2
  12. package/dist/toolbar/toolbar.main_279b3a68.js.map +764 -0
  13. package/dist/toolbar/{toolbar_361afb84.html → toolbar_0a91ca3b.html} +1509 -1583
  14. package/dist/toolbar_injector/asset-manifest.json +2 -2
  15. package/dist/toolbar_injector/{toolbar_injector_fac1e995.js → toolbar_injector_34f6ad8e.js} +18 -15
  16. package/dist/toolbar_injector/{toolbar_injector_fac1e995.js.map → toolbar_injector_34f6ad8e.js.map} +15 -15
  17. package/package.json +16 -12
  18. package/readme.md +54 -54
  19. package/src/buildProject.js +31 -26
  20. package/src/dev_server.js +111 -92
  21. package/src/execute.js +3 -8
  22. package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
  23. package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
  24. package/src/internal/browser_launcher/from_playwright.js +6 -4
  25. package/src/internal/browser_runtime/browser_runtime.js +12 -14
  26. package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
  27. package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
  28. package/src/internal/browser_utils/fetchJson.js +1 -1
  29. package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
  30. package/src/internal/building/buildUsingRollup.js +41 -57
  31. package/src/internal/building/html/parseHtmlRessource.js +2 -1
  32. package/src/internal/building/rollup_plugin_jsenv.js +28 -8
  33. package/src/internal/compiling/babel_parse_error.js +9 -0
  34. package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +58 -9
  35. package/src/internal/compiling/compileFile.js +2 -2
  36. package/src/internal/compiling/compileHtml.js +1 -1
  37. package/src/internal/compiling/createCompiledFileService.js +25 -74
  38. package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
  39. package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
  40. package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
  41. package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
  42. package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
  43. package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
  44. package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
  45. package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
  46. package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
  47. package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
  48. package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
  49. package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
  50. package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
  51. package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
  52. package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
  53. package/src/internal/compiling/sse_service/sse_service.js +369 -0
  54. package/src/internal/compiling/startCompileServer.js +157 -804
  55. package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
  56. package/src/internal/dev_server/exploring/exploring.js +10 -8
  57. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +92 -78
  58. package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
  59. package/src/internal/dev_server/toolbar/toolbar.html +46 -16
  60. package/src/internal/dev_server/toolbar/toolbar.injector.js +17 -15
  61. package/src/internal/dev_server/toolbar/toolbar.main.js +12 -16
  62. package/src/internal/executing/executeConcurrently.js +1 -1
  63. package/src/internal/executing/executePlan.js +2 -3
  64. package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
  65. package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
  66. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
  67. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
  68. package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
  69. package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
  70. package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
  71. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +89 -0
  72. package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
  73. package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
  74. package/src/internal/features/features_compat_from_runtime.js +38 -0
  75. package/src/internal/features/features_compat_from_runtime_support.js +31 -0
  76. package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
  77. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
  78. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
  79. package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
  80. package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
  81. package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
  82. package/src/internal/jsenv_remote_directory.js +1 -1
  83. package/src/internal/node_launcher/createControllableNodeProcess.js +4 -3
  84. package/src/internal/node_launcher/node_runtime_report.js +15 -9
  85. package/src/internal/node_runtime/fetchSource.js +2 -4
  86. package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
  87. package/src/internal/redirector/redirector.html +40 -0
  88. package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
  89. package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
  90. package/src/internal/url_conversion.js +12 -17
  91. package/src/launchNode.js +29 -41
  92. package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
  93. package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
  94. package/dist/toolbar/toolbar.main_6c1b3d82.js.map +0 -802
  95. package/src/internal/CONSTANTS.js +0 -11
  96. package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
  97. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
  98. package/src/internal/dev_server/redirector/redirector.html +0 -48
  99. package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
  100. package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
  101. package/src/internal/generateGroupMap/runtime_compat.js +0 -34
  102. package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
  103. package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
  104. package/src/internal/integrity/integrity_algorithms.js +0 -26
  105. package/src/internal/integrity/integrity_parsing.js +0 -50
  106. package/src/internal/integrity/integrity_update.js +0 -23
  107. package/src/internal/integrity/integrity_validation.js +0 -49
  108. package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
  109. package/src/internal/node_runtime/detectNode.js +0 -3
  110. package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
  111. package/src/internal/runtime/resolveGroup.js +0 -13
  112. package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
@@ -150,33 +150,28 @@ const normalizeUrlMappings = (urlMappings, baseUrl) => {
150
150
 
151
151
  export const serverUrlToCompileInfo = (
152
152
  url,
153
- { compileServerOrigin, outDirectoryRelativeUrl },
153
+ { compileServerOrigin, jsenvDirectoryRelativeUrl },
154
154
  ) => {
155
- const outDirectoryServerUrl = resolveDirectoryUrl(
156
- outDirectoryRelativeUrl,
155
+ const jsenvDirectoryServerUrl = resolveDirectoryUrl(
156
+ jsenvDirectoryRelativeUrl,
157
157
  compileServerOrigin,
158
158
  )
159
159
  // not inside compile directory -> nothing to compile
160
- if (!url.startsWith(outDirectoryServerUrl)) {
160
+ if (!url.startsWith(jsenvDirectoryServerUrl)) {
161
161
  return { insideCompileDirectory: false }
162
162
  }
163
-
164
- const afterOutDirectory = url.slice(outDirectoryServerUrl.length)
165
-
163
+ const afterJsenvDirectory = url.slice(jsenvDirectoryServerUrl.length)
166
164
  // serve files inside /.jsenv/* directly without compilation
167
165
  // this is just to allow some files to be written inside outDirectory and read directly
168
- // if asked by the client (such as __compile_server_meta__.json)
169
- if (!afterOutDirectory.includes("/") || afterOutDirectory[0] === "/") {
166
+ if (!afterJsenvDirectory.includes("/") || afterJsenvDirectory[0] === "/") {
170
167
  return { insideCompileDirectory: true }
171
168
  }
172
-
173
- const parts = afterOutDirectory.split("/")
169
+ const parts = afterJsenvDirectory.split("/")
174
170
  const compileId = parts[0]
175
171
  // no compileId, we don't know what to compile (not supposed so happen)
176
172
  if (compileId === "") {
177
173
  return { insideCompileDirectory: true, compileId: null }
178
174
  }
179
-
180
175
  const afterCompileId = parts.slice(1).join("/")
181
176
  // note: afterCompileId can be '' (but not supposed to happen)
182
177
  return { insideCompileDirectory: true, compileId, afterCompileId }
@@ -260,7 +255,7 @@ const originalProjectUrlFromUrl = (
260
255
  {
261
256
  projectDirectoryUrl,
262
257
  compileServerOrigin,
263
- outDirectoryRelativeUrl,
258
+ jsenvDirectoryRelativeUrl,
264
259
  compileDirectoryRelativeUrl,
265
260
  },
266
261
  ) => {
@@ -280,7 +275,7 @@ const originalProjectUrlFromUrl = (
280
275
  compileDirectoryRelativeUrl = extractCompileDirectoryRelativeUrl({
281
276
  serverUrl,
282
277
  compileServerOrigin,
283
- outDirectoryRelativeUrl,
278
+ jsenvDirectoryRelativeUrl,
284
279
  })
285
280
  if (!compileDirectoryRelativeUrl) {
286
281
  return projectUrl
@@ -305,14 +300,14 @@ const originalProjectUrlFromUrl = (
305
300
  const extractCompileDirectoryRelativeUrl = ({
306
301
  serverUrl,
307
302
  compileServerOrigin,
308
- outDirectoryRelativeUrl,
303
+ jsenvDirectoryRelativeUrl,
309
304
  }) => {
310
305
  const compileInfo = serverUrlToCompileInfo(serverUrl, {
311
306
  compileServerOrigin,
312
- outDirectoryRelativeUrl,
307
+ jsenvDirectoryRelativeUrl,
313
308
  })
314
309
  if (compileInfo.compiledId) {
315
- return `${outDirectoryRelativeUrl}${compileInfo.compileId}/`
310
+ return `${jsenvDirectoryRelativeUrl}${compileInfo.compileId}/`
316
311
  }
317
312
  return null
318
313
  }
package/src/launchNode.js CHANGED
@@ -18,7 +18,7 @@ nodeRuntime.launch = async ({
18
18
  projectDirectoryUrl,
19
19
  compileServerId,
20
20
  compileServerOrigin,
21
- outDirectoryRelativeUrl,
21
+ jsenvDirectoryRelativeUrl,
22
22
 
23
23
  measurePerformance,
24
24
  collectPerformance,
@@ -26,6 +26,9 @@ nodeRuntime.launch = async ({
26
26
  coverageForceIstanbul,
27
27
  coverageConfig,
28
28
 
29
+ moduleOutFormat,
30
+ forceCompilation,
31
+
29
32
  debugPort,
30
33
  debugMode,
31
34
  debugModeInheritBreak,
@@ -36,26 +39,9 @@ nodeRuntime.launch = async ({
36
39
  stdout,
37
40
  stderr,
38
41
  stopAfterExecute,
39
- forceSystemJs,
40
42
 
41
43
  remap = true,
42
44
  }) => {
43
- if (typeof projectDirectoryUrl !== "string") {
44
- throw new TypeError(
45
- `projectDirectoryUrl must be a string, got ${projectDirectoryUrl}`,
46
- )
47
- }
48
- if (typeof compileServerOrigin !== "string") {
49
- throw new TypeError(
50
- `compileServerOrigin must be a string, got ${compileServerOrigin}`,
51
- )
52
- }
53
- if (typeof outDirectoryRelativeUrl !== "string") {
54
- throw new TypeError(
55
- `outDirectoryRelativeUrl must be a string, got ${outDirectoryRelativeUrl}`,
56
- )
57
- }
58
-
59
45
  env = {
60
46
  ...env,
61
47
  COVERAGE_ENABLED: collectCoverage,
@@ -100,7 +86,7 @@ nodeRuntime.launch = async ({
100
86
  const executeParams = {
101
87
  projectDirectoryUrl,
102
88
  compileServerOrigin,
103
- outDirectoryRelativeUrl,
89
+ jsenvDirectoryRelativeUrl,
104
90
  jsenvCoreDirectoryUrl,
105
91
 
106
92
  fileRelativeUrl,
@@ -115,45 +101,47 @@ nodeRuntime.launch = async ({
115
101
  remap,
116
102
  }
117
103
 
118
- // the computation of runtime features can be cached
119
- const nodeFeatures = await getNodeRuntimeReport({
104
+ // https://nodejs.org/docs/latest-v15.x/api/cli.html#cli_node_v8_coverage_dir
105
+ // instrumentation CAN be handed by process.env.NODE_V8_COVERAGE
106
+ // "transform-instrument" becomes non mandatory
107
+ const coverageHandledFromOutside =
108
+ !coverageForceIstanbul && process.env.NODE_V8_COVERAGE
109
+ const nodeRuntimeReport = await getNodeRuntimeReport({
120
110
  runtime: nodeRuntime,
121
111
  compileServerId,
122
112
  compileServerOrigin,
123
- outDirectoryRelativeUrl,
124
- // https://nodejs.org/docs/latest-v15.x/api/cli.html#cli_node_v8_coverage_dir
125
- // instrumentation CAN be handed by process.env.NODE_V8_COVERAGE
126
- // "transform-instrument" becomes non mandatory
127
- coverageHandledFromOutside:
128
- !coverageForceIstanbul && process.env.NODE_V8_COVERAGE,
129
- })
130
- const { canAvoidCompilation, compileId, importDefaultExtension } =
131
- nodeFeatures
132
113
 
114
+ moduleOutFormat,
115
+ forceCompilation,
116
+ coverageHandledFromOutside,
117
+ })
118
+ const { compileProfile, compileId } = nodeRuntimeReport
133
119
  let executionResult
134
- if (canAvoidCompilation && !forceSystemJs) {
120
+ if (compileId) {
135
121
  executionResult = await requestActionOnChildProcess({
136
122
  signal,
137
- actionType: "execute-using-dynamic-import",
138
- actionParams: executeParams,
139
- })
140
- } else {
141
- executionResult = await requestActionOnChildProcess({
142
- signal,
143
- actionType: "execute-using-systemjs",
123
+ actionType:
124
+ compileProfile.moduleOutFormat === "systemjs"
125
+ ? "execute-using-systemjs"
126
+ : "execute-using-dynamic-import",
144
127
  actionParams: {
145
128
  compileId,
146
- importDefaultExtension,
129
+ importDefaultExtension:
130
+ compileProfile.missingFeatures["import_default_extension"],
147
131
  ...executeParams,
148
132
  },
149
133
  })
134
+ } else {
135
+ executionResult = await requestActionOnChildProcess({
136
+ signal,
137
+ actionType: "execute-using-dynamic-import",
138
+ actionParams: executeParams,
139
+ })
150
140
  }
151
-
152
141
  executionResult = transformExecutionResult(executionResult, {
153
142
  compileServerOrigin,
154
143
  projectDirectoryUrl,
155
144
  })
156
-
157
145
  return executionResult
158
146
  }
159
147