@jsenv/core 25.1.0 → 25.3.0-alpha.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 (58) hide show
  1. package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +2 -2
  2. package/dist/build_manifest.js +4 -4
  3. package/dist/compile_proxy/asset-manifest.json +2 -2
  4. package/dist/compile_proxy/{compile_proxy_e3b0c442_809f35f7.js.map → compile_proxy.html__inline__20_809f35f7.js.map} +0 -0
  5. package/dist/compile_proxy/{compile_proxy_7ad5faa6.html → compile_proxy_8dfaee51.html} +3 -4
  6. package/dist/redirector/asset-manifest.json +2 -2
  7. package/dist/redirector/{redirector_e3b0c442_e391410e.js.map → redirector.html__inline__15_e391410e.js.map} +0 -0
  8. package/dist/redirector/{redirector_eb92e8a7.html → redirector_3e9a97b9.html} +3 -4
  9. package/dist/toolbar/asset-manifest.json +1 -1
  10. package/dist/toolbar/{toolbar_f7b8a263.html → toolbar_361afb84.html} +2 -3
  11. package/dist/toolbar_injector/asset-manifest.json +2 -2
  12. package/dist/toolbar_injector/{toolbar_injector_49e4756e.js → toolbar_injector_fac1e995.js} +2 -2
  13. package/dist/toolbar_injector/{toolbar_injector_49e4756e.js.map → toolbar_injector_fac1e995.js.map} +2 -2
  14. package/package.json +13 -9
  15. package/readme.md +75 -76
  16. package/src/buildProject.js +21 -13
  17. package/src/commonJsToJavaScriptModule.js +8 -7
  18. package/src/dev_server.js +2 -0
  19. package/src/execute.js +2 -0
  20. package/src/executeTestPlan.js +14 -0
  21. package/src/internal/building/buildUsingRollup.js +4 -2
  22. package/src/internal/building/build_stats.js +3 -0
  23. package/src/internal/building/build_url_generator.js +153 -0
  24. package/src/internal/building/css/parseCssRessource.js +32 -26
  25. package/src/internal/building/html/parseHtmlRessource.js +110 -91
  26. package/src/internal/building/js/parseJsRessource.js +4 -7
  27. package/src/internal/building/parseRessource.js +3 -0
  28. package/src/internal/building/ressource_builder.js +64 -62
  29. package/src/internal/building/ressource_builder_util.js +17 -5
  30. package/src/internal/building/rollup_plugin_jsenv.js +259 -189
  31. package/src/internal/building/url_fetcher.js +16 -7
  32. package/src/internal/building/url_loader.js +1 -5
  33. package/src/internal/building/url_versioning.js +0 -173
  34. package/src/internal/compiling/babel_plugin_import_metadata.js +7 -11
  35. package/src/internal/compiling/babel_plugin_proxy_external_imports.js +31 -0
  36. package/src/internal/compiling/compile-directory/compile-asset.js +8 -4
  37. package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +43 -8
  38. package/src/internal/compiling/compile-directory/updateMeta.js +4 -8
  39. package/src/internal/compiling/compile-directory/validateCache.js +1 -2
  40. package/src/internal/compiling/compileFile.js +22 -10
  41. package/src/internal/compiling/compileHtml.js +15 -28
  42. package/src/internal/compiling/createCompiledFileService.js +22 -24
  43. package/src/internal/compiling/html_source_file_service.js +18 -19
  44. package/src/internal/compiling/js-compilation-service/babelHelper.js +10 -13
  45. package/src/internal/compiling/js-compilation-service/babel_plugin_babel_helpers_as_jsenv_imports.js +4 -2
  46. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -7
  47. package/src/internal/compiling/js-compilation-service/transformJs.js +9 -5
  48. package/src/internal/compiling/jsenvCompilerForHtml.js +231 -195
  49. package/src/internal/compiling/jsenvCompilerForJavaScript.js +15 -11
  50. package/src/internal/compiling/startCompileServer.js +79 -19
  51. package/src/internal/compiling/transformResultToCompilationResult.js +47 -25
  52. package/src/internal/executing/executePlan.js +2 -0
  53. package/src/internal/fetchUrl.js +3 -2
  54. package/src/internal/jsenv_remote_directory.js +156 -0
  55. package/src/internal/origin_directory_converter.js +62 -0
  56. package/src/internal/response_validation.js +11 -24
  57. package/src/internal/sourceMappingURLUtils.js +10 -0
  58. package/src/internal/url_conversion.js +1 -0
@@ -1,12 +1,12 @@
1
1
 
2
- export const REDIRECTOR_BUILD_URL = new URL("redirector/redirector_eb92e8a7.html", import.meta.url).href
2
+ export const REDIRECTOR_BUILD_URL = new URL("redirector/redirector_3e9a97b9.html", import.meta.url).href
3
3
 
4
4
  export const BROWSER_RUNTIME_BUILD_URL = new URL("browser_runtime/browser_runtime_91c5a3b8.js", import.meta.url).href
5
5
 
6
- export const COMPILE_PROXY_BUILD_URL = new URL("compile_proxy/compile_proxy_7ad5faa6.html", import.meta.url).href
6
+ export const COMPILE_PROXY_BUILD_URL = new URL("compile_proxy/compile_proxy_8dfaee51.html", import.meta.url).href
7
7
 
8
8
  export const EVENT_SOURCE_CLIENT_BUILD_URL = new URL("event_source_client/event_source_client_80644aee.js", import.meta.url).href
9
9
 
10
- export const TOOLBAR_BUILD_URL = new URL("toolbar/toolbar_f7b8a263.html", import.meta.url).href
10
+ export const TOOLBAR_BUILD_URL = new URL("toolbar/toolbar_361afb84.html", import.meta.url).href
11
11
 
12
- export const TOOLBAR_INJECTOR_BUILD_URL = new URL("toolbar_injector/toolbar_injector_49e4756e.js", import.meta.url).href
12
+ export const TOOLBAR_INJECTOR_BUILD_URL = new URL("toolbar_injector/toolbar_injector_fac1e995.js", import.meta.url).href
@@ -1,4 +1,4 @@
1
1
  {
2
- "compile_proxy.html": "compile_proxy_7ad5faa6.html",
3
- "compile_proxy_e3b0c442.js.map": "compile_proxy_e3b0c442_809f35f7.js.map"
2
+ "compile_proxy.html": "compile_proxy_8dfaee51.html",
3
+ "compile_proxy.html__inline__20.js.map": "compile_proxy.html__inline__20_809f35f7.js.map"
4
4
  }
@@ -2,7 +2,7 @@
2
2
  <title>Compile proxy</title>
3
3
  <meta name="viewport" content="width=device-width, initial-scale=1">
4
4
  <meta charset="utf-8">
5
- <link rel="icon" href="data:,">
5
+
6
6
  <script id="jsenv_inject_systemjs">/*
7
7
  * SJS 6.11.0
8
8
  * Minimal SystemJS Build
@@ -874,8 +874,7 @@
874
874
  window.resolveReadyPromise = resolve
875
875
  })
876
876
  </script>
877
- <script type="systemjs-importmap">
878
- {
877
+ <script type="systemjs-importmap">{
879
878
  "imports": {}
880
879
  }</script>
881
880
  <script>System.register("compile_proxy.html__inline__20.js", [], function () {
@@ -2278,7 +2277,7 @@
2278
2277
  };
2279
2278
  });
2280
2279
 
2281
- //# sourceMappingURL=compile_proxy_e3b0c442_809f35f7.js.map</script>
2280
+ //# sourceMappingURL=compile_proxy.html__inline__20_809f35f7.js.map</script>
2282
2281
 
2283
2282
 
2284
2283
  </body></html>
@@ -1,4 +1,4 @@
1
1
  {
2
- "redirector_e3b0c442.js.map": "redirector_e3b0c442_e391410e.js.map",
3
- "redirector.html": "redirector_eb92e8a7.html"
2
+ "redirector.html": "redirector_3e9a97b9.html",
3
+ "redirector.html__inline__15.js.map": "redirector.html__inline__15_e391410e.js.map"
4
4
  }
@@ -2,7 +2,7 @@
2
2
  <title>Jsenv redirector</title>
3
3
  <meta name="viewport" content="width=device-width, initial-scale=1">
4
4
  <meta charset="utf-8">
5
- <link rel="icon" href="data:,">
5
+
6
6
  <script id="jsenv_inject_systemjs">/*
7
7
  * SJS 6.11.0
8
8
  * Minimal SystemJS Build
@@ -869,8 +869,7 @@
869
869
  </head>
870
870
 
871
871
  <body>
872
- <script type="systemjs-importmap">
873
- {
872
+ <script type="systemjs-importmap">{
874
873
  "imports": {}
875
874
  }</script>
876
875
  <script>System.register("redirector.html__inline__15.js", [], function () {
@@ -2322,7 +2321,7 @@
2322
2321
  };
2323
2322
  });
2324
2323
 
2325
- //# sourceMappingURL=redirector_e3b0c442_e391410e.js.map</script>
2324
+ //# sourceMappingURL=redirector.html__inline__15_e391410e.js.map</script>
2326
2325
 
2327
2326
 
2328
2327
  </body></html>
@@ -8,6 +8,6 @@
8
8
  "assets/settings.css.map": "assets/settings.css_61548139.map",
9
9
  "assets/toolbar.main.css.map": "assets/toolbar.main.css_269d7ce2.map",
10
10
  "assets/tooltip.css.map": "assets/tooltip.css_a94a8bdd.map",
11
- "toolbar.html": "toolbar_f7b8a263.html",
11
+ "toolbar.html": "toolbar_361afb84.html",
12
12
  "toolbar.main.js.map": "toolbar.main_6c1b3d82.js.map"
13
13
  }
@@ -2,7 +2,7 @@
2
2
  <title>Jsenv toolbar</title>
3
3
  <meta name="viewport" content="width=device-width, initial-scale=1">
4
4
  <meta charset="utf-8">
5
- <link rel="icon" href="data:,">
5
+
6
6
  <style>/* Loader icon */
7
7
  #loader-icon {
8
8
  width: 20px;
@@ -1999,8 +1999,7 @@ html[data-toolbar-visible] #toolbar-trigger {
1999
1999
  module approach wil be faster because
2000
2000
  no compilation will be necessary
2001
2001
  -->
2002
- <script type="systemjs-importmap">
2003
- {
2002
+ <script type="systemjs-importmap">{
2004
2003
  "imports": {}
2005
2004
  }</script>
2006
2005
  <script>
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "assets/jsenv-logo.svg": "assets/jsenv-logo_188b9ca6.svg",
3
- "toolbar_injector.js": "toolbar_injector_49e4756e.js",
4
- "toolbar_injector.js.map": "toolbar_injector_49e4756e.js.map"
3
+ "toolbar_injector.js": "toolbar_injector_fac1e995.js",
4
+ "toolbar_injector.js.map": "toolbar_injector_fac1e995.js.map"
5
5
  }
@@ -746,7 +746,7 @@
746
746
  return then ? value.then(then) : value;
747
747
  }
748
748
 
749
- var TOOLBAR_BUILD_RELATIVE_URL = "dist/toolbar/toolbar_f7b8a263.html";
749
+ var TOOLBAR_BUILD_RELATIVE_URL = "dist/toolbar/toolbar_361afb84.html";
750
750
 
751
751
  function _call(body, then, direct) {
752
752
  if (direct) {
@@ -970,4 +970,4 @@
970
970
 
971
971
  })();
972
972
 
973
- //# sourceMappingURL=toolbar_injector_49e4756e.js.map
973
+ //# sourceMappingURL=toolbar_injector_fac1e995.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "file": "toolbar_injector_49e4756e.js",
3
+ "file": "toolbar_injector_fac1e995.js",
4
4
  "sources": [
5
5
  "../../helpers/babel/typeof/typeof.js",
6
6
  "../../helpers/babel/defineProperty/defineProperty.js",
@@ -25,7 +25,7 @@
25
25
  "import { fetchUrl } from \"./fetch-browser.js\"\n\nexport const fetchJson = async (url, options = {}) => {\n const response = await fetchUrl(url, options)\n const object = await response.json()\n return object\n}\n",
26
26
  "import { fetchJson } from \"../../browser_utils/fetchJson.js\"\n\nexport const fetchExploringJson = async ({ signal } = {}) => {\n try {\n const exploringInfo = await fetchJson(\"/.jsenv/exploring.json\", {\n signal,\n })\n return exploringInfo\n } catch (e) {\n if (signal && signal.aborted && e.name === \"AbortError\") {\n throw e\n }\n throw new Error(\n `Cannot communicate with exploring server due to a network error\n--- error stack ---\n${e.stack}`,\n )\n }\n}\n",
27
27
  "export const updateIframeOverflowOnParentWindow = () => {\n if (!window.parent) {\n // can happen while parent iframe reloads\n return\n }\n\n const aTooltipIsOpened =\n document.querySelector(\"[data-tooltip-visible]\") ||\n document.querySelector(\"[data-tooltip-auto-visible]\")\n const settingsAreOpened = document.querySelector(\"#settings[data-active]\")\n\n if (aTooltipIsOpened || settingsAreOpened) {\n enableIframeOverflowOnParentWindow()\n } else {\n disableIframeOverflowOnParentWindow()\n }\n}\n\nlet iframeOverflowEnabled = false\nconst enableIframeOverflowOnParentWindow = () => {\n if (iframeOverflowEnabled) return\n iframeOverflowEnabled = true\n\n const iframe = getToolbarIframe()\n const transitionDuration = iframe.style.transitionDuration\n setStyles(iframe, { \"height\": \"100%\", \"transition-duration\": \"0ms\" })\n if (transitionDuration) {\n setTimeout(() => {\n setStyles(iframe, { \"transition-duration\": transitionDuration })\n })\n }\n}\n\nconst disableIframeOverflowOnParentWindow = () => {\n if (!iframeOverflowEnabled) return\n iframeOverflowEnabled = false\n\n const iframe = getToolbarIframe()\n const transitionDuration = iframe.style.transitionDuration\n setStyles(iframe, { \"height\": \"40px\", \"transition-duration\": \"0ms\" })\n if (transitionDuration) {\n setTimeout(() => {\n setStyles(iframe, { \"transition-duration\": transitionDuration })\n })\n }\n}\n\nexport const getToolbarIframe = () => {\n const iframes = Array.from(window.parent.document.querySelectorAll(\"iframe\"))\n return iframes.find((iframe) => iframe.contentWindow === window)\n}\n\nexport const forceHideElement = (element) => {\n element.setAttribute(\"data-force-hide\", \"\")\n}\n\nexport const removeForceHideElement = (element) => {\n element.removeAttribute(\"data-force-hide\")\n}\n\nexport const setStyles = (element, styles) => {\n const elementStyle = element.style\n const restoreStyles = Object.keys(styles).map((styleName) => {\n let restore\n if (styleName in elementStyle) {\n const currentStyle = elementStyle[styleName]\n restore = () => {\n elementStyle[styleName] = currentStyle\n }\n } else {\n restore = () => {\n delete elementStyle[styleName]\n }\n }\n\n elementStyle[styleName] = styles[styleName]\n\n return restore\n })\n return () => {\n restoreStyles.forEach((restore) => restore())\n }\n}\n\nexport const setAttributes = (element, attributes) => {\n Object.keys(attributes).forEach((name) => {\n element.setAttribute(name, attributes[name])\n })\n}\n\nexport const getDocumentScroll = () => {\n return {\n x: document.documentElement.scrollLeft,\n y: document.documentElement.scrollTop,\n }\n}\n\nexport const toolbarSectionIsActive = (element) => {\n return element.hasAttribute(\"data-active\")\n}\n\nexport const activateToolbarSection = (element) => {\n element.setAttribute(\"data-active\", \"\")\n}\n\nexport const deactivateToolbarSection = (element) => {\n element.removeAttribute(\"data-active\")\n}\n",
28
- "import { fetchExploringJson } from \"@jsenv/core/src/internal/dev_server/exploring/fetchExploringJson.js\"\nimport { setAttributes, setStyles } from \"./util/dom.js\"\n\n// eslint-disable-next-line no-undef\nconst TOOLBAR_BUILD_RELATIVE_URL = \"dist/toolbar/toolbar_f7b8a263.html\"\nconst jsenvLogoSvgUrl = new URL(\"./jsenv-logo.svg\", import.meta.url)\n\nconst injectToolbar = async () => {\n await new Promise((resolve) => {\n if (window.requestIdleCallback) {\n window.requestIdleCallback(resolve)\n } else {\n window.requestAnimationFrame(resolve)\n }\n })\n\n const { jsenvDirectoryRelativeUrl } = await fetchExploringJson()\n const jsenvDirectoryServerUrl = resolveUrl(\n jsenvDirectoryRelativeUrl,\n document.location.origin,\n )\n\n const placeholder = getToolbarPlaceholder()\n\n const iframe = document.createElement(\"iframe\")\n setAttributes(iframe, {\n tabindex: -1,\n // sandbox: \"allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation\",\n // allow: \"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; vr\",\n allowtransparency: true,\n })\n setStyles(iframe, {\n \"position\": \"fixed\",\n \"zIndex\": 1000,\n \"bottom\": 0,\n \"left\": 0,\n \"width\": \"100%\",\n \"height\": 0,\n /* ensure toolbar children are not focusable when hidden */\n \"visibility\": \"hidden\",\n \"transition-duration\": \"300ms\",\n \"transition-property\": \"height, visibility\",\n \"border\": \"none\",\n })\n const iframeLoadedPromise = iframeToLoadedPromise(iframe)\n const jsenvToolbarHtmlServerUrl = resolveUrl(\n TOOLBAR_BUILD_RELATIVE_URL,\n jsenvDirectoryServerUrl,\n )\n // set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)\n iframe.setAttribute(\"src\", jsenvToolbarHtmlServerUrl)\n placeholder.parentNode.replaceChild(iframe, placeholder)\n\n await iframeLoadedPromise\n iframe.removeAttribute(\"tabindex\")\n\n const div = document.createElement(\"div\")\n div.innerHTML = `\n<div id=\"jsenv-toolbar-trigger\">\n <svg id=\"jsenv-toolbar-trigger-icon\">\n <use xlink:href=\"${jsenvLogoSvgUrl}#jsenv-logo\"></use>\n </svg>\n <style>\n #jsenv-toolbar-trigger {\n display: block;\n overflow: hidden;\n position: fixed;\n z-index: 1000;\n bottom: -32px;\n right: 20px;\n height: 40px;\n width: 40px;\n padding: 0;\n margin: 0;\n border-radius: 5px 5px 0 0;\n border: 1px solid rgba(0, 0, 0, 0.33);\n border-bottom: none;\n box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.46);\n background: transparent;\n text-align: center;\n transition: 600ms;\n }\n\n #jsenv-toolbar-trigger:hover {\n cursor: pointer;\n }\n\n #jsenv-toolbar-trigger[data-expanded] {\n bottom: 0;\n }\n\n #jsenv-toolbar-trigger-icon {\n width: 35px;\n height: 35px;\n opacity: 0;\n transition: 600ms;\n }\n\n #jsenv-toolbar-trigger[data-expanded] #jsenv-toolbar-trigger-icon {\n opacity: 1;\n }\n </style>\n</div>`\n const toolbarTrigger = div.firstElementChild\n iframe.parentNode.appendChild(toolbarTrigger)\n\n let timer\n toolbarTrigger.onmouseenter = () => {\n toolbarTrigger.setAttribute(\"data-animate\", \"\")\n timer = setTimeout(expandToolbarTrigger, 500)\n }\n toolbarTrigger.onmouseleave = () => {\n clearTimeout(timer)\n collapseToolbarTrigger()\n }\n toolbarTrigger.onfocus = () => {\n toolbarTrigger.removeAttribute(\"data-animate\")\n expandToolbarTrigger()\n }\n toolbarTrigger.onblur = () => {\n toolbarTrigger.removeAttribute(\"data-animate\")\n clearTimeout(timer)\n collapseToolbarTrigger()\n }\n toolbarTrigger.onclick = () => {\n sendCommandToToolbar(iframe, \"showToolbar\")\n }\n\n const showToolbarTrigger = () => {\n toolbarTrigger.style.display = \"block\"\n }\n\n const hideToolbarTrigger = () => {\n toolbarTrigger.style.display = \"none\"\n }\n\n const expandToolbarTrigger = () => {\n toolbarTrigger.setAttribute(\"data-expanded\", \"\")\n }\n\n const collapseToolbarTrigger = () => {\n toolbarTrigger.removeAttribute(\"data-expanded\", \"\")\n }\n\n hideToolbarTrigger()\n addToolbarEventCallback(iframe, \"toolbar-visibility-change\", (visible) => {\n if (visible) {\n hideToolbarTrigger()\n } else {\n showToolbarTrigger()\n }\n })\n addToolbarEventCallback(iframe, \"toolbar_ready\", () => {\n sendCommandToToolbar(iframe, \"renderToolbar\")\n })\n\n return iframe\n}\n\nconst addToolbarEventCallback = (iframe, eventName, callback) => {\n const messageEventCallback = (messageEvent) => {\n const { data } = messageEvent\n if (typeof data !== \"object\") {\n return\n }\n const { __jsenv__ } = data\n if (!__jsenv__) {\n return\n }\n if (__jsenv__.event !== eventName) {\n return\n }\n callback(__jsenv__.data)\n }\n\n window.addEventListener(\"message\", messageEventCallback, false)\n return () => {\n window.removeEventListener(\"message\", messageEventCallback, false)\n }\n}\n\nconst sendCommandToToolbar = (iframe, command, ...args) => {\n iframe.contentWindow.postMessage(\n {\n __jsenv__: {\n command,\n args,\n },\n },\n window.origin,\n )\n}\n\nconst getToolbarPlaceholder = () => {\n const placeholder = queryPlaceholder()\n if (placeholder) {\n if (document.body.contains(placeholder)) {\n return placeholder\n }\n // otherwise iframe would not be visible because in <head>\n console.warn(\n \"element with [data-jsenv-toolbar-placeholder] must be inside document.body\",\n )\n return createTooolbarPlaceholder()\n }\n return createTooolbarPlaceholder()\n}\n\nconst queryPlaceholder = () => {\n return document.querySelector(\"[data-jsenv-toolbar-placeholder]\")\n}\n\nconst createTooolbarPlaceholder = () => {\n const placeholder = document.createElement(\"span\")\n document.body.appendChild(placeholder)\n return placeholder\n}\n\nconst iframeToLoadedPromise = (iframe) => {\n return new Promise((resolve) => {\n const onload = () => {\n iframe.removeEventListener(\"load\", onload, true)\n resolve()\n }\n iframe.addEventListener(\"load\", onload, true)\n })\n}\n\nconst resolveUrl = (url, baseUrl) => String(new URL(url, baseUrl))\n\nif (document.readyState === \"complete\") {\n injectToolbar()\n} else {\n window.addEventListener(\"load\", injectToolbar)\n}\n"
28
+ "import { fetchExploringJson } from \"@jsenv/core/src/internal/dev_server/exploring/fetchExploringJson.js\"\nimport { setAttributes, setStyles } from \"./util/dom.js\"\n\n// eslint-disable-next-line no-undef\nconst TOOLBAR_BUILD_RELATIVE_URL = \"dist/toolbar/toolbar_361afb84.html\"\nconst jsenvLogoSvgUrl = new URL(\"./jsenv-logo.svg\", import.meta.url)\n\nconst injectToolbar = async () => {\n await new Promise((resolve) => {\n if (window.requestIdleCallback) {\n window.requestIdleCallback(resolve)\n } else {\n window.requestAnimationFrame(resolve)\n }\n })\n\n const { jsenvDirectoryRelativeUrl } = await fetchExploringJson()\n const jsenvDirectoryServerUrl = resolveUrl(\n jsenvDirectoryRelativeUrl,\n document.location.origin,\n )\n\n const placeholder = getToolbarPlaceholder()\n\n const iframe = document.createElement(\"iframe\")\n setAttributes(iframe, {\n tabindex: -1,\n // sandbox: \"allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation\",\n // allow: \"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; vr\",\n allowtransparency: true,\n })\n setStyles(iframe, {\n \"position\": \"fixed\",\n \"zIndex\": 1000,\n \"bottom\": 0,\n \"left\": 0,\n \"width\": \"100%\",\n \"height\": 0,\n /* ensure toolbar children are not focusable when hidden */\n \"visibility\": \"hidden\",\n \"transition-duration\": \"300ms\",\n \"transition-property\": \"height, visibility\",\n \"border\": \"none\",\n })\n const iframeLoadedPromise = iframeToLoadedPromise(iframe)\n const jsenvToolbarHtmlServerUrl = resolveUrl(\n TOOLBAR_BUILD_RELATIVE_URL,\n jsenvDirectoryServerUrl,\n )\n // set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)\n iframe.setAttribute(\"src\", jsenvToolbarHtmlServerUrl)\n placeholder.parentNode.replaceChild(iframe, placeholder)\n\n await iframeLoadedPromise\n iframe.removeAttribute(\"tabindex\")\n\n const div = document.createElement(\"div\")\n div.innerHTML = `\n<div id=\"jsenv-toolbar-trigger\">\n <svg id=\"jsenv-toolbar-trigger-icon\">\n <use xlink:href=\"${jsenvLogoSvgUrl}#jsenv-logo\"></use>\n </svg>\n <style>\n #jsenv-toolbar-trigger {\n display: block;\n overflow: hidden;\n position: fixed;\n z-index: 1000;\n bottom: -32px;\n right: 20px;\n height: 40px;\n width: 40px;\n padding: 0;\n margin: 0;\n border-radius: 5px 5px 0 0;\n border: 1px solid rgba(0, 0, 0, 0.33);\n border-bottom: none;\n box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.46);\n background: transparent;\n text-align: center;\n transition: 600ms;\n }\n\n #jsenv-toolbar-trigger:hover {\n cursor: pointer;\n }\n\n #jsenv-toolbar-trigger[data-expanded] {\n bottom: 0;\n }\n\n #jsenv-toolbar-trigger-icon {\n width: 35px;\n height: 35px;\n opacity: 0;\n transition: 600ms;\n }\n\n #jsenv-toolbar-trigger[data-expanded] #jsenv-toolbar-trigger-icon {\n opacity: 1;\n }\n </style>\n</div>`\n const toolbarTrigger = div.firstElementChild\n iframe.parentNode.appendChild(toolbarTrigger)\n\n let timer\n toolbarTrigger.onmouseenter = () => {\n toolbarTrigger.setAttribute(\"data-animate\", \"\")\n timer = setTimeout(expandToolbarTrigger, 500)\n }\n toolbarTrigger.onmouseleave = () => {\n clearTimeout(timer)\n collapseToolbarTrigger()\n }\n toolbarTrigger.onfocus = () => {\n toolbarTrigger.removeAttribute(\"data-animate\")\n expandToolbarTrigger()\n }\n toolbarTrigger.onblur = () => {\n toolbarTrigger.removeAttribute(\"data-animate\")\n clearTimeout(timer)\n collapseToolbarTrigger()\n }\n toolbarTrigger.onclick = () => {\n sendCommandToToolbar(iframe, \"showToolbar\")\n }\n\n const showToolbarTrigger = () => {\n toolbarTrigger.style.display = \"block\"\n }\n\n const hideToolbarTrigger = () => {\n toolbarTrigger.style.display = \"none\"\n }\n\n const expandToolbarTrigger = () => {\n toolbarTrigger.setAttribute(\"data-expanded\", \"\")\n }\n\n const collapseToolbarTrigger = () => {\n toolbarTrigger.removeAttribute(\"data-expanded\", \"\")\n }\n\n hideToolbarTrigger()\n addToolbarEventCallback(iframe, \"toolbar-visibility-change\", (visible) => {\n if (visible) {\n hideToolbarTrigger()\n } else {\n showToolbarTrigger()\n }\n })\n addToolbarEventCallback(iframe, \"toolbar_ready\", () => {\n sendCommandToToolbar(iframe, \"renderToolbar\")\n })\n\n return iframe\n}\n\nconst addToolbarEventCallback = (iframe, eventName, callback) => {\n const messageEventCallback = (messageEvent) => {\n const { data } = messageEvent\n if (typeof data !== \"object\") {\n return\n }\n const { __jsenv__ } = data\n if (!__jsenv__) {\n return\n }\n if (__jsenv__.event !== eventName) {\n return\n }\n callback(__jsenv__.data)\n }\n\n window.addEventListener(\"message\", messageEventCallback, false)\n return () => {\n window.removeEventListener(\"message\", messageEventCallback, false)\n }\n}\n\nconst sendCommandToToolbar = (iframe, command, ...args) => {\n iframe.contentWindow.postMessage(\n {\n __jsenv__: {\n command,\n args,\n },\n },\n window.origin,\n )\n}\n\nconst getToolbarPlaceholder = () => {\n const placeholder = queryPlaceholder()\n if (placeholder) {\n if (document.body.contains(placeholder)) {\n return placeholder\n }\n // otherwise iframe would not be visible because in <head>\n console.warn(\n \"element with [data-jsenv-toolbar-placeholder] must be inside document.body\",\n )\n return createTooolbarPlaceholder()\n }\n return createTooolbarPlaceholder()\n}\n\nconst queryPlaceholder = () => {\n return document.querySelector(\"[data-jsenv-toolbar-placeholder]\")\n}\n\nconst createTooolbarPlaceholder = () => {\n const placeholder = document.createElement(\"span\")\n document.body.appendChild(placeholder)\n return placeholder\n}\n\nconst iframeToLoadedPromise = (iframe) => {\n return new Promise((resolve) => {\n const onload = () => {\n iframe.removeEventListener(\"load\", onload, true)\n resolve()\n }\n iframe.addEventListener(\"load\", onload, true)\n })\n}\n\nconst resolveUrl = (url, baseUrl) => String(new URL(url, baseUrl))\n\nif (document.readyState === \"complete\") {\n injectToolbar()\n} else {\n window.addEventListener(\"load\", injectToolbar)\n}\n"
29
29
  ],
30
30
  "names": [
31
31
  "nativeTypeOf",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "25.1.0",
3
+ "version": "25.3.0-alpha.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,6 +27,9 @@
27
27
  "/src/",
28
28
  "/main.js"
29
29
  ],
30
+ "workspaces": [
31
+ "./packages/*"
32
+ ],
30
33
  "scripts": {
31
34
  "eslint": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs,.cjs,.html",
32
35
  "importmap": "node ./script/importmap/importmap.js",
@@ -39,8 +42,8 @@
39
42
  "file-size": "node ./script/file_size/file_size.mjs --log",
40
43
  "prettier": "prettier --write .",
41
44
  "playwright-install": "npx playwright install-deps && npx playwright install",
42
- "packages-install": "node ./script/packages/packages_install.js",
43
45
  "certificate-install": "node ./script/dev/install_certificate_authority.mjs",
46
+ "sync-workspace-versions": "node ./script/dev/sync_workspace_versions.mjs",
44
47
  "prepublishOnly": "npm run build"
45
48
  },
46
49
  "optionalDependencies": {
@@ -59,11 +62,12 @@
59
62
  "@babel/plugin-transform-modules-systemjs": "7.16.5",
60
63
  "@c88/v8-coverage": "0.1.1",
61
64
  "@jsenv/abort": "4.1.2",
62
- "@jsenv/filesystem": "2.6.0",
65
+ "@jsenv/filesystem": "2.7.0",
63
66
  "@jsenv/importmap": "1.2.0",
67
+ "@jsenv/integrity": "0.0.1",
64
68
  "@jsenv/log": "1.5.0",
65
69
  "@jsenv/logger": "4.0.1",
66
- "@jsenv/server": "12.2.1",
70
+ "@jsenv/server": "12.3.2",
67
71
  "@jsenv/uneval": "1.6.0",
68
72
  "@rollup/plugin-commonjs": "21.0.1",
69
73
  "@rollup/plugin-json": "4.1.0",
@@ -111,17 +115,17 @@
111
115
  "@babel/plugin-transform-react-jsx": "7.16.5",
112
116
  "@babel/plugin-transform-typescript": "7.16.1",
113
117
  "@babel/preset-env": "7.16.5",
114
- "@jsenv/assert": "2.4.0",
115
- "@jsenv/babel-preset": "./packages/jsenv-babel-preset",
118
+ "@jsenv/assert": "2.4.1",
119
+ "@jsenv/babel-preset": "1.1.2",
116
120
  "@jsenv/eslint-config": "16.0.9",
117
121
  "@jsenv/file-size-impact": "12.1.1",
118
122
  "@jsenv/github-release-package": "1.2.3",
119
123
  "@jsenv/https-local": "1.0.3",
120
- "@jsenv/importmap-eslint-resolver": "5.2.1",
121
- "@jsenv/importmap-node-module": "5.0.0",
124
+ "@jsenv/importmap-eslint-resolver": "5.2.5",
125
+ "@jsenv/importmap-node-module": "5.1.0",
122
126
  "@jsenv/package-publish": "1.6.2",
123
127
  "@jsenv/performance-impact": "2.2.1",
124
- "@jsenv/pwa": "4.0.0",
128
+ "@jsenv/pwa": "4.0.1",
125
129
  "babel-plugin-transform-async-to-promises": "0.8.17",
126
130
  "eslint": "7.32.0",
127
131
  "eslint-plugin-html": "6.2.0",
package/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  _@jsenv/core_ is a quick start pack to launch a js project. It provides what you need from the beginning: develoment, testing and building all in one.
4
4
 
5
- Jsenv **integrates naturally with standard** HTML, CSS and JS: you don't have to pick a JavaScript framework.
5
+ Jsenv integrates naturally with standard HTML, CSS and JS: you don't have to pick a JavaScript framework.
6
6
 
7
7
  # Overview
8
8
 
@@ -178,7 +178,7 @@ Only the content of html files is shown below because the content of non-html fi
178
178
  <meta charset="utf-8" />
179
179
  <link rel="modulepreload" href="./main.js" />
180
180
  <link rel="icon" href="./favicon.ico" />
181
- <script type="importmap" src="./import_map.importmap"></script>
181
+ <script type="importmap" src="./project.importmap"></script>
182
182
  <link rel="stylesheet" type="text/css" href="./main.css" />
183
183
  </head>
184
184
 
@@ -217,14 +217,14 @@ await buildProject({
217
217
 
218
218
  building ./main.html...
219
219
  --- files in the build: 5 ---
220
- dist/assets/favicon-25e95a00.png (6.67 KB)
221
- dist/assets/main-feec3a1b.css (62 B)
222
- dist/main-63252261.js (50 Kb)
220
+ dist/assets/favicon_5340s4789a.ico (6.67 KB)
221
+ dist/assets/main_3b329ff0.css (62 B)
222
+ dist/main-f7379e10.js (50 Kb)
223
223
  dist/main.prod.html (392 B)
224
- dist/project-d2192ffe.importmap (29 B)
224
+ dist/project_b237a334.importmap (29 B)
225
225
  --- sourcemap files in the build: 2 ---
226
- dist/assets/main-feec3a1b.css.map (198 B)
227
- dist/main-63252261.js.map (55Kb B)
226
+ dist/assets/main_3b329ff0.css.map (198 B)
227
+ dist/main_3b329ff0.js.map (55Kb B)
228
228
  ------- build summary -------
229
229
  project files: 27 (70.38 KB)
230
230
  build files: 5 (45.2 KB)
@@ -241,20 +241,74 @@ build duration: 1.85 seconds
241
241
  <head>
242
242
  <title>Title</title>
243
243
  <meta charset="utf-8" />
244
- <link rel="modulepreload" href="main-f7379e10.js" />
245
- <link rel="icon" href="assets/favicon-5340s4789a.ico" />
246
- <script type="importmap" src="import-map-b237a334.importmap"></script>
247
- <link rel="stylesheet" type="text/css" href="assets/main-3b329ff0.css" />
244
+ <link rel="modulepreload" href="main_f7379e10.js" />
245
+ <link rel="icon" href="assets/favicon_5340s4789a.ico" />
246
+ <script type="importmap" src="project_b237a334.importmap"></script>
247
+ <link rel="stylesheet" type="text/css" href="assets/main_3b329ff0.css" />
248
248
  </head>
249
249
 
250
250
  <body>
251
- <script type="module" src="./main-f7379e10.js"></script>
251
+ <script type="module" src="./main_f7379e10.js"></script>
252
252
  </body>
253
253
  </html>
254
254
  ```
255
255
 
256
256
  To read more about jsenv build tool, check [jsenv build documentation](./docs/building/readme.md#jsenv-build).
257
257
 
258
+ # Installation
259
+
260
+ ```console
261
+ npm install --save-dev @jsenv/core
262
+ ```
263
+
264
+ _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 16.13.0. Other operating systems and Node.js versions are not tested.
265
+
266
+ # Configuration
267
+
268
+ We recommend to put some jsenv configuration in a top level file named _jsenv.config.mjs_.
269
+
270
+ The presence of a jsenv configuration file is **optional**.
271
+
272
+ ```js
273
+ /*
274
+ * This file exports configuration reused by other files such as
275
+ *
276
+ * script/test/test.mjs
277
+ * script/build/build.mjs
278
+ *
279
+ * Read more at https://github.com/jsenv/jsenv-core#configuration
280
+ */
281
+
282
+ export const projectDirectoryUrl = new URL("./", import.meta.url)
283
+ ```
284
+
285
+ _jsenv.config.mjs_ is meant to share configuration, other files will simply import what they need.
286
+
287
+ ```diff
288
+ import { buildProject } from '@jsenv/core'
289
+
290
+ + import { projectDirectoryUrl } from "./jsenv.config.mjs"
291
+
292
+ await buildProject({
293
+ - projectDirectoryUrl: new URL('./', import.meta.url)
294
+ + projectDirectoryUrl
295
+ })
296
+ ```
297
+
298
+ > We recommend to use ".mjs" extension when a file is written for Node.js but you can name the file as you want, "jsenv.config.js" is fine too.
299
+
300
+ # Documentation
301
+
302
+ | Link | Description |
303
+ | -------------------------------------------------------- | ------------------------------------------ |
304
+ | [Browser support](./docs/browser_support/readme.md) | Documentation around browser support |
305
+ | [Assets](./docs/assets/readme.md) | How to use assets (CSS, JSON, images, ...) |
306
+ | [Web workers](./docs/web_workers/readme.md) | How to use web workers |
307
+ | [NPM package](./docs/npm_package/readme.md) | How to use a NPM package |
308
+ | [CDN](./docs/cdn/readme.md) | How to use ressources from CDN |
309
+ | [React](./docs/react/readme.md) | How to enable react (or preact) and JSX |
310
+ | [TypeScript (Experimental)](./docs/typescript/readme.md) | How to enable TypeScript |
311
+
258
312
  # About
259
313
 
260
314
  Jsenv was first created to write tests that could be executed in different runtimes. It has naturally evolved to cover the core needs of a JavaScript project:
@@ -276,7 +330,7 @@ Jsenv relies on **standard web features**. Each standard listed below is potenti
276
330
 
277
331
  Amongst other use cases, the ease of use and flexibility of jsenv makes it a great tool to start and learn web development.
278
332
 
279
- First because jsenv is a tool that was built to run raw js, html and css. It starts from the **simplest form of coding** in JavaScript. If a browser can run your code, so can jsenv without configuration or things to learn. There is no magic that will bite you right away or later. Jsenv can be configured to add more stuff later, on demand.
333
+ First because jsenv is a tool that was built to run raw js, html and css. It starts from the **simplest form of coding**. If a browser can run your code, so can jsenv without configuration or things to learn. There is no magic that will bite you right away or later. Jsenv can be configured to add more stuff later, on demand.
280
334
 
281
335
  Second because jsenv is compatible with the latest standards. Even some that are not yet mature in the js ecosystem, such as import maps. This will makes you at ease with technologies that will be part of the ecosystem once you are confortable with coding.
282
336
 
@@ -324,67 +378,12 @@ The logo is composed by the name at the center and two circles orbiting around i
324
378
 
325
379
  </details>
326
380
 
327
- # Installation
328
-
329
- ```console
330
- npm install --save-dev @jsenv/core
331
- ```
332
-
333
- _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 16.13.0. Other operating systems and Node.js versions are not tested.
334
-
335
- # Configuration
336
-
337
- Jsenv configuration is done in [jsenv.config.mjs](#jsenvconfigmjs) and [babel.config.cjs](#babelconfigcjs).
338
-
339
- ## jsenv.config.mjs
340
-
341
- We recommend to put configuration in a top level file named _jsenv.config.mjs_ like the one below:
342
-
343
- ```js
344
- /*
345
- * This file exports configuration reused by jsenv scripts such as
346
- *
347
- * script/test/test.mjs
348
- * script/build/build.mjs
349
- *
350
- * Read more at https://github.com/jsenv/jsenv-core#jsenvconfigmjs
351
- */
352
-
353
- export const projectDirectoryUrl = new URL("./", import.meta.url)
354
- ```
355
-
356
- This file helps to see jsenv configuration quickly and share it between files. That being said you are free to organize your configuration as you want.
357
-
358
- ## babel.config.cjs
359
-
360
- When code needs to be transformed, the project must contain a [babel config file](https://babeljs.io/docs/en/config-files).
361
-
362
- It's recommended to use the following _babel.config.cjs_
363
-
364
- ```js
365
- /*
366
- * This file configure the list of babel plugins enabled
367
- * in this codebase
368
- *
369
- * Read more at https://github.com/jsenv/jsenv-core/tree/master/packages/jsenv-babel-preset
370
- */
371
-
372
- module.exports = {
373
- presets: ["@jsenv/babel-preset"],
374
- }
375
- ```
376
-
377
381
  # See also
378
382
 
379
- | Link | Description |
380
- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
381
- | [Browser support](./docs/config/browser_support.md) | Document how to configure browser support |
382
- | [Web workers](./docs/config/web_workers.md) | Document how to use web workers |
383
- | [React](./docs/config/react.md) | Document how to enable react/preact and JSX |
384
- | [CommonJS modules](./docs/config/commonjs.md) | Document how to use code written in CommonJS |
385
- | [TypeScript (Experimental)](./docs/config/typescript.md) | Document how to enable TypeScript |
386
- | [@jsenv/template-pwa](https://github.com/jsenv/jsenv-template-pwa) | GitHub repository template for a progressive web application |
387
- | [@jsenv/template-node-package](https://github.com/jsenv/jsenv-template-node-package) | GitHub repository template for a node package |
388
- | [@jsenv/assert](https://github.com/jsenv/assert) | NPM package to write assertions |
389
- | [I am too lazy for a test framework](shorturl.at/rFY39) | Article presenting a straightforward testing experience |
390
- | [Jsenv compile server](./docs/jsenv-compile-server.md) | Documentation about jsenv progressive compilation with a filesystem cache |
383
+ | Link | Description |
384
+ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
385
+ | [@jsenv/template-pwa](https://github.com/jsenv/jsenv-template-pwa) | GitHub repository template for a progressive web application |
386
+ | [@jsenv/template-node-package](https://github.com/jsenv/jsenv-template-node-package) | GitHub repository template for a node package |
387
+ | [@jsenv/assert](https://github.com/jsenv/assert) | NPM package to write assertions |
388
+ | [I am too lazy for a test framework](https://medium.com/@DamienMaillard/i-am-too-lazy-for-a-test-framework-ca08d216ee05) | Article presenting a straightforward testing experience |
389
+ | [Jsenv compile server](./docs/jsenv-compile-server.md) | Documentation about jsenv progressive compilation with a filesystem cache |
@@ -3,17 +3,17 @@ import { resolveDirectoryUrl } from "@jsenv/filesystem"
3
3
  import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
4
4
 
5
5
  import { shakeBabelPluginMap } from "@jsenv/core/src/internal/generateGroupMap/shake_babel_plugin_map.js"
6
- import { COMPILE_ID_BEST } from "./internal/CONSTANTS.js"
6
+ import { COMPILE_ID_BEST } from "@jsenv/core/src/internal/CONSTANTS.js"
7
7
  import {
8
8
  assertProjectDirectoryUrl,
9
9
  assertProjectDirectoryExists,
10
- } from "./internal/argUtils.js"
11
- import { startCompileServer } from "./internal/compiling/startCompileServer.js"
12
- import { buildUsingRollup } from "./internal/building/buildUsingRollup.js"
10
+ } from "@jsenv/core/src/internal/argUtils.js"
11
+ import { startCompileServer } from "@jsenv/core/src/internal/compiling/startCompileServer.js"
12
+ import { buildUsingRollup } from "@jsenv/core/src/internal/building/buildUsingRollup.js"
13
13
  import {
14
14
  jsenvBrowserRuntimeSupport,
15
15
  jsenvNodeRuntimeSupport,
16
- } from "./internal/generateGroupMap/jsenvRuntimeSupport.js"
16
+ } from "@jsenv/core/src/internal/generateGroupMap/jsenvRuntimeSupport.js"
17
17
 
18
18
  /**
19
19
  * Generate optimized version of source files into a directory
@@ -63,11 +63,8 @@ export const buildProject = async ({
63
63
  importMapFileRelativeUrl,
64
64
  importDefaultExtension,
65
65
  externalImportSpecifiers = [],
66
- externalImportUrlPatterns = format === "commonjs"
67
- ? {
68
- "node_modules/": true,
69
- }
70
- : {},
66
+ preservedUrls = {},
67
+ // https://rollupjs.org/guide/en/#outputpaths
71
68
  importPaths = {},
72
69
 
73
70
  urlVersioning = format === "systemjs" ||
@@ -189,19 +186,29 @@ export const buildProject = async ({
189
186
  ip,
190
187
  port,
191
188
  env,
189
+
192
190
  babelPluginMap,
193
191
  workers,
194
192
  serviceWorkers,
195
193
  runtimeSupport,
196
194
  customCompilers,
197
- compileServerCanReadFromFilesystem: filesystemCache,
198
- compileServerCanWriteOnFilesystem: filesystemCache,
195
+ preservedUrls: {
196
+ // when format is commonjs preserve node_modules files
197
+ // because code generated expects to be installed alongside its dependencies and require them
198
+ "./node_modules/": format === "commonjs",
199
+ "./node_modules/@jsenv/core/helpers/": false,
200
+ // However it's possible to pass http url in there to "handle" a remote url (http(s)://*)
201
+ // In that case the remote url is fetched and becomes a file in the build directory
202
+ ...preservedUrls,
203
+ },
199
204
  // keep source html untouched
200
205
  // here we don't need to inline importmap
201
206
  // nor to inject jsenv script
202
207
  transformHtmlSourceFiles: false,
203
208
  jsenvScriptInjection: false,
204
209
  jsenvEventSourceClientInjection: false,
210
+ compileServerCanReadFromFilesystem: filesystemCache,
211
+ compileServerCanWriteOnFilesystem: filesystemCache,
205
212
  })
206
213
 
207
214
  buildOperation.addEndCallback(async () => {
@@ -219,6 +226,7 @@ export const buildProject = async ({
219
226
  projectDirectoryUrl,
220
227
  compileServerOrigin,
221
228
  compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${COMPILE_ID_BEST}/`,
229
+ jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
222
230
  buildDirectoryUrl,
223
231
  buildDirectoryClean,
224
232
  assetManifestFile,
@@ -229,7 +237,7 @@ export const buildProject = async ({
229
237
  importMapFileRelativeUrl,
230
238
  importDefaultExtension,
231
239
  externalImportSpecifiers,
232
- externalImportUrlPatterns,
240
+ preservedUrls: compileServer.preservedUrls,
233
241
  importPaths,
234
242
 
235
243
  format,
@@ -1,16 +1,15 @@
1
1
  import { urlToFileSystemPath, resolveUrl } from "@jsenv/filesystem"
2
2
 
3
+ import { generateSourcemapUrl } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
3
4
  import { transformResultToCompilationResult } from "@jsenv/core/src/internal/compiling/transformResultToCompilationResult.js"
4
5
  import { rollupPluginCommonJsNamedExports } from "@jsenv/core/src/internal/compiling/rollup_plugin_commonjs_named_exports.js"
5
6
 
6
7
  export const commonJsToJavaScriptModule = async ({
7
8
  logger,
8
-
9
+ projectDirectoryUrl,
10
+ jsenvRemoteDirectory,
9
11
  url,
10
12
  compiledUrl,
11
- projectDirectoryUrl,
12
-
13
- sourcemapExcludeSources,
14
13
 
15
14
  replaceGlobalObject = true,
16
15
  replaceGlobalFilename = true,
@@ -22,6 +21,7 @@ export const commonJsToJavaScriptModule = async ({
22
21
  replaceMap = {},
23
22
  convertBuiltinsToBrowser = true,
24
23
  external = [],
24
+ sourcemapExcludeSources,
25
25
  } = {}) => {
26
26
  if (!url.startsWith("file:///")) {
27
27
  // it's possible to make rollup compatible with http:// for instance
@@ -147,7 +147,7 @@ export const commonJsToJavaScriptModule = async ({
147
147
  // entryFileNames: `./[name].js`,
148
148
  // https://rollupjs.org/guide/en#output-sourcemap
149
149
  sourcemap: true,
150
- sourcemapExcludeSources: true,
150
+ sourcemapExcludeSources,
151
151
  exports: "named",
152
152
  ...(compiledUrl
153
153
  ? { dir: urlToFileSystemPath(resolveUrl("./", compiledUrl)) }
@@ -165,11 +165,12 @@ export const commonJsToJavaScriptModule = async ({
165
165
  },
166
166
  {
167
167
  projectDirectoryUrl,
168
- originalFileContent: code,
168
+ jsenvRemoteDirectory,
169
169
  originalFileUrl: url,
170
170
  compiledFileUrl: compiledUrl,
171
- sourcemapFileUrl: `${compiledUrl}.map`,
171
+ sourcemapFileUrl: generateSourcemapUrl(compiledUrl),
172
172
  sourcemapExcludeSources,
173
+ originalFileContent: code,
173
174
  },
174
175
  )
175
176
  }
package/src/dev_server.js CHANGED
@@ -49,6 +49,7 @@ export const startDevServer = async ({
49
49
  serviceWorkers,
50
50
  importMapInWebWorkers,
51
51
  customCompilers,
52
+ preservedUrls,
52
53
  runtimeSupportDuringDev = {
53
54
  // this allows to compile nothing or almost nothing when opening files
54
55
  // with a recent chrome. Without this we would compile all the things not yet unsupported
@@ -125,6 +126,7 @@ export const startDevServer = async ({
125
126
  compileServerCanReadFromFilesystem,
126
127
  compileServerCanWriteOnFilesystem,
127
128
  customCompilers,
129
+ preservedUrls,
128
130
  sourcemapMethod,
129
131
  babelPluginMap,
130
132
  workers,
package/src/execute.js CHANGED
@@ -46,6 +46,7 @@ export const execute = async ({
46
46
  port,
47
47
  babelPluginMap,
48
48
  customCompilers,
49
+ preservedUrls,
49
50
  workers,
50
51
  serviceWorkers,
51
52
  importMapInWebWorkers,
@@ -112,6 +113,7 @@ export const execute = async ({
112
113
  [runtime.name]: runtime.version,
113
114
  }),
114
115
  customCompilers,
116
+ preservedUrls,
115
117
  workers,
116
118
  serviceWorkers,
117
119
  importMapInWebWorkers,