@jsenv/core 24.6.5 → 25.0.0-alpha.3

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 (83) hide show
  1. package/dist/browser_runtime/asset-manifest.json +2 -1
  2. package/dist/browser_runtime/{browser_runtime-bb0e3aa4.js → browser_runtime_91c5a3b8.js} +137 -26
  3. package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +1089 -0
  4. package/dist/build_manifest.js +6 -6
  5. package/dist/compile_proxy/asset-manifest.json +2 -1
  6. package/dist/compile_proxy/{compile_proxy-6eb67db4.html → compile_proxy_7ad5faa6.html} +119 -26
  7. package/dist/compile_proxy/{compile_proxy.html__inline__20-9e168143.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +6 -6
  8. package/dist/event_source_client/asset-manifest.json +2 -1
  9. package/dist/event_source_client/{event_source_client-9f14c8b9.js → event_source_client_80644aee.js} +2 -2
  10. package/dist/event_source_client/{event_source_client-9f14c8b9.js.map → event_source_client_80644aee.js.map} +4 -3
  11. package/dist/redirector/asset-manifest.json +2 -1
  12. package/dist/redirector/{redirector.html__inline__15-3a34a156.js.map → redirector_e3b0c442_e391410e.js.map} +6 -6
  13. package/dist/redirector/{redirector-b6ad84bf.html → redirector_eb92e8a7.html} +119 -26
  14. package/dist/toolbar/asset-manifest.json +11 -10
  15. package/dist/toolbar/assets/{compilation.css-209d68b4.map → compilation.css_e37c747b.map} +1 -1
  16. package/dist/toolbar/assets/{eventsource.css-38cd0a36.map → eventsource.css_c0c71e7b.map} +1 -1
  17. package/dist/toolbar/assets/{execution.css-0ebe522f.map → execution.css_f3377c10.map} +1 -1
  18. package/dist/toolbar/assets/{focus.css-3f9c156d.map → focus.css_896f3e45.map} +1 -1
  19. package/dist/toolbar/assets/{light-theme.css-78b19a80.map → light-theme.css_72a60fa3.map} +1 -1
  20. package/dist/toolbar/assets/{overflow-menu.css-d9688a1c.map → overflow-menu.css_2859d519.map} +1 -1
  21. package/dist/toolbar/assets/{settings.css-2b81b245.map → settings.css_61548139.map} +1 -1
  22. package/dist/toolbar/assets/{toolbar.main.css-846920e9.map → toolbar.main.css_269d7ce2.map} +9 -9
  23. package/dist/toolbar/assets/{tooltip.css-03395ee6.map → tooltip.css_a94a8bdd.map} +1 -1
  24. package/dist/toolbar/{toolbar.main-a5ef2c60.js.map → toolbar.main2_6c1b3d82.js.map} +8 -8
  25. package/dist/toolbar/{toolbar-1fbf8dcb.html → toolbar_04ba410c.html} +129 -36
  26. package/dist/toolbar_injector/asset-manifest.json +3 -2
  27. package/dist/toolbar_injector/assets/{jsenv-logo-188b9ca6.svg → jsenv-logo_188b9ca6.svg} +0 -0
  28. package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js → toolbar_injector_4a48bc53.js} +3 -3
  29. package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js.map → toolbar_injector_4a48bc53.js.map} +2 -2
  30. package/package.json +5 -4
  31. package/readme.md +24 -91
  32. package/src/buildProject.js +51 -27
  33. package/src/dev_server.js +8 -2
  34. package/src/execute.js +7 -1
  35. package/src/executeTestPlan.js +17 -0
  36. package/src/internal/browser_feature_detection/browser_feature_detection.js +18 -25
  37. package/src/internal/browser_runtime/browser_runtime.js +2 -2
  38. package/src/internal/browser_runtime/createBrowserRuntime.js +1 -1
  39. package/src/internal/browser_runtime/displayErrorInDocument.js +2 -0
  40. package/src/internal/browser_runtime/displayErrorNotification.js +1 -1
  41. package/src/internal/building/buildUsingRollup.js +12 -15
  42. package/src/internal/building/build_logs.js +2 -2
  43. package/src/internal/building/build_stats.js +11 -1
  44. package/src/internal/building/html/parseHtmlRessource.js +2 -26
  45. package/src/internal/building/js/parseJsRessource.js +3 -2
  46. package/src/internal/building/json_module.js +11 -0
  47. package/src/internal/building/parseRessource.js +1 -1
  48. package/src/internal/building/ressource_builder.js +210 -216
  49. package/src/internal/building/rollup_plugin_jsenv.js +554 -378
  50. package/src/internal/building/url_loader.js +8 -145
  51. package/src/internal/building/url_versioning.js +220 -0
  52. package/src/internal/compiling/compileHtml.js +8 -1
  53. package/src/internal/compiling/createCompiledFileService.js +28 -40
  54. package/src/internal/compiling/html_source_file_service.js +66 -51
  55. package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +23 -0
  56. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -12
  57. package/src/internal/compiling/js-compilation-service/transformJs.js +2 -0
  58. package/src/internal/compiling/jsenvCompilerForHtml.js +43 -44
  59. package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
  60. package/src/internal/compiling/jsenvCompilerForJavaScript.js +9 -0
  61. package/src/internal/compiling/startCompileServer.js +29 -5
  62. package/src/internal/dev_server/event_source_client/livereload_preference.js +1 -1
  63. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -9
  64. package/src/internal/executing/executePlan.js +6 -0
  65. package/src/internal/generateGroupMap/{jsenvBabelPluginCompatMap.js → babel_plugins_compatibility.js} +0 -0
  66. package/src/internal/generateGroupMap/{featuresCompatMap.js → features_compatibility.js} +9 -1
  67. package/src/internal/generateGroupMap/generateGroupMap.js +6 -35
  68. package/src/internal/generateGroupMap/one_runtime_compat.js +9 -12
  69. package/src/internal/generateGroupMap/runtime_compat.js +10 -15
  70. package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -2
  71. package/src/internal/generateGroupMap/shake_babel_plugin_map.js +21 -0
  72. package/src/internal/import-resolution/importmap_default.js +52 -0
  73. package/src/internal/node_feature_detection/node_feature_detection.js +25 -19
  74. package/src/internal/runtime/s.js +101 -6
  75. package/src/internal/unevalException.js +1 -1
  76. package/src/jsenvServiceWorkerFinalizer.js +12 -17
  77. package/dist/browser_runtime/browser_runtime-bb0e3aa4.js.map +0 -1067
  78. package/src/internal/building/asset_url_versioning.js +0 -50
  79. package/src/internal/building/rollup_build_sourcemap.js +0 -54
  80. package/src/internal/building/url-versioning.js +0 -96
  81. package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
  82. package/src/internal/import-resolution/importmap-default.js +0 -34
  83. package/src/internal/renderNamePattern.js +0 -6
@@ -2,6 +2,7 @@ import { createLogger, createDetailedMessage } from "@jsenv/logger"
2
2
  import { resolveDirectoryUrl } from "@jsenv/filesystem"
3
3
  import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
4
4
 
5
+ import { shakeBabelPluginMap } from "@jsenv/core/src/internal/generateGroupMap/shake_babel_plugin_map.js"
5
6
  import { COMPILE_ID_BEST } from "./internal/CONSTANTS.js"
6
7
  import {
7
8
  assertProjectDirectoryUrl,
@@ -14,6 +15,15 @@ import {
14
15
  jsenvNodeRuntimeSupport,
15
16
  } from "./internal/generateGroupMap/jsenvRuntimeSupport.js"
16
17
 
18
+ /**
19
+ * Generate optimized version of source files into a directory
20
+ * @param {string|url} projectDirectoryUrl Root directory of the project
21
+ * @param {string|url} buildDirectoryRelativeUrl Directory where optimized files are written
22
+ * @param {object} entryPoints Describe entry point paths and control their names in the build directory
23
+ * @param {"esmodule" | "systemjs" | "commonjs" | "global"} format Code generated will use this module format
24
+ * @param {object} runtimeSupport Code generated will be compatible with these runtimes
25
+ * @param {boolean} [minify=false] Minify file content in the build directory (HTML, CSS, JS, JSON, SVG)
26
+ */
17
27
  export const buildProject = async ({
18
28
  signal = new AbortController().signal,
19
29
  handleSIGINT = true,
@@ -22,7 +32,13 @@ export const buildProject = async ({
22
32
  logger,
23
33
 
24
34
  projectDirectoryUrl,
25
- entryPointMap,
35
+ entryPoints,
36
+ workers = [],
37
+ serviceWorkers = [],
38
+ serviceWorkerFinalizer,
39
+ classicWorkers = [],
40
+ classicServiceWorkers = [],
41
+ importMapInWebWorkers = false,
26
42
  buildDirectoryRelativeUrl,
27
43
  buildDirectoryClean = true,
28
44
  assetManifestFile = false,
@@ -57,7 +73,6 @@ export const buildProject = async ({
57
73
  urlVersioning = format === "systemjs" ||
58
74
  format === "esmodule" ||
59
75
  format === "global",
60
- urlVersionningForEntryPoints = false,
61
76
  lineBreakNormalization = process.platform === "win32",
62
77
  // when jsConcatenation is disabled rollup becomes almost useless
63
78
  // except it can still do tree shaking
@@ -78,10 +93,6 @@ export const buildProject = async ({
78
93
  // https://github.com/cssnano/cssnano/tree/master/packages/cssnano-preset-default
79
94
  minifyCssOptions,
80
95
 
81
- workers = {},
82
- serviceWorkers = {},
83
- serviceWorkerFinalizer,
84
-
85
96
  env = {},
86
97
  protocol,
87
98
  privateKey,
@@ -113,14 +124,19 @@ export const buildProject = async ({
113
124
  `runtimeSupport must be an object, got ${runtimeSupport}`,
114
125
  )
115
126
  }
127
+ if (format !== "systemjs" && importMapInWebWorkers) {
128
+ throw new Error(
129
+ `format must be "systemjs" when importMapInWebWorkers is enabled`,
130
+ )
131
+ }
116
132
 
117
133
  projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
118
134
  await assertProjectDirectoryExists({ projectDirectoryUrl })
119
135
 
120
- assertEntryPointMap({ entryPointMap })
136
+ assertentryPoints({ entryPoints })
121
137
 
122
- if (Object.keys(entryPointMap).length === 0) {
123
- logger.error(`entryPointMap is an empty object`)
138
+ if (Object.keys(entryPoints).length === 0) {
139
+ logger.error(`entryPoints is an empty object`)
124
140
  return {
125
141
  rollupBuilds: {},
126
142
  }
@@ -165,6 +181,7 @@ export const buildProject = async ({
165
181
  moduleOutFormat: "esmodule", // rollup will transform into the right format
166
182
  importMetaFormat: "esmodule", // rollup will transform into the right format
167
183
  topLevelAwait: "ignore", // rollup will transform if needed
184
+ prependSystemJs: false,
168
185
 
169
186
  protocol,
170
187
  privateKey,
@@ -173,9 +190,10 @@ export const buildProject = async ({
173
190
  port,
174
191
  env,
175
192
  babelPluginMap,
176
- customCompilers,
193
+ workers,
194
+ serviceWorkers,
177
195
  runtimeSupport,
178
-
196
+ customCompilers,
179
197
  compileServerCanReadFromFilesystem: filesystemCache,
180
198
  compileServerCanWriteOnFilesystem: filesystemCache,
181
199
  // keep source html untouched
@@ -197,7 +215,7 @@ export const buildProject = async ({
197
215
  buildOperation,
198
216
  logger,
199
217
 
200
- entryPointMap,
218
+ entryPoints,
201
219
  projectDirectoryUrl,
202
220
  compileServerOrigin,
203
221
  compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${COMPILE_ID_BEST}/`,
@@ -218,11 +236,21 @@ export const buildProject = async ({
218
236
  systemJsUrl,
219
237
  globalName,
220
238
  globals,
221
- babelPluginMap: compileServer.babelPluginMap,
239
+ babelPluginMap: shakeBabelPluginMap({
240
+ babelPluginMap: compileServer.babelPluginMap,
241
+ missingFeatureNames:
242
+ compileServer.compileServerGroupMap[COMPILE_ID_BEST]
243
+ .missingFeatureNames,
244
+ }),
222
245
  runtimeSupport,
246
+ workers,
247
+ serviceWorkers,
248
+ serviceWorkerFinalizer,
249
+ classicWorkers,
250
+ classicServiceWorkers,
251
+ importMapInWebWorkers,
223
252
 
224
253
  urlVersioning,
225
- urlVersionningForEntryPoints,
226
254
  lineBreakNormalization,
227
255
  useImportMapToMaximizeCacheReuse,
228
256
  preserveEntrySignatures,
@@ -235,10 +263,6 @@ export const buildProject = async ({
235
263
  minifyJsOptions,
236
264
  minifyCssOptions,
237
265
 
238
- workers,
239
- serviceWorkers,
240
- serviceWorkerFinalizer,
241
-
242
266
  writeOnFileSystem,
243
267
  sourcemapExcludeSources,
244
268
  })
@@ -255,27 +279,27 @@ export const buildProject = async ({
255
279
  }
256
280
  }
257
281
 
258
- const assertEntryPointMap = ({ entryPointMap }) => {
259
- if (typeof entryPointMap !== "object") {
260
- throw new TypeError(`entryPointMap must be an object, got ${entryPointMap}`)
282
+ const assertentryPoints = ({ entryPoints }) => {
283
+ if (typeof entryPoints !== "object") {
284
+ throw new TypeError(`entryPoints must be an object, got ${entryPoints}`)
261
285
  }
262
- const keys = Object.keys(entryPointMap)
286
+ const keys = Object.keys(entryPoints)
263
287
  keys.forEach((key) => {
264
288
  if (!key.startsWith("./")) {
265
289
  throw new TypeError(
266
- `unexpected key in entryPointMap, all keys must start with ./ but found ${key}`,
290
+ `unexpected key in entryPoints, all keys must start with ./ but found ${key}`,
267
291
  )
268
292
  }
269
293
 
270
- const value = entryPointMap[key]
294
+ const value = entryPoints[key]
271
295
  if (typeof value !== "string") {
272
296
  throw new TypeError(
273
- `unexpected value in entryPointMap, all values must be strings found ${value} for key ${key}`,
297
+ `unexpected value in entryPoints, all values must be strings found ${value} for key ${key}`,
274
298
  )
275
299
  }
276
- if (!value.startsWith("./")) {
300
+ if (value.includes("/")) {
277
301
  throw new TypeError(
278
- `unexpected value in entryPointMap, all values must starts with ./ but found ${value} for key ${key}`,
302
+ `unexpected value in entryPoints, all values must be plain strings (no "/") but found ${value} for key ${key}`,
279
303
  )
280
304
  }
281
305
  })
package/src/dev_server.js CHANGED
@@ -45,17 +45,20 @@ export const startDevServer = async ({
45
45
  keepProcessAlive = true,
46
46
 
47
47
  babelPluginMap,
48
+ workers,
49
+ serviceWorkers,
50
+ importMapInWebWorkers,
51
+ customCompilers,
48
52
  runtimeSupportDuringDev = {
49
53
  // this allows to compile nothing or almost nothing when opening files
50
54
  // with a recent chrome. Without this we would compile all the things not yet unsupported
51
55
  // by Firefox and Safari such as top level await, importmap, etc
52
- chrome: "93",
56
+ chrome: "96",
53
57
  },
54
58
  logLevel,
55
59
  compileServerCanReadFromFilesystem,
56
60
  compileServerCanWriteOnFilesystem,
57
61
  sourcemapMethod,
58
- customCompilers,
59
62
  livereloadWatchConfig,
60
63
  livereloadLogLevel,
61
64
  jsenvDirectoryClean,
@@ -124,6 +127,9 @@ export const startDevServer = async ({
124
127
  customCompilers,
125
128
  sourcemapMethod,
126
129
  babelPluginMap,
130
+ workers,
131
+ serviceWorkers,
132
+ importMapInWebWorkers,
127
133
  runtimeSupport: runtimeSupportDuringDev,
128
134
  livereloadWatchConfig,
129
135
  livereloadLogLevel,
package/src/execute.js CHANGED
@@ -46,6 +46,9 @@ export const execute = async ({
46
46
  port,
47
47
  babelPluginMap,
48
48
  customCompilers,
49
+ workers,
50
+ serviceWorkers,
51
+ importMapInWebWorkers,
49
52
  compileServerCanReadFromFilesystem,
50
53
  compileServerCanWriteOnFilesystem,
51
54
 
@@ -105,10 +108,13 @@ export const execute = async ({
105
108
  ip,
106
109
  port,
107
110
  babelPluginMap,
108
- customCompilers,
109
111
  runtimeSupport: normalizeRuntimeSupport({
110
112
  [runtime.name]: runtime.version,
111
113
  }),
114
+ customCompilers,
115
+ workers,
116
+ serviceWorkers,
117
+ importMapInWebWorkers,
112
118
  compileServerCanReadFromFilesystem,
113
119
  compileServerCanWriteOnFilesystem,
114
120
  })
@@ -19,6 +19,17 @@ import { generateCoverageHtmlDirectory } from "./internal/executing/coverage_rep
19
19
  import { generateCoverageTextLog } from "./internal/executing/coverage_reporter/coverage_reporter_text_log.js"
20
20
  import { jsenvCoverageConfig } from "./jsenvCoverageConfig.js"
21
21
 
22
+ /**
23
+ * Execute a list of files and log how it goes
24
+ * @param {object} testPlan Configure files to execute and their runtimes (browsers/node)
25
+ * @param {string|url} projectDirectoryUrl Root directory of the project
26
+ * @param {number} [maxExecutionsInParallel=1] Maximum amount of execution in parallel
27
+ * @param {number} [defaultMsAllocatedPerExecution=30000] Milliseconds after which execution is aborted and considered as failed by timeout
28
+ * @param {number} [cooldownBetweenExecutions=0] Millisecond to wait between each execution
29
+ * @param {boolean} [logMemoryHeapUsage=false] Add memory heap usage during logs
30
+ * @param {boolean} [coverage=false] Controls if coverage is collected during files executions
31
+ * @param {boolean} [coverageV8ConflictWarning=true] Warn when coverage from 2 executions cannot be merged
32
+ */
22
33
  export const executeTestPlan = async ({
23
34
  signal = new AbortController().signal,
24
35
  handleSIGINT = true,
@@ -79,6 +90,9 @@ export const executeTestPlan = async ({
79
90
  compileServerCanWriteOnFilesystem,
80
91
  babelPluginMap,
81
92
  babelConfigFileUrl,
93
+ workers,
94
+ serviceWorkers,
95
+ importMapInWebWorkers,
82
96
  customCompilers,
83
97
  jsenvDirectoryClean,
84
98
  }) => {
@@ -179,6 +193,9 @@ export const executeTestPlan = async ({
179
193
  compileServerCanWriteOnFilesystem,
180
194
  babelPluginMap,
181
195
  babelConfigFileUrl,
196
+ workers,
197
+ serviceWorkers,
198
+ importMapInWebWorkers,
182
199
  customCompilers,
183
200
  })
184
201
 
@@ -36,17 +36,14 @@ export const scanBrowserRuntimeFeatures = async ({
36
36
  failFastOnFeatureDetection,
37
37
  inlineImportMapIntoHTML,
38
38
  })
39
- const pluginRequiredNameArray = await pluginRequiredNamesFromGroupInfo(
40
- groupInfo,
41
- {
42
- featuresReport,
43
- coverageHandledFromOutside,
44
- },
45
- )
39
+ const missingFeatureNames = await adjustMissingFeatureNames(groupInfo, {
40
+ featuresReport,
41
+ coverageHandledFromOutside,
42
+ })
46
43
 
47
44
  const canAvoidCompilation =
48
45
  customCompilerPatterns.length === 0 &&
49
- pluginRequiredNameArray.length === 0 &&
46
+ missingFeatureNames.length === 0 &&
50
47
  featuresReport.importmap &&
51
48
  featuresReport.dynamicImport &&
52
49
  featuresReport.topLevelAwait
@@ -55,7 +52,7 @@ export const scanBrowserRuntimeFeatures = async ({
55
52
  canAvoidCompilation,
56
53
  featuresReport,
57
54
  customCompilerPatterns,
58
- pluginRequiredNameArray,
55
+ missingFeatureNames,
59
56
  inlineImportMapIntoHTML,
60
57
  outDirectoryRelativeUrl,
61
58
  compileId,
@@ -63,27 +60,25 @@ export const scanBrowserRuntimeFeatures = async ({
63
60
  }
64
61
  }
65
62
 
66
- const pluginRequiredNamesFromGroupInfo = async (
63
+ const adjustMissingFeatureNames = async (
67
64
  groupInfo,
68
65
  { featuresReport, coverageHandledFromOutside },
69
66
  ) => {
70
- const { pluginRequiredNameArray } = groupInfo
71
- const requiredPluginNames = pluginRequiredNameArray.slice()
72
- const markPluginAsSupported = (name) => {
73
- const index = requiredPluginNames.indexOf(name)
67
+ const { missingFeatureNames } = groupInfo
68
+ const missingFeatureNamesCopy = missingFeatureNames.slice()
69
+ const markAsSupported = (name) => {
70
+ const index = missingFeatureNamesCopy.indexOf(name)
74
71
  if (index > -1) {
75
- requiredPluginNames.splice(index, 1)
72
+ missingFeatureNamesCopy.splice(index, 1)
76
73
  }
77
74
  }
78
-
79
75
  // When instrumentation CAN be handed by playwright
80
76
  // https://playwright.dev/docs/api/class-chromiumcoverage#chromiumcoveragestartjscoverageoptions
81
77
  // coverageHandledFromOutside is true and "transform-instrument" becomes non mandatory
82
78
  if (coverageHandledFromOutside) {
83
- markPluginAsSupported("transform-instrument")
79
+ markAsSupported("transform-instrument")
84
80
  }
85
-
86
- if (pluginRequiredNameArray.includes("transform-import-assertions")) {
81
+ if (missingFeatureNames.includes("transform-import-assertions")) {
87
82
  const jsonImportAssertions = await supportsJsonImportAssertions()
88
83
  featuresReport.jsonImportAssertions = jsonImportAssertions
89
84
 
@@ -91,17 +86,15 @@ const pluginRequiredNamesFromGroupInfo = async (
91
86
  featuresReport.cssImportAssertions = cssImportAssertions
92
87
 
93
88
  if (jsonImportAssertions && cssImportAssertions) {
94
- markPluginAsSupported("transform-import-assertions")
89
+ markAsSupported("transform-import-assertions")
95
90
  }
96
91
  }
97
-
98
- if (pluginRequiredNameArray.includes("new-stylesheet-as-jsenv-import")) {
92
+ if (missingFeatureNames.includes("new-stylesheet-as-jsenv-import")) {
99
93
  const newStylesheet = supportsNewStylesheet()
100
94
  featuresReport.newStylesheet = newStylesheet
101
- markPluginAsSupported("new-stylesheet-as-jsenv-import")
95
+ markAsSupported("new-stylesheet-as-jsenv-import")
102
96
  }
103
-
104
- return requiredPluginNames
97
+ return missingFeatureNamesCopy
105
98
  }
106
99
 
107
100
  const detectSupportedFeatures = async ({
@@ -127,12 +127,12 @@ const onExecutionError = (
127
127
  },
128
128
  ) => {
129
129
  const error = executionResult.error
130
- if (error.code === "NETWORK_FAILURE") {
130
+ if (error && error.code === "NETWORK_FAILURE") {
131
131
  if (currentScript) {
132
132
  const errorEvent = new Event("error")
133
133
  currentScript.dispatchEvent(errorEvent)
134
134
  }
135
- } else {
135
+ } else if (typeof error === "object") {
136
136
  const { parsingError } = error
137
137
  const globalErrorEvent = new Event("error")
138
138
  if (parsingError) {
@@ -40,7 +40,7 @@ export const createBrowserRuntime = async ({
40
40
  // if there is an importmap in the document we use it instead of fetching.
41
41
  // systemjs style with systemjs-importmap
42
42
  const importmapScript = document.querySelector(
43
- `script[type="jsenv-importmap"]`,
43
+ `script[type="systemjs-importmap"]`,
44
44
  )
45
45
  let importMap
46
46
  let importMapUrl
@@ -102,6 +102,8 @@ const errorToHTML = (error) => {
102
102
  }
103
103
  } else if (typeof error === "string") {
104
104
  html = error
105
+ } else if (error === undefined) {
106
+ html = "undefined"
105
107
  } else {
106
108
  html = JSON.stringify(error)
107
109
  }
@@ -7,7 +7,7 @@ const displayErrorNotificationImplementation = (error, { icon } = {}) => {
7
7
  if (Notification.permission === "granted") {
8
8
  const notification = new Notification("An error occured", {
9
9
  lang: "en",
10
- body: error.stack,
10
+ body: error ? error.stack : "undefined",
11
11
  icon,
12
12
  })
13
13
  notification.onclick = () => {
@@ -13,7 +13,6 @@ import {
13
13
  isNodePartOfSupportedRuntimes,
14
14
  isBrowserPartOfSupportedRuntimes,
15
15
  } from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
16
- import { featuresCompatMap } from "@jsenv/core/src/internal/generateGroupMap/featuresCompatMap.js"
17
16
  import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
18
17
  import { createRollupPlugins } from "./rollup_plugin_jsenv.js"
19
18
 
@@ -22,7 +21,7 @@ export const buildUsingRollup = async ({
22
21
  logger,
23
22
 
24
23
  projectDirectoryUrl,
25
- entryPointMap,
24
+ entryPoints,
26
25
  compileServerOrigin,
27
26
  compileDirectoryRelativeUrl,
28
27
  buildDirectoryUrl,
@@ -49,9 +48,10 @@ export const buildUsingRollup = async ({
49
48
  workers,
50
49
  serviceWorkers,
51
50
  serviceWorkerFinalizer,
51
+ classicWorkers,
52
+ classicServiceWorkers,
52
53
 
53
54
  urlVersioning,
54
- urlVersionningForEntryPoints,
55
55
  lineBreakNormalization,
56
56
  jsConcatenation,
57
57
  cssConcatenation,
@@ -69,21 +69,17 @@ export const buildUsingRollup = async ({
69
69
 
70
70
  const runtimeCompatMap = createRuntimeCompat({
71
71
  runtimeSupport,
72
- pluginMap: {
73
- import_assertion_type_json: true,
74
- import_assertion_type_css: true,
75
- },
76
- pluginCompatMap: featuresCompatMap,
72
+ featureNames: ["import_assertion_type_json", "import_assertion_type_css"],
77
73
  })
78
74
  const importAssertionsSupport = {
79
75
  json:
80
76
  format === "esmodule" &&
81
- !runtimeCompatMap.pluginRequiredNameArray.includes(
77
+ !runtimeCompatMap.missingFeatureNames.includes(
82
78
  "import_assertion_type_json",
83
79
  ),
84
80
  css:
85
81
  format === "esmodule" &&
86
- !runtimeCompatMap.pluginRequiredNameArray.includes(
82
+ !runtimeCompatMap.missingFeatureNames.includes(
87
83
  "import_assertion_type_json",
88
84
  ),
89
85
  }
@@ -99,7 +95,7 @@ export const buildUsingRollup = async ({
99
95
  logger,
100
96
 
101
97
  projectDirectoryUrl,
102
- entryPointMap,
98
+ entryPoints,
103
99
  compileServerOrigin,
104
100
  compileDirectoryRelativeUrl,
105
101
  buildDirectoryUrl,
@@ -121,9 +117,10 @@ export const buildUsingRollup = async ({
121
117
  workers,
122
118
  serviceWorkers,
123
119
  serviceWorkerFinalizer,
120
+ classicWorkers,
121
+ classicServiceWorkers,
124
122
 
125
123
  urlVersioning,
126
- urlVersionningForEntryPoints,
127
124
  lineBreakNormalization,
128
125
  jsConcatenation,
129
126
  cssConcatenation,
@@ -204,7 +201,7 @@ export const buildUsingRollup = async ({
204
201
  buildFileContents,
205
202
  buildInlineFileContents,
206
203
  buildStats,
207
- } = getResult()
204
+ } = await getResult()
208
205
 
209
206
  if (writeOnFileSystem) {
210
207
  if (buildDirectoryClean) {
@@ -264,7 +261,7 @@ const useRollup = async ({
264
261
 
265
262
  const rollupInputOptions = {
266
263
  // about cache here, we should/could reuse previous rollup call
267
- // to get the cache from the entryPointMap
264
+ // to get the cache from the entryPoints
268
265
  // as shown here: https://rollupjs.org/guide/en#cache
269
266
  // it could be passed in arguments to this function
270
267
  // however parallelism and having different rollup options per
@@ -307,7 +304,7 @@ const useRollup = async ({
307
304
  logger.warn(String(warning))
308
305
  },
309
306
  // on passe input: [] car c'est le plugin jsenv qui se chargera d'emit des chunks
310
- // en fonction de entryPointMap
307
+ // en fonction de entryPoints
311
308
  // on fait cela car sinon rollup est pénible si on passe un input de type html
312
309
  input: [],
313
310
  preserveEntrySignatures,
@@ -5,8 +5,8 @@ import { byteAsFileSize } from "../logs/byteAsFileSize.js"
5
5
  import { msAsDuration } from "../logs/msAsDuration.js"
6
6
  import { stringifyUrlSite } from "./url_trace.js"
7
7
 
8
- export const formatBuildStartLog = ({ entryPointMap }) => {
9
- const entryFileRelativeUrls = Object.keys(entryPointMap)
8
+ export const formatBuildStartLog = ({ entryPoints }) => {
9
+ const entryFileRelativeUrls = Object.keys(entryPoints)
10
10
  if (entryFileRelativeUrls.length === 1) {
11
11
  return `
12
12
  building ${entryFileRelativeUrls[0]}...`
@@ -59,7 +59,13 @@ const getProjectFileContents = (ressourceBuilder) => {
59
59
 
60
60
  Object.keys(ressourceMap).forEach((url) => {
61
61
  const ressource = ressourceMap[url]
62
- const { isInline, isExternal, isPlaceholder, bufferBeforeBuild } = ressource
62
+ const {
63
+ isInline,
64
+ isExternal,
65
+ isPlaceholder,
66
+ isSourcemap,
67
+ bufferBeforeBuild,
68
+ } = ressource
63
69
  if (isInline) {
64
70
  // inline ressources are not files
65
71
  return
@@ -80,6 +86,10 @@ const getProjectFileContents = (ressourceBuilder) => {
80
86
  // to generate it in the build
81
87
  return
82
88
  }
89
+ if (isSourcemap && !bufferBeforeBuild) {
90
+ // sourcemap generated by rollup do not have bufferBeforeBuild
91
+ return
92
+ }
83
93
  projectFileContents[url] = bufferBeforeBuild
84
94
  })
85
95
  return projectFileContents
@@ -16,12 +16,7 @@ Or be sure to also reference this url somewhere in the html file like
16
16
 
17
17
  */
18
18
 
19
- import {
20
- urlToFilename,
21
- urlToRelativeUrl,
22
- resolveUrl,
23
- urlToParentUrl,
24
- } from "@jsenv/filesystem"
19
+ import { urlToFilename, urlToRelativeUrl, resolveUrl } from "@jsenv/filesystem"
25
20
 
26
21
  import {
27
22
  parseHtmlString,
@@ -255,7 +250,7 @@ const regularScriptTextNodeVisitor = (
255
250
  })
256
251
  return () => {
257
252
  const { bufferAfterBuild } = jsReference.ressource
258
- textNode.value = bufferAfterBuild
253
+ textNode.value = String(bufferAfterBuild)
259
254
  }
260
255
  }
261
256
 
@@ -359,8 +354,6 @@ const moduleScriptTextNodeVisitor = (
359
354
  }
360
355
  const { bufferAfterBuild } = jsReference.ressource
361
356
  const jsText = String(bufferAfterBuild)
362
- // ici on voudrait pouvoir ajouter le commentaire de la sourcemap
363
- // sauf que cela se produit un poil plus tard je crois?
364
357
  textNode.value = jsText
365
358
  }
366
359
  }
@@ -386,23 +379,6 @@ const importmapScriptSrcVisitor = (
386
379
  contentTypeExpected: "application/importmap+json",
387
380
  ressourceSpecifier: srcAttribute.value,
388
381
  ...referenceLocationFromHtmlNode(script, "src"),
389
- // here we want to force the fileName for the importmap
390
- // so that we don't have to rewrite its content
391
- // the goal is to put the importmap at the same relative path
392
- // than in the project
393
- fileNamePattern: () => {
394
- const importmapReferenceUrl = importmapReference.referenceUrl
395
- const importmapRessourceUrl = importmapReference.ressource.url
396
- const importmapUrlRelativeToImporter = urlToRelativeUrl(
397
- importmapRessourceUrl,
398
- importmapReferenceUrl,
399
- )
400
- const importmapParentRelativeUrl = urlToRelativeUrl(
401
- urlToParentUrl(resolveUrl(importmapUrlRelativeToImporter, "file://")),
402
- "file://",
403
- )
404
- return `${importmapParentRelativeUrl}[name]-[hash][extname]`
405
- },
406
382
  })
407
383
  return ({ getUrlRelativeToImporter }) => {
408
384
  const { ressource } = importmapReference
@@ -103,9 +103,10 @@ export const parseJsRessource = async (
103
103
  map.file = urlToFilename(jsBuildUrl)
104
104
  if (map.sources) {
105
105
  map.sources = map.sources.map((source) => {
106
- const sourceUrl = resolveUrl(source, jsOriginalUrl)
106
+ const sourceUrl = resolveUrl(source, jsUrl)
107
+ const sourceOriginalUrl = asOriginalUrl(sourceUrl)
107
108
  const sourceUrlRelativeToSourceMap = urlToRelativeUrl(
108
- sourceUrl,
109
+ sourceOriginalUrl,
109
110
  sourcemapPrecomputedBuildUrl,
110
111
  )
111
112
  return sourceUrlRelativeToSourceMap
@@ -0,0 +1,11 @@
1
+ export const convertJsonTextToJavascriptModule = ({ code }) => {
2
+ // here we could do the following
3
+ // return export default jsonText
4
+ // This would return valid js, that would be minified later
5
+ // however we will prefer using JSON.parse because it's faster
6
+ // for js engine to parse JSON than JS
7
+
8
+ return {
9
+ code: `export default JSON.parse(${JSON.stringify(code.trim())})`,
10
+ }
11
+ }
@@ -22,7 +22,7 @@ import { parseJsRessource } from "./js/parseJsRessource.js"
22
22
  import { parseJsonRessource } from "./json/parseJsonRessource.js"
23
23
  import { parseWebmanifestRessource } from "./webmanifest/parseWebmanifestRessource.js"
24
24
 
25
- export const parseRessource = (
25
+ export const parseRessource = async (
26
26
  ressource,
27
27
  notifiers,
28
28
  {