@jsenv/core 25.0.0 → 25.2.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 (60) 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 +8 -8
  15. package/readme.md +61 -52
  16. package/src/buildProject.js +21 -13
  17. package/src/commonJsToJavaScriptModule.js +8 -7
  18. package/src/execute.js +2 -0
  19. package/src/executeTestPlan.js +14 -0
  20. package/src/internal/building/buildUsingRollup.js +4 -2
  21. package/src/internal/building/build_stats.js +3 -0
  22. package/src/internal/building/build_url_generator.js +153 -0
  23. package/src/internal/building/css/parseCssRessource.js +32 -26
  24. package/src/internal/building/html/parseHtmlRessource.js +109 -91
  25. package/src/internal/building/js/parseJsRessource.js +5 -13
  26. package/src/internal/building/parseRessource.js +3 -0
  27. package/src/internal/building/ressource_builder.js +72 -64
  28. package/src/internal/building/ressource_builder_util.js +17 -5
  29. package/src/internal/building/rollup_plugin_jsenv.js +262 -189
  30. package/src/internal/building/url_fetcher.js +16 -7
  31. package/src/internal/building/url_loader.js +1 -5
  32. package/src/internal/building/url_versioning.js +0 -173
  33. package/src/internal/compiling/babel_plugin_import_metadata.js +7 -11
  34. package/src/internal/compiling/babel_plugin_proxy_external_imports.js +31 -0
  35. package/src/internal/compiling/compile-directory/compile-asset.js +8 -4
  36. package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +43 -8
  37. package/src/internal/compiling/compile-directory/updateMeta.js +2 -8
  38. package/src/internal/compiling/compile-directory/validateCache.js +1 -2
  39. package/src/internal/compiling/compileFile.js +22 -10
  40. package/src/internal/compiling/compileHtml.js +15 -28
  41. package/src/internal/compiling/createCompiledFileService.js +22 -24
  42. package/src/internal/compiling/html_source_file_service.js +18 -19
  43. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +14 -4
  44. package/src/internal/compiling/js-compilation-service/transformJs.js +9 -5
  45. package/src/internal/compiling/jsenvCompilerForHtml.js +534 -263
  46. package/src/internal/compiling/jsenvCompilerForJavaScript.js +15 -11
  47. package/src/internal/compiling/startCompileServer.js +83 -20
  48. package/src/internal/compiling/transformResultToCompilationResult.js +47 -25
  49. package/src/internal/executing/executePlan.js +2 -0
  50. package/src/internal/fetchUrl.js +3 -2
  51. package/src/internal/integrity/integrity_algorithms.js +26 -0
  52. package/src/internal/integrity/integrity_parsing.js +50 -0
  53. package/src/internal/integrity/integrity_update.js +23 -0
  54. package/src/internal/integrity/integrity_validation.js +49 -0
  55. package/src/internal/jsenvCoreDirectoryUrl.js +2 -0
  56. package/src/internal/jsenv_remote_directory.js +156 -0
  57. package/src/internal/origin_directory_converter.js +62 -0
  58. package/src/internal/response_validation.js +11 -24
  59. package/src/internal/sourceMappingURLUtils.js +10 -0
  60. 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.0.0",
3
+ "version": "25.2.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,7 +8,7 @@
8
8
  "url": "https://github.com/jsenv/jsenv-core"
9
9
  },
10
10
  "engines": {
11
- "node": ">=14.9.0"
11
+ "node": ">=16.13.0"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -59,11 +59,11 @@
59
59
  "@babel/plugin-transform-modules-systemjs": "7.16.5",
60
60
  "@c88/v8-coverage": "0.1.1",
61
61
  "@jsenv/abort": "4.1.2",
62
- "@jsenv/filesystem": "2.6.0",
62
+ "@jsenv/filesystem": "2.6.1",
63
63
  "@jsenv/importmap": "1.2.0",
64
64
  "@jsenv/log": "1.5.0",
65
65
  "@jsenv/logger": "4.0.1",
66
- "@jsenv/server": "12.2.1",
66
+ "@jsenv/server": "12.3.2",
67
67
  "@jsenv/uneval": "1.6.0",
68
68
  "@rollup/plugin-commonjs": "21.0.1",
69
69
  "@rollup/plugin-json": "4.1.0",
@@ -111,17 +111,17 @@
111
111
  "@babel/plugin-transform-react-jsx": "7.16.5",
112
112
  "@babel/plugin-transform-typescript": "7.16.1",
113
113
  "@babel/preset-env": "7.16.5",
114
- "@jsenv/assert": "2.4.0",
114
+ "@jsenv/assert": "2.4.1",
115
115
  "@jsenv/babel-preset": "./packages/jsenv-babel-preset",
116
116
  "@jsenv/eslint-config": "16.0.9",
117
117
  "@jsenv/file-size-impact": "12.1.1",
118
118
  "@jsenv/github-release-package": "1.2.3",
119
119
  "@jsenv/https-local": "1.0.3",
120
- "@jsenv/importmap-eslint-resolver": "5.2.1",
121
- "@jsenv/importmap-node-module": "5.0.0",
120
+ "@jsenv/importmap-eslint-resolver": "5.2.2",
121
+ "@jsenv/importmap-node-module": "5.1.0",
122
122
  "@jsenv/package-publish": "1.6.2",
123
123
  "@jsenv/performance-impact": "2.2.1",
124
- "@jsenv/pwa": "4.0.0",
124
+ "@jsenv/pwa": "4.0.1",
125
125
  "babel-plugin-transform-async-to-promises": "0.8.17",
126
126
  "eslint": "7.32.0",
127
127
  "eslint-plugin-html": "6.2.0",
package/readme.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # jsenv [![npm package](https://img.shields.io/npm/v/@jsenv/core.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/core) [![github main worflow](https://github.com/jsenv/jsenv-core/workflows/main/badge.svg)](https://github.com/jsenv/jsenv-core/actions?workflow=main) [![codecov coverage](https://codecov.io/gh/jsenv/jsenv-core/branch/master/graph/badge.svg)](https://codecov.io/gh/jsenv/jsenv-core)
2
2
 
3
- _@jsenv/core_ is a quick start pack to launch a js project.
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
- You don't have to pick a JavaScript framework: jsenv integrates naturally with standard HTML, CSS and JS. It provides what you need from the beginning: a dev server, a build tool and a test "framework", all in one.
5
+ Jsenv integrates naturally with standard HTML, CSS and JS: you don't have to pick a JavaScript framework.
6
6
 
7
- # Test runner overview
7
+ # Overview
8
+
9
+ This section demos 3 things jsenv provides:
10
+
11
+ 1. A test runner
12
+ 2. A dev server
13
+ 3. A build script
14
+
15
+ Don't be fooled by the apparent simplicity of the following demos, jsenv can be used on more complex scenarios as well.
16
+
17
+ ## Test runner overview
8
18
 
9
19
  Let's assume you want to test `countDogs` exported by _animals.js_ file.
10
20
 
@@ -94,7 +104,7 @@ total duration: 1.2 seconds
94
104
 
95
105
  To read more about testing in jsenv, check [jsenv test runner documentation](./docs/testing/readme.md#jsenv-test-runner).
96
106
 
97
- # Dev server overview
107
+ ## Dev server overview
98
108
 
99
109
  You want to execute the following _main.html_ file in a browser.
100
110
 
@@ -155,7 +165,7 @@ Browser navigates to _main.html_ and execute the file. Hello world is displayed
155
165
 
156
166
  To read more about jsenv dev server, check [jsenv dev server documentation](./docs/dev_server/readme.md#jsenv-dev-server).
157
167
 
158
- # Build overview
168
+ ## Build overview
159
169
 
160
170
  Following the steps below turns a `main.html` into an optimized `dist/main.prod.html`.
161
171
  Only the content of html files is shown below because the content of non-html files is trivial.
@@ -168,7 +178,7 @@ Only the content of html files is shown below because the content of non-html fi
168
178
  <meta charset="utf-8" />
169
179
  <link rel="modulepreload" href="./main.js" />
170
180
  <link rel="icon" href="./favicon.ico" />
171
- <script type="importmap" src="./import_map.importmap"></script>
181
+ <script type="importmap" src="./project.importmap"></script>
172
182
  <link rel="stylesheet" type="text/css" href="./main.css" />
173
183
  </head>
174
184
 
@@ -207,14 +217,14 @@ await buildProject({
207
217
 
208
218
  building ./main.html...
209
219
  --- files in the build: 5 ---
210
- dist/assets/favicon-25e95a00.png (6.67 KB)
211
- dist/assets/main-feec3a1b.css (62 B)
212
- 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)
213
223
  dist/main.prod.html (392 B)
214
- dist/project-d2192ffe.importmap (29 B)
224
+ dist/project_b237a334.importmap (29 B)
215
225
  --- sourcemap files in the build: 2 ---
216
- dist/assets/main-feec3a1b.css.map (198 B)
217
- dist/main-63252261.js.map (55Kb B)
226
+ dist/assets/main_3b329ff0.css.map (198 B)
227
+ dist/main_3b329ff0.js.map (55Kb B)
218
228
  ------- build summary -------
219
229
  project files: 27 (70.38 KB)
220
230
  build files: 5 (45.2 KB)
@@ -231,14 +241,14 @@ build duration: 1.85 seconds
231
241
  <head>
232
242
  <title>Title</title>
233
243
  <meta charset="utf-8" />
234
- <link rel="modulepreload" href="main-f7379e10.js" />
235
- <link rel="icon" href="assets/favicon-5340s4789a.ico" />
236
- <script type="importmap" src="import-map-b237a334.importmap"></script>
237
- <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" />
238
248
  </head>
239
249
 
240
250
  <body>
241
- <script type="module" src="./main-f7379e10.js"></script>
251
+ <script type="module" src="./main_f7379e10.js"></script>
242
252
  </body>
243
253
  </html>
244
254
  ```
@@ -253,7 +263,7 @@ Jsenv was first created to write tests that could be executed in different runti
253
263
  - A test runner to execute test files
254
264
  - A build tool to optimize files for production
255
265
 
256
- Jsenv relies on standard web features. Each standard listed below is potentially supported natively by the browser. When browser supports all of them, jsenv will use source files without modification. Otherwise, the files are compiled to be executable in the browser.
266
+ Jsenv relies on **standard web features**. Each standard listed below is potentially supported natively by the browser. When browser supports all of them, jsenv will use source files without modification. Otherwise, the files are compiled to be executable in the browser.
257
267
 
258
268
  - `<script type="module">`
259
269
  - `<script type="importmap">`
@@ -266,7 +276,7 @@ Jsenv relies on standard web features. Each standard listed below is potentially
266
276
 
267
277
  Amongst other use cases, the ease of use and flexibility of jsenv makes it a great tool to start and learn web development.
268
278
 
269
- 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.
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**. 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.
270
280
 
271
281
  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.
272
282
 
@@ -324,57 +334,56 @@ _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 16.13.0. Other operati
324
334
 
325
335
  # Configuration
326
336
 
327
- Jsenv configuration is done in [jsenv.config.mjs](#jsenvconfigmjs) and [babel.config.cjs](#babelconfigcjs).
337
+ We recommend to put some jsenv configuration in a top level file named _jsenv.config.mjs_.
328
338
 
329
- ## jsenv.config.mjs
330
-
331
- We recommend to put configuration in a top level file named _jsenv.config.mjs_ like the one below:
339
+ The presence of a jsenv configuration file is **optional**.
332
340
 
333
341
  ```js
334
342
  /*
335
- * This file exports configuration reused by jsenv scripts such as
343
+ * This file exports configuration reused by other files such as
336
344
  *
337
345
  * script/test/test.mjs
338
346
  * script/build/build.mjs
339
347
  *
340
- * Read more at https://github.com/jsenv/jsenv-core#jsenvconfigmjs
348
+ * Read more at https://github.com/jsenv/jsenv-core#configuration
341
349
  */
342
350
 
343
351
  export const projectDirectoryUrl = new URL("./", import.meta.url)
344
352
  ```
345
353
 
346
- 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.
354
+ _jsenv.config.mjs_ is meant to share configuration, other files will simply import what they need.
347
355
 
348
- ## babel.config.cjs
356
+ ```diff
357
+ import { buildProject } from '@jsenv/core'
349
358
 
350
- When code needs to be transformed, the project must contain a [babel config file](https://babeljs.io/docs/en/config-files).
359
+ + import { projectDirectoryUrl } from "./jsenv.config.mjs"
351
360
 
352
- It's recommended to use the following _babel.config.cjs_
361
+ await buildProject({
362
+ - projectDirectoryUrl: new URL('./', import.meta.url)
363
+ + projectDirectoryUrl
364
+ })
365
+ ```
353
366
 
354
- ```js
355
- /*
356
- * This file configure the list of babel plugins enabled
357
- * in this codebase
358
- *
359
- * Read more at https://github.com/jsenv/jsenv-core/tree/master/packages/jsenv-babel-preset
360
- */
367
+ > 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.
361
368
 
362
- module.exports = {
363
- presets: ["@jsenv/babel-preset"],
364
- }
365
- ```
369
+ # Documentation
370
+
371
+ | Link | Description |
372
+ | -------------------------------------------------------- | ------------------------------------------ |
373
+ | [Browser support](./docs/browser_support/readme.md) | Documentation around browser support |
374
+ | [Assets](./docs/assets/readme.md) | How to use assets (CSS, JSON, images, ...) |
375
+ | [CDN](./docs/cdn/readme.md) | How to use ressources from CDN |
376
+ | [Web workers](./docs/web_workers/readme.md) | How to use web workers |
377
+ | [NPM package](./docs/npm_package/readme.md) | How to use a NPM package |
378
+ | [React](./docs/react/readme.md) | How to enable react (or preact) and JSX |
379
+ | [TypeScript (Experimental)](./docs/typescript/readme.md) | How to enable TypeScript |
366
380
 
367
381
  # See also
368
382
 
369
- | Link | Description |
370
- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
371
- | [Browser support](./docs/config/browser_support.md) | Document how to configure browser support |
372
- | [Web workers](./docs/config/web_workers.md) | Document how to use web workers |
373
- | [React](./docs/config/react.md) | Document how to enable react/preact and JSX |
374
- | [CommonJS modules](./docs/config/commonjs.md) | Document how to use code written in CommonJS |
375
- | [TypeScript (Experimental)](./docs/config/typescript.md) | Document how to enable TypeScript |
376
- | [@jsenv/template-pwa](https://github.com/jsenv/jsenv-template-pwa) | GitHub repository template for a progressive web application |
377
- | [@jsenv/template-node-package](https://github.com/jsenv/jsenv-template-node-package) | GitHub repository template for a node package |
378
- | [@jsenv/assert](https://github.com/jsenv/assert) | NPM package to write assertions |
379
- | [I am too lazy for a test framework](shorturl.at/rFY39) | Article presenting a straightforward testing experience |
380
- | [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/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,