@jsenv/core 22.4.0 → 23.0.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.
Files changed (106) hide show
  1. package/dist/jsenv_browser_system.js +331 -256
  2. package/dist/jsenv_browser_system.js.map +55 -33
  3. package/dist/jsenv_compile_proxy.js +186 -108
  4. package/dist/jsenv_compile_proxy.js.map +48 -42
  5. package/dist/jsenv_exploring_redirector.js +148 -71
  6. package/dist/jsenv_exploring_redirector.js.map +26 -20
  7. package/dist/jsenv_toolbar.js +215 -104
  8. package/dist/jsenv_toolbar.js.map +39 -26
  9. package/helpers/new_stylesheet/new_stylesheet.js +411 -0
  10. package/{LICENSE → license} +0 -0
  11. package/main.js +8 -7
  12. package/package.json +23 -19
  13. package/readme.md +9 -6
  14. package/src/buildProject.js +3 -7
  15. package/src/execute.js +23 -10
  16. package/src/executeTestPlan.js +0 -4
  17. package/src/importUsingChildProcess.js +36 -32
  18. package/src/internal/{babel-plugin-replace-expressions.js → babel_plugin_replace_expressions.js} +0 -0
  19. package/src/internal/{babel-plugin-transform-import-meta.js → babel_plugin_transform_import_meta.js} +0 -0
  20. package/src/internal/browser-launcher/executeHtmlFile.js +6 -8
  21. package/src/internal/browser-launcher/jsenv-browser-system.js +3 -0
  22. package/src/internal/building/asset_url_versioning.js +5 -9
  23. package/src/internal/building/buildServiceWorker.js +6 -13
  24. package/src/internal/building/buildUsingRollup.js +41 -4
  25. package/src/internal/building/build_logs.js +11 -0
  26. package/src/internal/building/build_stats.js +7 -1
  27. package/src/internal/building/createJsenvRollupPlugin.js +402 -297
  28. package/src/internal/building/css/parseCssRessource.js +67 -71
  29. package/src/internal/building/css/parseCssUrls.js +2 -2
  30. package/src/internal/building/css/{postcss-urlhash-plugin.js → postcss_plugin_url_visitor.js} +43 -21
  31. package/src/internal/building/css/replaceCssUrls.js +17 -14
  32. package/src/internal/building/css_module.js +47 -0
  33. package/src/internal/building/html/parseHtmlRessource.js +44 -43
  34. package/src/internal/building/import_references.js +81 -0
  35. package/src/internal/building/importmap/parseImportmapRessource.js +5 -2
  36. package/src/internal/building/js/minifyJs.js +30 -3
  37. package/src/internal/building/js/parseJsRessource.js +70 -77
  38. package/src/internal/building/json/parseJsonRessource.js +3 -2
  39. package/src/internal/building/parseRessource.js +11 -8
  40. package/src/internal/building/parsing.utils.js +4 -15
  41. package/src/internal/building/ressource_builder.js +142 -114
  42. package/src/internal/building/ressource_builder_util.js +31 -18
  43. package/src/internal/building/{fetchSourcemap.js → sourcemap_loader.js} +29 -27
  44. package/src/internal/building/svg/parseSvgRessource.js +7 -3
  45. package/src/internal/building/url-versioning.js +2 -1
  46. package/src/internal/building/url_fetcher.js +79 -0
  47. package/src/internal/building/url_loader.js +267 -0
  48. package/src/internal/building/url_trace.js +1 -1
  49. package/src/internal/building/webmanifest/parseWebmanifestRessource.js +9 -4
  50. package/src/internal/compiling/{js-compilation-service/ensureGlobalThisImportBabelPlugin.js → babel_plugin_global_this_as_jsenv_import.js} +4 -2
  51. package/src/internal/compiling/babel_plugin_import_assertions.js +100 -0
  52. package/src/internal/compiling/babel_plugin_new_stylesheet_as_jsenv_import.js +109 -0
  53. package/src/internal/compiling/babel_plugin_transform_import_specifier.js +86 -0
  54. package/src/internal/compiling/babel_plugins.js +2 -0
  55. package/src/internal/compiling/createCompiledFileService.js +46 -15
  56. package/src/internal/compiling/html_source_file_service.js +2 -2
  57. package/src/internal/compiling/js-compilation-service/{transformBabelHelperToImportBabelPlugin.js → babel_plugin_babel_helpers_as_jsenv_imports.js} +1 -1
  58. package/src/internal/compiling/js-compilation-service/{ensureRegeneratorRuntimeImportBabelPlugin.js → babel_plugin_regenerator_runtime_as_jsenv_import.js} +1 -1
  59. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +7 -16
  60. package/src/internal/compiling/js-compilation-service/transformJs.js +0 -2
  61. package/src/internal/compiling/jsenvCompilerForHtml.js +2 -7
  62. package/src/internal/compiling/rollup_plugin_commonjs_named_exports.js +2 -2
  63. package/src/internal/compiling/startCompileServer.js +11 -4
  64. package/src/internal/escapeTemplateStringSpecialCharacters.js +20 -0
  65. package/src/internal/executing/coverage/{babel-plugin-instrument.js → babel_plugin_instrument.js} +17 -6
  66. package/src/internal/executing/coverage/relativeUrlToEmptyCoverage.js +1 -1
  67. package/src/internal/executing/executeConcurrently.js +5 -3
  68. package/src/internal/executing/executePlan.js +16 -2
  69. package/src/internal/executing/generateFileExecutionSteps.js +2 -1
  70. package/src/internal/executing/launchAndExecute.js +43 -69
  71. package/src/internal/executing/writeLog.js +25 -18
  72. package/src/internal/exploring/exploring.css +2 -1
  73. package/src/internal/exploring/exploring.redirector.js +0 -1
  74. package/src/internal/generateGroupMap/generateGroupMap.js +14 -10
  75. package/src/internal/generateGroupMap/jsenvBabelPluginCompatMap.js +30 -0
  76. package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -6
  77. package/src/internal/generateGroupMap/one_runtime_compat.js +9 -38
  78. package/src/internal/generateGroupMap/runtime_compat.js +9 -24
  79. package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -12
  80. package/src/internal/generateGroupMap/runtime_support.js +53 -0
  81. package/src/internal/jsenvInternalFiles.js +0 -1
  82. package/src/internal/node-launcher/createControllableNodeProcess.js +2 -3
  83. package/src/internal/response_validation.js +143 -0
  84. package/src/internal/runtime/createBrowserRuntime/createBrowserRuntime.js +8 -3
  85. package/src/internal/runtime/createBrowserRuntime/createBrowserSystem.js +165 -25
  86. package/src/internal/runtime/createBrowserRuntime/displayErrorInDocument.js +7 -6
  87. package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +124 -68
  88. package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +8 -86
  89. package/src/internal/runtime/createNodeRuntime/createNodeSystem.js +53 -9
  90. package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +115 -0
  91. package/src/internal/runtime/module-registration.js +86 -136
  92. package/src/internal/runtime/resolveGroup.js +2 -3
  93. package/src/internal/toolbar/compilation/toolbar.compilation.js +15 -17
  94. package/src/internal/toolbar/eventsource/toolbar.eventsource.js +35 -8
  95. package/src/internal/toolbar/toolbar.main.js +7 -4
  96. package/src/internal/url_utils.js +33 -0
  97. package/src/internal/url_utils.test.js +39 -0
  98. package/src/jsonToJavaScriptModule.js +12 -0
  99. package/src/launchBrowser.js +50 -34
  100. package/src/launchNode.js +6 -3
  101. package/src/requireUsingChildProcess.js +36 -32
  102. package/src/startExploring.js +25 -11
  103. package/src/internal/building/transformImportMetaUrlReferences.js +0 -71
  104. package/src/internal/runtime/resolveBrowserGroup.js +0 -5
  105. package/src/internal/runtime/resolveNodeGroup.js +0 -5
  106. package/src/internal/validateResponseStatusIsOk.js +0 -91
@@ -0,0 +1,411 @@
1
+ /* eslint-disable */
2
+ // copy paste to help finding the file (npm and node modules would make it complex)
3
+ // to keep in sync with https://github.com/calebdwilliams/construct-style-sheets
4
+ ;(function () {
5
+ "use strict"
6
+
7
+ if (typeof document === "undefined" || "adoptedStyleSheets" in document) {
8
+ return
9
+ }
10
+
11
+ var hasShadyCss = "ShadyCSS" in window && !ShadyCSS.nativeShadow
12
+ var bootstrapper = document.implementation.createHTMLDocument("")
13
+ var closedShadowRootRegistry = new WeakMap()
14
+ var _DOMException = typeof DOMException === "object" ? Error : DOMException
15
+ var defineProperty = Object.defineProperty
16
+ var forEach = Array.prototype.forEach
17
+
18
+ var hasBrokenRules = (function () {
19
+ var style = bootstrapper.createElement("style")
20
+ style.textContent = '.x{content:"y"}'
21
+ bootstrapper.body.appendChild(style)
22
+ return style.sheet.cssRules[0].style.content !== '"y"'
23
+ })()
24
+ var brokenRulePatterns = [/content:\s*["']/gm]
25
+ function fixBrokenRules(content) {
26
+ return brokenRulePatterns.reduce(function (acc, pattern) {
27
+ return acc.replace(pattern, "$&%%%")
28
+ }, content)
29
+ }
30
+ var placeholderPatterns = [/(content:\s*["'])%%%/gm]
31
+ var getCssText = hasBrokenRules
32
+ ? function (rule) {
33
+ return placeholderPatterns.reduce(function (acc, pattern) {
34
+ return acc.replace(pattern, "$1")
35
+ }, rule.cssText)
36
+ }
37
+ : function (rule) {
38
+ return rule.cssText
39
+ }
40
+
41
+ var importPattern = /@import.+?;?$/gm
42
+ function rejectImports(contents) {
43
+ var _contents = contents.replace(importPattern, "")
44
+ if (_contents !== contents) {
45
+ console.warn(
46
+ "@import rules are not allowed here. See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418",
47
+ )
48
+ }
49
+ return _contents.trim()
50
+ }
51
+ function clearRules(sheet) {
52
+ for (var i = 0; i < sheet.cssRules.length; i++) {
53
+ sheet.deleteRule(0)
54
+ }
55
+ }
56
+ function insertAllRules(from, to) {
57
+ forEach.call(from.cssRules, function (rule, i) {
58
+ to.insertRule(getCssText(rule), i)
59
+ })
60
+ }
61
+ function isElementConnected(element) {
62
+ return "isConnected" in element
63
+ ? element.isConnected
64
+ : document.contains(element)
65
+ }
66
+ function unique(arr) {
67
+ return arr.filter(function (value, index) {
68
+ return arr.indexOf(value) === index
69
+ })
70
+ }
71
+ function diff(arr1, arr2) {
72
+ return arr1.filter(function (value) {
73
+ return arr2.indexOf(value) === -1
74
+ })
75
+ }
76
+ function removeNode(node) {
77
+ node.parentNode.removeChild(node)
78
+ }
79
+ function getShadowRoot(element) {
80
+ return element.shadowRoot || closedShadowRootRegistry.get(element)
81
+ }
82
+
83
+ var cssStyleSheetMethods = [
84
+ "addRule",
85
+ "deleteRule",
86
+ "insertRule",
87
+ "removeRule",
88
+ ]
89
+ var NonConstructedStyleSheet = CSSStyleSheet
90
+ var nonConstructedProto = NonConstructedStyleSheet.prototype
91
+ nonConstructedProto.replace = function () {
92
+ return Promise.reject(
93
+ new _DOMException(
94
+ "Can't call replace on non-constructed CSSStyleSheets.",
95
+ ),
96
+ )
97
+ }
98
+ nonConstructedProto.replaceSync = function () {
99
+ throw new _DOMException(
100
+ "Failed to execute 'replaceSync' on 'CSSStyleSheet': Can't call replaceSync on non-constructed CSSStyleSheets.",
101
+ )
102
+ }
103
+ function isCSSStyleSheetInstance(instance) {
104
+ return typeof instance === "object"
105
+ ? proto$1.isPrototypeOf(instance) ||
106
+ nonConstructedProto.isPrototypeOf(instance)
107
+ : false
108
+ }
109
+ function isNonConstructedStyleSheetInstance(instance) {
110
+ return typeof instance === "object"
111
+ ? nonConstructedProto.isPrototypeOf(instance)
112
+ : false
113
+ }
114
+ var $basicStyleSheet = new WeakMap()
115
+ var $locations = new WeakMap()
116
+ var $adoptersByLocation = new WeakMap()
117
+ function addAdopterLocation(sheet, location) {
118
+ var adopter = document.createElement("style")
119
+ $adoptersByLocation.get(sheet).set(location, adopter)
120
+ $locations.get(sheet).push(location)
121
+ return adopter
122
+ }
123
+ function getAdopterByLocation(sheet, location) {
124
+ return $adoptersByLocation.get(sheet).get(location)
125
+ }
126
+ function removeAdopterLocation(sheet, location) {
127
+ $adoptersByLocation.get(sheet).delete(location)
128
+ $locations.set(
129
+ sheet,
130
+ $locations.get(sheet).filter(function (_location) {
131
+ return _location !== location
132
+ }),
133
+ )
134
+ }
135
+ function restyleAdopter(sheet, adopter) {
136
+ requestAnimationFrame(function () {
137
+ clearRules(adopter.sheet)
138
+ insertAllRules($basicStyleSheet.get(sheet), adopter.sheet)
139
+ })
140
+ }
141
+ function checkInvocationCorrectness(self) {
142
+ if (!$basicStyleSheet.has(self)) {
143
+ throw new TypeError("Illegal invocation")
144
+ }
145
+ }
146
+ function ConstructedStyleSheet() {
147
+ var self = this
148
+ var style = document.createElement("style")
149
+ bootstrapper.body.appendChild(style)
150
+ $basicStyleSheet.set(self, style.sheet)
151
+ $locations.set(self, [])
152
+ $adoptersByLocation.set(self, new WeakMap())
153
+ }
154
+ var proto$1 = ConstructedStyleSheet.prototype
155
+ proto$1.replace = function replace(contents) {
156
+ try {
157
+ this.replaceSync(contents)
158
+ return Promise.resolve(this)
159
+ } catch (e) {
160
+ return Promise.reject(e)
161
+ }
162
+ }
163
+ proto$1.replaceSync = function replaceSync(contents) {
164
+ checkInvocationCorrectness(this)
165
+ if (typeof contents === "string") {
166
+ var self_1 = this
167
+ var style = $basicStyleSheet.get(self_1).ownerNode
168
+ style.textContent = hasBrokenRules
169
+ ? fixBrokenRules(rejectImports(contents))
170
+ : rejectImports(contents)
171
+ $basicStyleSheet.set(self_1, style.sheet)
172
+ $locations.get(self_1).forEach(function (location) {
173
+ if (location.isConnected()) {
174
+ restyleAdopter(self_1, getAdopterByLocation(self_1, location))
175
+ }
176
+ })
177
+ }
178
+ }
179
+ defineProperty(proto$1, "cssRules", {
180
+ configurable: true,
181
+ enumerable: true,
182
+ get: function cssRules() {
183
+ checkInvocationCorrectness(this)
184
+ return $basicStyleSheet.get(this).cssRules
185
+ },
186
+ })
187
+ cssStyleSheetMethods.forEach(function (method) {
188
+ proto$1[method] = function () {
189
+ var self = this
190
+ checkInvocationCorrectness(self)
191
+ var args = arguments
192
+ $locations.get(self).forEach(function (location) {
193
+ if (location.isConnected()) {
194
+ var sheet = getAdopterByLocation(self, location).sheet
195
+ sheet[method].apply(sheet, args)
196
+ }
197
+ })
198
+ if (hasBrokenRules) {
199
+ if (method === "insertRule") {
200
+ args[0] = fixBrokenRules(args[0])
201
+ }
202
+ if (method === "addRule") {
203
+ args[1] = fixBrokenRules(args[1])
204
+ }
205
+ }
206
+ var basic = $basicStyleSheet.get(self)
207
+ return basic[method].apply(basic, args)
208
+ }
209
+ })
210
+ defineProperty(ConstructedStyleSheet, Symbol.hasInstance, {
211
+ configurable: true,
212
+ value: isCSSStyleSheetInstance,
213
+ })
214
+
215
+ var defaultObserverOptions = {
216
+ childList: true,
217
+ subtree: true,
218
+ }
219
+ var locations = new WeakMap()
220
+ function getAssociatedLocation(element) {
221
+ var location = locations.get(element)
222
+ if (!location) {
223
+ location = new Location(element)
224
+ locations.set(element, location)
225
+ }
226
+ return location
227
+ }
228
+ function attachAdoptedStyleSheetProperty(constructor) {
229
+ defineProperty(constructor.prototype, "adoptedStyleSheets", {
230
+ configurable: true,
231
+ enumerable: true,
232
+ get: function () {
233
+ return getAssociatedLocation(this).sheets
234
+ },
235
+ set: function (sheets) {
236
+ getAssociatedLocation(this).update(sheets)
237
+ },
238
+ })
239
+ }
240
+ function traverseWebComponents(node, callback) {
241
+ var iter = document.createNodeIterator(
242
+ node,
243
+ NodeFilter.SHOW_ELEMENT,
244
+ function (foundNode) {
245
+ return getShadowRoot(foundNode)
246
+ ? NodeFilter.FILTER_ACCEPT
247
+ : NodeFilter.FILTER_REJECT
248
+ },
249
+ null,
250
+ false,
251
+ )
252
+ for (var next = void 0; (next = iter.nextNode()); ) {
253
+ callback(getShadowRoot(next))
254
+ }
255
+ }
256
+ var $element = new WeakMap()
257
+ var $uniqueSheets = new WeakMap()
258
+ var $observer = new WeakMap()
259
+ function isExistingAdopter(self, element) {
260
+ return (
261
+ element instanceof HTMLStyleElement &&
262
+ $uniqueSheets.get(self).some(function (sheet) {
263
+ return getAdopterByLocation(sheet, self)
264
+ })
265
+ )
266
+ }
267
+ function getAdopterContainer(self) {
268
+ var element = $element.get(self)
269
+ return element instanceof Document ? element.body : element
270
+ }
271
+ function adopt(self) {
272
+ var styleList = document.createDocumentFragment()
273
+ var sheets = $uniqueSheets.get(self)
274
+ var observer = $observer.get(self)
275
+ var container = getAdopterContainer(self)
276
+ observer.disconnect()
277
+ sheets.forEach(function (sheet) {
278
+ styleList.appendChild(
279
+ getAdopterByLocation(sheet, self) || addAdopterLocation(sheet, self),
280
+ )
281
+ })
282
+ container.insertBefore(styleList, null)
283
+ observer.observe(container, defaultObserverOptions)
284
+ sheets.forEach(function (sheet) {
285
+ restyleAdopter(sheet, getAdopterByLocation(sheet, self))
286
+ })
287
+ }
288
+ function Location(element) {
289
+ var self = this
290
+ self.sheets = []
291
+ $element.set(self, element)
292
+ $uniqueSheets.set(self, [])
293
+ $observer.set(
294
+ self,
295
+ new MutationObserver(function (mutations, observer) {
296
+ if (!document) {
297
+ observer.disconnect()
298
+ return
299
+ }
300
+ mutations.forEach(function (mutation) {
301
+ if (!hasShadyCss) {
302
+ forEach.call(mutation.addedNodes, function (node) {
303
+ if (!(node instanceof Element)) {
304
+ return
305
+ }
306
+ traverseWebComponents(node, function (root) {
307
+ getAssociatedLocation(root).connect()
308
+ })
309
+ })
310
+ }
311
+ forEach.call(mutation.removedNodes, function (node) {
312
+ if (!(node instanceof Element)) {
313
+ return
314
+ }
315
+ if (isExistingAdopter(self, node)) {
316
+ adopt(self)
317
+ }
318
+ if (!hasShadyCss) {
319
+ traverseWebComponents(node, function (root) {
320
+ getAssociatedLocation(root).disconnect()
321
+ })
322
+ }
323
+ })
324
+ })
325
+ }),
326
+ )
327
+ }
328
+ Location.prototype = {
329
+ isConnected: function () {
330
+ var element = $element.get(this)
331
+ return element instanceof Document
332
+ ? element.readyState !== "loading"
333
+ : isElementConnected(element.host)
334
+ },
335
+ connect: function () {
336
+ var container = getAdopterContainer(this)
337
+ $observer.get(this).observe(container, defaultObserverOptions)
338
+ if ($uniqueSheets.get(this).length > 0) {
339
+ adopt(this)
340
+ }
341
+ traverseWebComponents(container, function (root) {
342
+ getAssociatedLocation(root).connect()
343
+ })
344
+ },
345
+ disconnect: function () {
346
+ $observer.get(this).disconnect()
347
+ },
348
+ update: function (sheets) {
349
+ var self = this
350
+ var locationType =
351
+ $element.get(self) === document ? "Document" : "ShadowRoot"
352
+ if (!Array.isArray(sheets)) {
353
+ throw new TypeError(
354
+ "Failed to set the 'adoptedStyleSheets' property on " +
355
+ locationType +
356
+ ": Iterator getter is not callable.",
357
+ )
358
+ }
359
+ if (!sheets.every(isCSSStyleSheetInstance)) {
360
+ throw new TypeError(
361
+ "Failed to set the 'adoptedStyleSheets' property on " +
362
+ locationType +
363
+ ": Failed to convert value to 'CSSStyleSheet'",
364
+ )
365
+ }
366
+ if (sheets.some(isNonConstructedStyleSheetInstance)) {
367
+ throw new TypeError(
368
+ "Failed to set the 'adoptedStyleSheets' property on " +
369
+ locationType +
370
+ ": Can't adopt non-constructed stylesheets",
371
+ )
372
+ }
373
+ self.sheets = sheets
374
+ var oldUniqueSheets = $uniqueSheets.get(self)
375
+ var uniqueSheets = unique(sheets)
376
+ var removedSheets = diff(oldUniqueSheets, uniqueSheets)
377
+ removedSheets.forEach(function (sheet) {
378
+ removeNode(getAdopterByLocation(sheet, self))
379
+ removeAdopterLocation(sheet, self)
380
+ })
381
+ $uniqueSheets.set(self, uniqueSheets)
382
+ if (self.isConnected() && uniqueSheets.length > 0) {
383
+ adopt(self)
384
+ }
385
+ },
386
+ }
387
+
388
+ window.CSSStyleSheet = ConstructedStyleSheet
389
+ attachAdoptedStyleSheetProperty(Document)
390
+ if ("ShadowRoot" in window) {
391
+ attachAdoptedStyleSheetProperty(ShadowRoot)
392
+ var proto = Element.prototype
393
+ var attach_1 = proto.attachShadow
394
+ proto.attachShadow = function attachShadow(init) {
395
+ var root = attach_1.call(this, init)
396
+ if (init.mode === "closed") {
397
+ closedShadowRootRegistry.set(this, root)
398
+ }
399
+ return root
400
+ }
401
+ }
402
+ var documentLocation = getAssociatedLocation(document)
403
+ if (documentLocation.isConnected()) {
404
+ documentLocation.connect()
405
+ } else {
406
+ document.addEventListener(
407
+ "DOMContentLoaded",
408
+ documentLocation.connect.bind(documentLocation),
409
+ )
410
+ }
411
+ })()
File without changes
package/main.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable import/max-dependencies */
2
2
  export { buildProject } from "./src/buildProject.js"
3
3
  export { commonJsToJavaScriptModule } from "./src/commonJsToJavaScriptModule.js"
4
+ export { jsonToJavaScriptModule } from "./src/jsonToJavaScriptModule.js"
4
5
  export { textToJavaScriptModule } from "./src/textToJavaScriptModule.js"
5
6
  export { execute } from "./src/execute.js"
6
7
  export { executeTestPlan } from "./src/executeTestPlan.js"
@@ -9,13 +10,13 @@ export { jsenvCoverageConfig } from "./src/jsenvCoverageConfig.js"
9
10
  export { jsenvExplorableConfig } from "./src/jsenvExplorableConfig.js"
10
11
  export { jsenvServiceWorkerFinalizer } from "./src/jsenvServiceWorkerFinalizer.js"
11
12
  export {
12
- launchChromium,
13
- launchChromiumTab,
14
- launchFirefox,
15
- launchFirefoxTab,
16
- launchWebkit,
17
- launchWebkitTab,
13
+ chromiumRuntime,
14
+ chromiumTabRuntime,
15
+ firefoxRuntime,
16
+ firefoxTabRuntime,
17
+ webkitRuntime,
18
+ webkitTabRuntime,
18
19
  } from "./src/launchBrowser.js"
19
- export { launchNode } from "./src/launchNode.js"
20
+ export { nodeRuntime } from "./src/launchNode.js"
20
21
  export { requireUsingChildProcess } from "./src/requireUsingChildProcess.js"
21
22
  export { startExploring } from "./src/startExploring.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "22.4.0",
3
+ "version": "23.0.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,8 +11,7 @@
11
11
  "node": ">=14.9.0"
12
12
  },
13
13
  "publishConfig": {
14
- "access": "public",
15
- "registry": "https://registry.npmjs.org"
14
+ "access": "public"
16
15
  },
17
16
  "type": "module",
18
17
  "exports": {
@@ -29,7 +28,7 @@
29
28
  "/main.js"
30
29
  ],
31
30
  "scripts": {
32
- "eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs,.html",
31
+ "eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs,.cjs,.html",
33
32
  "generate-importmap": "node ./script/importmap/generate_importmap.js",
34
33
  "build": "node ./script/build/build.js",
35
34
  "dist": "npm run build",
@@ -53,12 +52,13 @@
53
52
  "postpublish": "node ./script/publish/restore_postinstall.mjs"
54
53
  },
55
54
  "dependencies": {
56
- "@babel/core": "7.15.5",
55
+ "@babel/core": "7.15.8",
57
56
  "@babel/helper-module-imports": "7.15.4",
58
57
  "@babel/helpers": "7.15.4",
59
- "@babel/parser": "7.15.7",
58
+ "@babel/parser": "7.15.8",
60
59
  "@babel/plugin-proposal-dynamic-import": "7.14.5",
61
60
  "@babel/plugin-syntax-dynamic-import": "7.8.3",
61
+ "@babel/plugin-syntax-import-assertions": "7.14.5",
62
62
  "@babel/plugin-syntax-import-meta": "7.10.4",
63
63
  "@babel/plugin-syntax-numeric-separator": "7.10.4",
64
64
  "@babel/plugin-transform-modules-systemjs": "7.15.4",
@@ -74,8 +74,10 @@
74
74
  "@rollup/plugin-json": "4.1.0",
75
75
  "@rollup/plugin-node-resolve": "13.0.5",
76
76
  "@rollup/plugin-replace": "3.0.0",
77
+ "acorn-import-assertions": "1.8.0",
77
78
  "ansi-to-html": "0.7.2",
78
79
  "bytes": "3.1.0",
80
+ "construct-style-sheets-polyfill": "3.0.4",
79
81
  "cjs-module-lexer": "1.2.2",
80
82
  "cssnano": "5.0.8",
81
83
  "cssnano-preset-default": "5.1.4",
@@ -85,13 +87,14 @@
85
87
  "humanize-duration": "3.27.0",
86
88
  "is-unicode-supported": "1.1.0",
87
89
  "is-valid-identifier": "2.0.2",
88
- "istanbul-lib-coverage": "3.0.1",
89
- "istanbul-lib-instrument": "5.0.2",
90
+ "istanbul-lib-coverage": "3.0.2",
91
+ "istanbul-lib-instrument": "5.0.3",
90
92
  "istanbul-lib-report": "3.0.0",
91
- "istanbul-reports": "3.0.2",
93
+ "istanbul-reports": "3.0.5",
92
94
  "magic-string": "0.25.7",
95
+ "node-fetch": "3.0.0",
93
96
  "parse5": "6.0.1",
94
- "playwright": "1.15.1",
97
+ "playwright": "1.15.2",
95
98
  "postcss": "8.3.9",
96
99
  "postcss-value-parser": "4.1.0",
97
100
  "regenerator-runtime": "0.13.9",
@@ -107,23 +110,23 @@
107
110
  "terser": "5.9.0",
108
111
  "tree-kill": "1.2.2",
109
112
  "v8-to-istanbul": "8.1.0",
110
- "vm2": "3.9.3",
113
+ "vm2": "3.9.4",
111
114
  "wrap-ansi": "8.0.1"
112
115
  },
113
116
  "devDependencies": {
114
- "@babel/eslint-parser": "7.15.7",
117
+ "@babel/eslint-parser": "7.15.8",
115
118
  "@babel/plugin-syntax-jsx": "7.14.5",
116
119
  "@babel/plugin-transform-block-scoping": "7.15.3",
117
120
  "@babel/plugin-transform-react-jsx": "7.14.9",
118
- "@babel/plugin-transform-typescript": "7.15.4",
119
- "@babel/preset-env": "7.15.6",
121
+ "@babel/plugin-transform-typescript": "7.15.8",
122
+ "@babel/preset-env": "7.15.8",
120
123
  "@jsenv/assert": "2.3.1",
121
124
  "@jsenv/babel-preset": "./packages/jsenv-babel-preset",
122
125
  "@jsenv/codecov-upload": "3.5.0",
123
- "@jsenv/eslint-config": "16.0.6",
126
+ "@jsenv/eslint-config": "16.0.8",
124
127
  "@jsenv/github-release-package": "1.2.3",
125
128
  "@jsenv/importmap-eslint-resolver": "5.1.2",
126
- "@jsenv/importmap-node-module": "2.3.1",
129
+ "@jsenv/importmap-node-module": "2.4.1",
127
130
  "@jsenv/package-publish": "1.6.2",
128
131
  "@jsenv/performance-impact": "1.7.0",
129
132
  "@jsenv/prettier-check-project": "5.6.1",
@@ -131,13 +134,14 @@
131
134
  "babel-plugin-transform-async-to-promises": "0.8.15",
132
135
  "eslint": "7.32.0",
133
136
  "eslint-plugin-html": "6.2.0",
134
- "eslint-plugin-import": "2.24.2",
137
+ "eslint-plugin-import": "2.25.2",
135
138
  "eslint-plugin-react": "7.26.1",
136
139
  "node-notifier": "10.0.0",
137
- "preact": "10.5.14",
140
+ "preact": "10.5.15",
138
141
  "prettier": "2.4.1",
139
142
  "react": "17.0.2",
140
143
  "react-dom": "17.0.2",
141
- "redux": "4.1.1"
144
+ "redux": "4.1.1",
145
+ "rollup-plugin-import-assert": "1.1.1"
142
146
  }
143
147
  }
package/readme.md CHANGED
@@ -14,7 +14,7 @@ Jsenv integrates naturally with standard html, css and js. It can be configured
14
14
  - Dispensable by default: as long as your code use only standards, jsenv can be removed and code still runs.
15
15
  - Compiles when mandatory: if code can be executed without compilation, source files are used.
16
16
  - Test files and regular files have more in common. They are easier to understand and debug.
17
- - Developer experience: things where carefully crafted to get explicit and coherent apis.
17
+ - Great developer experience with explicit and coherent apis
18
18
 
19
19
  ## Web standards used by jsenv
20
20
 
@@ -25,6 +25,7 @@ Each standard listed in this section is potentially supported natively by the br
25
25
  - top level await
26
26
  - import.meta.url
27
27
  - dynamic imports
28
+ - import assertions
28
29
 
29
30
  # Test runner overview
30
31
 
@@ -71,8 +72,8 @@ npm install --save-dev @jsenv/core
71
72
  ```js
72
73
  import {
73
74
  executeTestPlan,
74
- launchChromiumTab,
75
- launchFirefoxTab,
75
+ chromiumRuntimeTab,
76
+ firefoxRuntimeTab,
76
77
  } from "@jsenv/core"
77
78
 
78
79
  executeTestPlan({
@@ -80,10 +81,10 @@ executeTestPlan({
80
81
  testPlan: {
81
82
  "./animals.test.html": {
82
83
  chromium: {
83
- launch: launchChromiumTab,
84
+ runtime: chromiumRuntimeTab,
84
85
  },
85
86
  firefox: {
86
- launch: launchFirefoxTab,
87
+ runtime: firefoxRuntimeTab,
87
88
  },
88
89
  },
89
90
  },
@@ -332,7 +333,9 @@ Jsenv configuration is done in [jsenv.config.mjs](https://github.com/jsenv/jsenv
332
333
 
333
334
  ## jsenv.config.mjs
334
335
 
335
- Jsenv codebase usually puts configuration in a top level [jsenv.config.mjs](./jsenv.config.mjs) file.
336
+ Jsenv codebase usually puts configuration in a top level file named `jsenv.config.mjs`.
337
+
338
+ It's recommended to use the following `jsenv.config.mjs`
336
339
 
337
340
  ```js
338
341
  /*
@@ -39,6 +39,7 @@ export const buildProject = async ({
39
39
  globalName,
40
40
  globals = {},
41
41
  babelPluginMap,
42
+ customCompilers,
42
43
  runtimeSupport = format === "global" ||
43
44
  format === "systemjs" ||
44
45
  format === "esmodule"
@@ -101,8 +102,6 @@ export const buildProject = async ({
101
102
  // when asking them to the compile server
102
103
  // (to fix that sourcemap could be inlined)
103
104
  filesystemCache = true,
104
-
105
- ...rest
106
105
  }) => {
107
106
  const jsenvBuildFunction = async ({ jsenvCancellationToken }) => {
108
107
  cancellationToken = composeCancellationToken(
@@ -168,6 +167,8 @@ export const buildProject = async ({
168
167
  env,
169
168
  babelPluginMap,
170
169
  transformTopLevelAwait,
170
+ customCompilers,
171
+ runtimeSupport,
171
172
 
172
173
  compileServerCanReadFromFileSystem: filesystemCache,
173
174
  compileServerCanWriteOnFilesystem: filesystemCache,
@@ -175,11 +176,6 @@ export const buildProject = async ({
175
176
  // here we don't need to inline importmap
176
177
  // nor to inject jsenv script
177
178
  transformHtmlSourceFiles: false,
178
-
179
- runtimeSupport,
180
-
181
- // override with potential custom options
182
- ...rest,
183
179
  })
184
180
 
185
181
  const { outDirectoryRelativeUrl, origin: compileServerOrigin } =