@jsenv/core 25.6.2 → 27.0.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 (476) hide show
  1. package/main.js +18 -20
  2. package/package.json +38 -73
  3. package/readme.md +32 -44
  4. package/src/build/build.js +737 -0
  5. package/src/build/build_urls_generator.js +64 -0
  6. package/src/build/inject_version_mappings.js +62 -0
  7. package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +225 -0
  8. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +30 -0
  9. package/src/build/plugins/minify_js/jsenv_plugin_minify_js.js +47 -0
  10. package/src/dev/plugins/autoreload/babel_plugin_metadata_import_meta_hot.js +98 -0
  11. package/src/dev/plugins/autoreload/client/autoreload_preference.js +11 -0
  12. package/src/dev/plugins/autoreload/client/event_source_client.js +186 -0
  13. package/src/{internal/dev_server/event_source_client → dev/plugins/autoreload/client}/event_source_connection.js +21 -25
  14. package/src/dev/plugins/autoreload/client/import_meta_hot.js +80 -0
  15. package/src/dev/plugins/autoreload/client/reload.js +101 -0
  16. package/src/dev/plugins/autoreload/client/url_helpers.js +20 -0
  17. package/src/dev/plugins/autoreload/html_hot_dependencies.js +156 -0
  18. package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +374 -0
  19. package/src/dev/plugins/autoreload/sse_service.js +149 -0
  20. package/src/dev/plugins/explorer/client/explorer.html +607 -0
  21. package/src/{internal → dev/plugins/explorer/client}/jsenv.png +0 -0
  22. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +74 -0
  23. package/src/{internal/dev_server/toolbar/animation/toolbar.animation.js → dev/plugins/toolbar/client/animation/toolbar_animation.js} +0 -0
  24. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/eventsource/eventsource.css +2 -2
  25. package/src/dev/plugins/toolbar/client/eventsource/toolbar_eventsource.js +57 -0
  26. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/execution/execution.css +0 -0
  27. package/src/dev/plugins/toolbar/client/execution/toolbar_execution.js +88 -0
  28. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/focus.css +0 -0
  29. package/src/{internal/dev_server/toolbar/focus/toolbar.focus.js → dev/plugins/toolbar/client/focus/toolbar_focus.js} +0 -0
  30. package/src/{internal/dev_server/toolbar/jsenv-logo.svg → dev/plugins/toolbar/client/jsenv_logo.svg} +1 -1
  31. package/src/{internal/dev_server/toolbar/notification/toolbar.notification.js → dev/plugins/toolbar/client/notification/toolbar_notification.js} +0 -0
  32. package/src/{internal/dev_server/toolbar/responsive/overflow-menu.css → dev/plugins/toolbar/client/responsive/overflow_menu.css} +0 -0
  33. package/src/{internal/dev_server/toolbar/responsive/toolbar.responsive.js → dev/plugins/toolbar/client/responsive/toolbar_responsive.js} +0 -0
  34. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/settings.css +0 -0
  35. package/src/{internal/dev_server/toolbar/settings/toolbar.settings.js → dev/plugins/toolbar/client/settings/toolbar_settings.js} +1 -0
  36. package/src/{internal/dev_server/toolbar/theme/jsenv-theme.css → dev/plugins/toolbar/client/theme/jsenv_theme.css} +1 -15
  37. package/src/{internal/dev_server/toolbar/theme/light-theme.css → dev/plugins/toolbar/client/theme/light_theme.css} +0 -17
  38. package/src/{internal/dev_server/toolbar/theme/toolbar.theme.js → dev/plugins/toolbar/client/theme/toolbar_theme.js} +0 -0
  39. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar.html +42 -201
  40. package/src/{internal/dev_server/toolbar/toolbar.injector.js → dev/plugins/toolbar/client/toolbar_injector.js} +10 -29
  41. package/src/{internal/dev_server/toolbar/toolbar.main.css → dev/plugins/toolbar/client/toolbar_main.css} +2 -26
  42. package/src/{internal/dev_server/toolbar/toolbar.main.js → dev/plugins/toolbar/client/toolbar_main.js} +18 -64
  43. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.css +1 -1
  44. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.js +0 -0
  45. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/animation.js +0 -0
  46. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/dom.js +0 -0
  47. package/src/{internal/browser_utils/fetchUsingXHR.js → dev/plugins/toolbar/client/util/fetch_using_xhr.js} +0 -2
  48. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/fetching.js +2 -4
  49. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/iframe_to_parent_href.js +0 -0
  50. package/src/{internal/dev_server/toolbar/util/jsenvLogger.js → dev/plugins/toolbar/client/util/jsenv_logger.js} +0 -0
  51. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/preferences.js +0 -0
  52. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/responsive.js +0 -0
  53. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/util.js +0 -0
  54. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/variant/variant.js +0 -0
  55. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +62 -0
  56. package/src/dev/start_dev_server.js +105 -0
  57. package/src/execute/execute.js +132 -0
  58. package/src/execute/run.js +208 -0
  59. package/src/execute/runtimes/browsers/chromium.js +8 -0
  60. package/src/execute/runtimes/browsers/firefox.js +7 -0
  61. package/src/execute/runtimes/browsers/from_playwright.js +464 -0
  62. package/src/execute/runtimes/browsers/webkit.js +24 -0
  63. package/src/{internal/node_launcher/createChildProcessOptions.js → execute/runtimes/node/child_exec_options.js} +25 -36
  64. package/src/{internal/node_runtime/nodeControllableFile.mjs → execute/runtimes/node/controllable_file.mjs} +1 -18
  65. package/src/{internal/node_launcher/createControllableNodeProcess.js → execute/runtimes/node/controlled_process.js} +128 -150
  66. package/src/execute/runtimes/node/exec_options.js +44 -0
  67. package/src/{internal/node_launcher → execute/runtimes/node}/kill_process_tree.js +4 -2
  68. package/src/execute/runtimes/node/node_process.js +92 -0
  69. package/src/execute/runtimes/node/node_worker_thread.js +28 -0
  70. package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +29 -0
  71. package/src/{internal/compiling/js-compilation-service → omega/core_plugins/babel/babel_helper}/babel_plugin_babel_helpers_as_jsenv_imports.js +16 -19
  72. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/.eslintrc.cjs +0 -0
  73. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AsyncGenerator/AsyncGenerator.js +0 -0
  74. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AwaitValue/AwaitValue.js +0 -0
  75. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -0
  76. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayLikeToArray/arrayLikeToArray.js +0 -0
  77. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithHoles/arrayWithHoles.js +0 -0
  78. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithoutHoles/arrayWithoutHoles.js +0 -0
  79. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/assertThisInitialized/assertThisInitialized.js +0 -0
  80. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -0
  81. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncIterator/asyncIterator.js +0 -0
  82. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncToGenerator/asyncToGenerator.js +0 -0
  83. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -0
  84. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -0
  85. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -0
  86. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -0
  87. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCallCheck/classCallCheck.js +0 -0
  88. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -0
  89. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -0
  90. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -0
  91. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classNameTDZError/classNameTDZError.js +0 -0
  92. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -0
  93. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldGet/classPrivateFieldGet.js +0 -0
  94. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -0
  95. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -0
  96. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldSet/classPrivateFieldSet.js +0 -0
  97. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodGet/classPrivateMethodGet.js +0 -0
  98. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodSet/classPrivateMethodSet.js +0 -0
  99. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -0
  100. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -0
  101. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -0
  102. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -0
  103. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/construct/construct.js +0 -0
  104. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createClass/createClass.js +0 -0
  105. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -0
  106. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -0
  107. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createRawReactElement/createRawReactElement.js +0 -0
  108. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createSuper/createSuper.js +0 -0
  109. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/decorate/decorate.js +0 -0
  110. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defaults/defaults.js +0 -0
  111. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineEnumerableProperties/defineEnumerableProperties.js +0 -0
  112. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineProperty/defineProperty.js +0 -0
  113. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/extends/extends.js +0 -0
  114. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/get/get.js +0 -0
  115. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/getPrototypeOf/getPrototypeOf.js +0 -0
  116. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inherits/inherits.js +0 -0
  117. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inheritsLoose/inheritsLoose.js +0 -0
  118. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerDefineProperty/initializerDefineProperty.js +0 -0
  119. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerWarningHelper/initializerWarningHelper.js +0 -0
  120. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/instanceof/instanceof.js +0 -0
  121. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireDefault/interopRequireDefault.js +0 -0
  122. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireWildcard/interopRequireWildcard.js +0 -0
  123. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeFunction/isNativeFunction.js +0 -0
  124. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -0
  125. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArray/iterableToArray.js +0 -0
  126. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimit/iterableToArrayLimit.js +0 -0
  127. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -0
  128. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/jsx/jsx.js +0 -0
  129. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/maybeArrayLike/maybeArrayLike.js +0 -0
  130. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/newArrowCheck/newArrowCheck.js +0 -0
  131. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableRest/nonIterableRest.js +0 -0
  132. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableSpread/nonIterableSpread.js +0 -0
  133. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -0
  134. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread/objectSpread.js +0 -0
  135. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread2/objectSpread2.js +0 -0
  136. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutProperties/objectWithoutProperties.js +0 -0
  137. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -0
  138. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/possibleConstructorReturn/possibleConstructorReturn.js +0 -0
  139. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readOnlyError/readOnlyError.js +0 -0
  140. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readme.md +0 -0
  141. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/set/set.js +0 -0
  142. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/setPrototypeOf/setPrototypeOf.js +0 -0
  143. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -0
  144. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArray/slicedToArray.js +0 -0
  145. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArrayLoose/slicedToArrayLoose.js +0 -0
  146. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/superPropBase/superPropBase.js +0 -0
  147. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -0
  148. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -0
  149. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/tdz/tdz.js +0 -0
  150. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalRef/temporalRef.js +0 -0
  151. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalUndefined/temporalUndefined.js +0 -0
  152. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toArray/toArray.js +0 -0
  153. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toConsumableArray/toConsumableArray.js +0 -0
  154. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPrimitive/toPrimitive.js +0 -0
  155. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPropertyKey/toPropertyKey.js +0 -0
  156. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/typeof/typeof.js +0 -0
  157. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -0
  158. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -0
  159. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapNativeSuper/wrapNativeSuper.js +0 -0
  160. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapRegExp/wrapRegExp.js +0 -0
  161. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/writeOnlyError/writeOnlyError.js +0 -0
  162. package/src/omega/core_plugins/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +35 -0
  163. package/{helpers/global-this/global-this.js → src/omega/core_plugins/babel/global_this/client/global_this.js} +0 -0
  164. package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +187 -0
  165. package/src/{internal/features → omega/core_plugins/babel/helpers}/babel_plugins_compatibility.js +1 -24
  166. package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +97 -0
  167. package/src/omega/core_plugins/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +117 -0
  168. package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +24 -0
  169. package/{helpers/new_stylesheet → src/omega/core_plugins/babel/new_stylesheet/client}/new_stylesheet.js +0 -0
  170. package/src/omega/core_plugins/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +34 -0
  171. package/{helpers/regenerator-runtime/regenerator-runtime.js → src/omega/core_plugins/babel/regenerator_runtime/client/regenerator_runtime.js} +0 -0
  172. package/src/omega/core_plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +169 -0
  173. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +67 -0
  174. package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +58 -0
  175. package/src/{internal/browser_runtime/displayErrorInDocument.js → omega/core_plugins/html_supervisor/client/error_in_document.js} +10 -18
  176. package/src/{internal/browser_runtime/displayErrorNotification.js → omega/core_plugins/html_supervisor/client/error_in_notification.js} +0 -1
  177. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +168 -0
  178. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +77 -0
  179. package/src/{internal → omega/core_plugins/html_supervisor/client}/perf_browser.js +0 -2
  180. package/src/{internal/unevalException.js → omega/core_plugins/html_supervisor/client/uneval_exception.js} +1 -1
  181. package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +233 -0
  182. package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +98 -0
  183. package/src/{internal/building → omega/core_plugins/import_assertions/helpers}/json_module.js +3 -2
  184. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +6 -0
  185. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +211 -0
  186. package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +80 -0
  187. package/src/omega/core_plugins/importmap/jsenv_plugin_importmap.js +212 -0
  188. package/src/omega/core_plugins/inline/client/inline_content.js +6 -0
  189. package/src/omega/core_plugins/inline/jsenv_plugin_data_urls.js +70 -0
  190. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +13 -0
  191. package/src/omega/core_plugins/inline/jsenv_plugin_inline_query_param.js +42 -0
  192. package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +142 -0
  193. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +210 -0
  194. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +12 -0
  195. package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +77 -0
  196. package/src/omega/core_plugins/url_resolution/jsenv_plugin_url_resolution.js +28 -0
  197. package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +50 -0
  198. package/src/omega/core_plugins.js +39 -0
  199. package/src/omega/errors.js +168 -0
  200. package/src/omega/file_url_converter.js +63 -0
  201. package/src/omega/kitchen.js +777 -0
  202. package/src/omega/omega_server.js +129 -0
  203. package/src/omega/plugin_controller.js +240 -0
  204. package/src/omega/runtime_support/default_runtime_support.js +13 -0
  205. package/src/omega/runtime_support/features_compatibility.js +91 -0
  206. package/src/omega/runtime_support/runtime_support.js +20 -0
  207. package/src/omega/server/file_service.js +155 -0
  208. package/src/omega/server/user_agent.js +22 -0
  209. package/src/omega/url_graph/url_graph_load.js +68 -0
  210. package/src/omega/url_graph/url_graph_report.js +151 -0
  211. package/src/omega/url_graph/url_graph_sort.js +29 -0
  212. package/src/omega/url_graph/url_info_transformations.js +161 -0
  213. package/src/omega/url_graph.js +132 -0
  214. package/src/omega/url_mentions/css_url_mentions.js +63 -0
  215. package/src/omega/url_mentions/html_url_mentions.js +185 -0
  216. package/src/omega/url_mentions/js_module_url_mentions.js +91 -0
  217. package/src/omega/url_mentions/parse_url_mentions.js +37 -0
  218. package/src/omega/url_mentions/worker_classic_url_mentions.js +37 -0
  219. package/src/{internal/executing/executePlan.js → test/execute_plan.js} +159 -213
  220. package/src/{executeTestPlan.js → test/execute_test_plan.js} +36 -84
  221. package/src/{internal/executing → test}/execution_colors.js +0 -0
  222. package/src/{internal/executing/generateFileExecutionSteps.js → test/execution_steps.js} +25 -4
  223. package/src/{internal/executing → test}/gc.js +0 -0
  224. package/src/test/logs_file_execution.js +223 -0
  225. package/dist/browser_runtime/asset-manifest.json +0 -4
  226. package/dist/browser_runtime/browser_runtime_c81cd9af.js +0 -5300
  227. package/dist/browser_runtime/browser_runtime_c81cd9af.js.map +0 -1089
  228. package/dist/build_manifest.js +0 -12
  229. package/dist/compile_proxy/asset-manifest.json +0 -4
  230. package/dist/compile_proxy/compile_proxy.html__inline__20_c05fdc30.js.map +0 -343
  231. package/dist/compile_proxy/compile_proxy_93ec4247.html +0 -2247
  232. package/dist/event_source_client/asset-manifest.json +0 -4
  233. package/dist/event_source_client/event_source_client_69f48287.js +0 -354
  234. package/dist/event_source_client/event_source_client_69f48287.js.map +0 -128
  235. package/dist/redirector/asset-manifest.json +0 -4
  236. package/dist/redirector/redirector.html__inline__12_20421b23.js.map +0 -349
  237. package/dist/redirector/redirector_ddc79416.html +0 -2292
  238. package/dist/toolbar/asset-manifest.json +0 -13
  239. package/dist/toolbar/assets/compilation.css_7421bd55.map +0 -12
  240. package/dist/toolbar/assets/eventsource.css_c0c71e7b.map +0 -12
  241. package/dist/toolbar/assets/execution.css_f3377c10.map +0 -12
  242. package/dist/toolbar/assets/focus.css_896f3e45.map +0 -12
  243. package/dist/toolbar/assets/light-theme.css_72a60fa3.map +0 -12
  244. package/dist/toolbar/assets/overflow-menu.css_2859d519.map +0 -12
  245. package/dist/toolbar/assets/settings.css_942b5a9e.map +0 -12
  246. package/dist/toolbar/assets/toolbar.main.css_b7d8bec1.map +0 -28
  247. package/dist/toolbar/assets/tooltip.css_a94a8bdd.map +0 -12
  248. package/dist/toolbar/toolbar.main_7d7783d3.js.map +0 -776
  249. package/dist/toolbar/toolbar_d6045dd0.html +0 -4978
  250. package/dist/toolbar_injector/asset-manifest.json +0 -5
  251. package/dist/toolbar_injector/assets/jsenv-logo_188b9ca6.svg +0 -95
  252. package/dist/toolbar_injector/toolbar_injector_c8c214dd.js +0 -977
  253. package/dist/toolbar_injector/toolbar_injector_c8c214dd.js.map +0 -294
  254. package/helpers/import-meta/import-meta-url-commonjs.js +0 -9
  255. package/helpers/import-meta/import-meta-url-global.js +0 -54
  256. package/src/buildProject.js +0 -336
  257. package/src/commonJsToJavaScriptModule.js +0 -180
  258. package/src/dev_server.js +0 -295
  259. package/src/execute.js +0 -184
  260. package/src/importUsingChildProcess.js +0 -68
  261. package/src/internal/argUtils.js +0 -12
  262. package/src/internal/babel_plugin_replace_expressions.js +0 -101
  263. package/src/internal/browser_detection/browser_detection.js +0 -68
  264. package/src/internal/browser_detection/detectAndroid.js +0 -13
  265. package/src/internal/browser_detection/detectChrome.js +0 -28
  266. package/src/internal/browser_detection/detectEdge.js +0 -13
  267. package/src/internal/browser_detection/detectElectron.js +0 -1
  268. package/src/internal/browser_detection/detectFirefox.js +0 -17
  269. package/src/internal/browser_detection/detectIOS.js +0 -19
  270. package/src/internal/browser_detection/detectInternetExplorer.js +0 -14
  271. package/src/internal/browser_detection/detectOpera.js +0 -27
  272. package/src/internal/browser_detection/detectSafari.js +0 -13
  273. package/src/internal/browser_detection/user_agent_data.js +0 -26
  274. package/src/internal/browser_detection/util.js +0 -13
  275. package/src/internal/browser_launcher/browser_runtime_profile.js +0 -81
  276. package/src/internal/browser_launcher/executeHtmlFile.js +0 -354
  277. package/src/internal/browser_launcher/from_playwright.js +0 -320
  278. package/src/internal/browser_launcher/trackPageToNotify.js +0 -77
  279. package/src/internal/browser_runtime/browser_runtime.js +0 -224
  280. package/src/internal/browser_runtime/browser_system.js +0 -218
  281. package/src/internal/browser_runtime/createBrowserRuntime.js +0 -146
  282. package/src/internal/browser_runtime/evalSource.js +0 -11
  283. package/src/internal/browser_runtime/makeNamespaceTransferable.js +0 -90
  284. package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +0 -29
  285. package/src/internal/browser_utils/fetchAndEvalUsingScript.js +0 -49
  286. package/src/internal/browser_utils/fetchJson.js +0 -7
  287. package/src/internal/browser_utils/fetch_browser.js +0 -34
  288. package/src/internal/building/buildToCompilationResult.js +0 -183
  289. package/src/internal/building/buildUsingRollup.js +0 -359
  290. package/src/internal/building/build_logs.js +0 -133
  291. package/src/internal/building/build_stats.js +0 -100
  292. package/src/internal/building/build_url_generator.js +0 -153
  293. package/src/internal/building/css/applyPostCss.js +0 -55
  294. package/src/internal/building/css/moveCssUrls.js +0 -44
  295. package/src/internal/building/css/parseCssRessource.js +0 -259
  296. package/src/internal/building/css/parseCssUrls.js +0 -38
  297. package/src/internal/building/css/postcss_plugin_url_visitor.js +0 -244
  298. package/src/internal/building/css/replaceCssUrls.js +0 -67
  299. package/src/internal/building/css_module.js +0 -43
  300. package/src/internal/building/es_to_system.js +0 -34
  301. package/src/internal/building/html/htmlScan.js +0 -70
  302. package/src/internal/building/html/minifyHtml.js +0 -7
  303. package/src/internal/building/html/parseHtmlRessource.js +0 -814
  304. package/src/internal/building/import_references.js +0 -80
  305. package/src/internal/building/importmap/parseImportmapRessource.js +0 -28
  306. package/src/internal/building/js/babel_plugin_inline_worker_imports.js +0 -96
  307. package/src/internal/building/js/minifyJs.js +0 -33
  308. package/src/internal/building/js/parseJsRessource.js +0 -121
  309. package/src/internal/building/js/transform_worker.js +0 -55
  310. package/src/internal/building/json/parseJsonRessource.js +0 -11
  311. package/src/internal/building/parseRessource.js +0 -207
  312. package/src/internal/building/parsing.utils.js +0 -29
  313. package/src/internal/building/resolve_import_url_helper.js +0 -12
  314. package/src/internal/building/ressource_builder.js +0 -1097
  315. package/src/internal/building/ressource_builder_util.js +0 -194
  316. package/src/internal/building/rollup_plugin_jsenv.js +0 -1963
  317. package/src/internal/building/sortObjectByPathnames.js +0 -10
  318. package/src/internal/building/sourcemap_loader.js +0 -73
  319. package/src/internal/building/svg/parseSvgRessource.js +0 -111
  320. package/src/internal/building/url_fetcher.js +0 -85
  321. package/src/internal/building/url_loader.js +0 -127
  322. package/src/internal/building/url_trace.js +0 -229
  323. package/src/internal/building/url_versioning.js +0 -65
  324. package/src/internal/building/webmanifest/parseWebmanifestRessource.js +0 -48
  325. package/src/internal/compiling/babel_parse_error.js +0 -9
  326. package/src/internal/compiling/babel_plugin_global_this_as_jsenv_import.js +0 -34
  327. package/src/internal/compiling/babel_plugin_import_assertions.js +0 -120
  328. package/src/internal/compiling/babel_plugin_import_metadata.js +0 -18
  329. package/src/internal/compiling/babel_plugin_import_visitor.js +0 -84
  330. package/src/internal/compiling/babel_plugin_new_stylesheet_as_jsenv_import.js +0 -113
  331. package/src/internal/compiling/babel_plugin_proxy_external_imports.js +0 -31
  332. package/src/internal/compiling/babel_plugin_transform_import_meta.js +0 -134
  333. package/src/internal/compiling/babel_plugins.js +0 -37
  334. package/src/internal/compiling/compileFile.js +0 -271
  335. package/src/internal/compiling/compileHtml.js +0 -544
  336. package/src/internal/compiling/createCompiledFileService.js +0 -263
  337. package/src/internal/compiling/html_source_file_service.js +0 -453
  338. package/src/internal/compiling/js-compilation-service/ansiToHTML.js +0 -9
  339. package/src/internal/compiling/js-compilation-service/babelHelper.js +0 -145
  340. package/src/internal/compiling/js-compilation-service/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -48
  341. package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +0 -23
  342. package/src/internal/compiling/js-compilation-service/generateBabelHelper.js +0 -36
  343. package/src/internal/compiling/js-compilation-service/transformJs.js +0 -196
  344. package/src/internal/compiling/jsenvCompilerForHtml.js +0 -674
  345. package/src/internal/compiling/jsenvCompilerForImportmap.js +0 -28
  346. package/src/internal/compiling/jsenvCompilerForJavaScript.js +0 -61
  347. package/src/internal/compiling/jsenv_directory/comparison_utils.js +0 -27
  348. package/src/internal/compiling/jsenv_directory/compile_asset.js +0 -24
  349. package/src/internal/compiling/jsenv_directory/compile_context.js +0 -60
  350. package/src/internal/compiling/jsenv_directory/compile_profile.js +0 -217
  351. package/src/internal/compiling/jsenv_directory/file_lock_registry.js +0 -24
  352. package/src/internal/compiling/jsenv_directory/file_lock_registry.test.js +0 -47
  353. package/src/internal/compiling/jsenv_directory/fs-optimized-for-cache.js +0 -57
  354. package/src/internal/compiling/jsenv_directory/getOrGenerateCompiledFile.js +0 -269
  355. package/src/internal/compiling/jsenv_directory/jsenv_directory.js +0 -174
  356. package/src/internal/compiling/jsenv_directory/updateMeta.js +0 -150
  357. package/src/internal/compiling/jsenv_directory/validateCache.js +0 -264
  358. package/src/internal/compiling/load_babel_plugin_map_from_file.js +0 -49
  359. package/src/internal/compiling/rollup_plugin_commonjs_named_exports.js +0 -187
  360. package/src/internal/compiling/sse_service/sse_service.js +0 -369
  361. package/src/internal/compiling/startCompileServer.js +0 -518
  362. package/src/internal/compiling/transformResultToCompilationResult.js +0 -242
  363. package/src/internal/dataUrl.utils.js +0 -55
  364. package/src/internal/dev_server/event_source_client/event_source_client.js +0 -63
  365. package/src/internal/dev_server/event_source_client/file_changes.js +0 -82
  366. package/src/internal/dev_server/event_source_client/livereload_preference.js +0 -13
  367. package/src/internal/dev_server/exploring/exploring.css +0 -237
  368. package/src/internal/dev_server/exploring/exploring.html +0 -79
  369. package/src/internal/dev_server/exploring/exploring.js +0 -243
  370. package/src/internal/dev_server/exploring/fetchExploringJson.js +0 -19
  371. package/src/internal/dev_server/toolbar/compilation/compilation.css +0 -23
  372. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +0 -201
  373. package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +0 -83
  374. package/src/internal/dev_server/toolbar/execution/toolbar.execution.js +0 -91
  375. package/src/internal/error-stack-remapping/getOriginalCallsites.js +0 -217
  376. package/src/internal/error-stack-remapping/installBrowserErrorStackRemapping.js +0 -45
  377. package/src/internal/error-stack-remapping/installErrorStackRemapping.js +0 -141
  378. package/src/internal/error-stack-remapping/installNodeErrorStackRemapping.js +0 -20
  379. package/src/internal/error-stack-remapping/remapCallSite.js +0 -314
  380. package/src/internal/error-stack-remapping/stackToString.js +0 -9
  381. package/src/internal/escapeRegexpSpecialCharacters.js +0 -34
  382. package/src/internal/escapeTemplateStringSpecialCharacters.js +0 -20
  383. package/src/internal/executing/coverage/babel_plugin_instrument.js +0 -90
  384. package/src/internal/executing/coverage/reportToCoverage.js +0 -198
  385. package/src/internal/executing/coverage_missing/createEmptyCoverage.js +0 -6
  386. package/src/internal/executing/coverage_missing/list_files_not_covered.js +0 -20
  387. package/src/internal/executing/coverage_missing/missing_coverage.js +0 -46
  388. package/src/internal/executing/coverage_missing/relativeUrlToEmptyCoverage.js +0 -63
  389. package/src/internal/executing/coverage_reporter/coverage_reporter_html_directory.js +0 -36
  390. package/src/internal/executing/coverage_reporter/coverage_reporter_json_file.js +0 -22
  391. package/src/internal/executing/coverage_reporter/coverage_reporter_text_log.js +0 -19
  392. package/src/internal/executing/coverage_reporter/istanbulCoverageMapFromCoverage.js +0 -16
  393. package/src/internal/executing/coverage_utils/file_by_file_coverage.js +0 -28
  394. package/src/internal/executing/coverage_utils/istanbul_coverage_composition.js +0 -28
  395. package/src/internal/executing/coverage_utils/v8_and_istanbul.js +0 -38
  396. package/src/internal/executing/coverage_utils/v8_coverage_composition.js +0 -23
  397. package/src/internal/executing/coverage_utils/v8_coverage_from_directory.js +0 -86
  398. package/src/internal/executing/coverage_utils/v8_coverage_to_istanbul.js +0 -100
  399. package/src/internal/executing/createSummaryLog.js +0 -143
  400. package/src/internal/executing/executionIsPassed.js +0 -2
  401. package/src/internal/executing/executionLogs.js +0 -159
  402. package/src/internal/executing/generateExecutionSteps.js +0 -29
  403. package/src/internal/executing/launchAndExecute.js +0 -458
  404. package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +0 -20
  405. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +0 -23
  406. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +0 -25
  407. package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +0 -37
  408. package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +0 -9
  409. package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +0 -14
  410. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +0 -89
  411. package/src/internal/features/browser_feature_detection/compile_proxy.html +0 -27
  412. package/src/internal/features/browser_feature_detection/execute_with_script_module.js +0 -24
  413. package/src/internal/features/features_compat_from_runtime.js +0 -38
  414. package/src/internal/features/features_compat_from_runtime_support.js +0 -31
  415. package/src/internal/features/features_compatibility.js +0 -37
  416. package/src/internal/features/node_feature_detection/feature_detect_dynamic_import.mjs +0 -5
  417. package/src/internal/features/node_feature_detection/feature_detect_top_level_await.mjs +0 -1
  418. package/src/internal/features/node_feature_detection/node_feature_detect_dynamic_import.js +0 -5
  419. package/src/internal/features/node_feature_detection/node_feature_detect_top_level_await.js +0 -16
  420. package/src/internal/features/node_feature_detection/node_feature_detection.js +0 -66
  421. package/src/internal/fetchUrl.js +0 -28
  422. package/src/internal/filePathUtils.js +0 -19
  423. package/src/internal/import-resolution/default-extension.js +0 -40
  424. package/src/internal/import-resolution/import-resolver-importmap.js +0 -64
  425. package/src/internal/import-resolution/import-resolver-node.js +0 -254
  426. package/src/internal/import-resolution/importmap_default.js +0 -37
  427. package/src/internal/jsenvCoreDirectoryUrl.js +0 -11
  428. package/src/internal/jsenvInternalFiles.js +0 -36
  429. package/src/internal/jsenv_builds.js +0 -19
  430. package/src/internal/jsenv_remote_directory.js +0 -156
  431. package/src/internal/logs/byte.js +0 -10
  432. package/src/internal/logs/byteAsFileSize.js +0 -9
  433. package/src/internal/logs/msAsDuration.js +0 -12
  434. package/src/internal/memoize.js +0 -24
  435. package/src/internal/node_launcher/node_runtime_report.js +0 -77
  436. package/src/internal/node_launcher/processOptions.js +0 -46
  437. package/src/internal/node_runtime/evalSource.js +0 -6
  438. package/src/internal/node_runtime/fetchSource.js +0 -8
  439. package/src/internal/node_runtime/node_execution_dynamic_import.js +0 -74
  440. package/src/internal/node_runtime/node_execution_performance.js +0 -67
  441. package/src/internal/node_runtime/node_execution_systemjs.js +0 -125
  442. package/src/internal/node_runtime/node_system.js +0 -191
  443. package/src/internal/origin_directory_converter.js +0 -62
  444. package/src/internal/perf_node.js +0 -13
  445. package/src/internal/promise_race.js +0 -19
  446. package/src/internal/redirector/redirector.html +0 -40
  447. package/src/internal/require.js +0 -3
  448. package/src/internal/response_validation.js +0 -130
  449. package/src/internal/runtime/module-registration.js +0 -207
  450. package/src/internal/runtime/s.js +0 -864
  451. package/src/internal/runtime/s.js.md +0 -1
  452. package/src/internal/runtime/valueInstall.js +0 -14
  453. package/src/internal/runtime_support/jsenv_runtime_support.js +0 -15
  454. package/src/internal/runtime_support/runtime_support.js +0 -70
  455. package/src/internal/semantic_versioning/findHighestVersion.js +0 -12
  456. package/src/internal/semantic_versioning/findLowestVersion.js +0 -12
  457. package/src/internal/semantic_versioning/index.js +0 -5
  458. package/src/internal/semantic_versioning/valueToVersion.js +0 -44
  459. package/src/internal/semantic_versioning/versionCompare.js +0 -32
  460. package/src/internal/semantic_versioning/versionIsAbove.js +0 -5
  461. package/src/internal/semantic_versioning/versionIsBelow.js +0 -5
  462. package/src/internal/semantic_versioning/versionIsEqual.js +0 -3
  463. package/src/internal/sourceMappingURLUtils.js +0 -112
  464. package/src/internal/url_conversion.js +0 -313
  465. package/src/internal/url_utils.js +0 -33
  466. package/src/internal/url_utils.test.js +0 -39
  467. package/src/jsenvCoverageConfig.js +0 -7
  468. package/src/jsenvExplorableConfig.js +0 -9
  469. package/src/jsenvRuntimeSupportDuringDev.js +0 -12
  470. package/src/jsenvServiceWorkerFinalizer.js +0 -55
  471. package/src/jsonToJavaScriptModule.js +0 -12
  472. package/src/launchBrowser.js +0 -43
  473. package/src/launchNode.js +0 -227
  474. package/src/playwright_browser_versions.js +0 -5
  475. package/src/requireUsingChildProcess.js +0 -67
  476. package/src/textToJavaScriptModule.js +0 -14
@@ -1,1097 +0,0 @@
1
- import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
2
- import { createLogger, loggerToLevels } from "@jsenv/logger"
3
-
4
- import { setJavaScriptSourceMappingUrl } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
5
-
6
- import { racePromises } from "../promise_race.js"
7
- import { parseDataUrl } from "../dataUrl.utils.js"
8
- import {
9
- getRessourceAsBase64Url,
10
- memoize,
11
- getCallerLocation,
12
- formatFoundReference,
13
- // formatDependenciesCollectedMessage,
14
- checkContentType,
15
- } from "./ressource_builder_util.js"
16
- import { stringifyUrlSite } from "./url_trace.js"
17
-
18
- export const createRessourceBuilder = (
19
- { urlFetcher, urlLoader, parseRessource },
20
- {
21
- logLevel,
22
- format,
23
- compileServerOrigin,
24
- buildDirectoryUrl,
25
-
26
- asOriginalServerUrl,
27
- urlToHumanUrl,
28
-
29
- onAsset,
30
- onAssetSourceUpdated,
31
- onJsModule,
32
- resolveRessourceUrl,
33
- buildUrlGenerator,
34
- },
35
- ) => {
36
- const logger = createLogger({ logLevel })
37
-
38
- const createReferenceForEntryPoint = async ({
39
- entryContentType,
40
- entryUrl,
41
- entryBuffer,
42
- }) => {
43
- // The entry point is conceptually referenced by code passing "entryPoints"
44
- // to buildProject. So we analyse stack trace to put this function caller
45
- // as the reference to this ressource file
46
- // we store this info in reference.isProgrammatic
47
- const callerLocation = getCallerLocation()
48
- const entryReference = createReference({
49
- ressourceSpecifier: entryUrl,
50
- contentTypeExpected: entryContentType,
51
- referenceUrl: callerLocation.url,
52
- referenceLine: callerLocation.line,
53
- referenceColumn: callerLocation.column,
54
-
55
- contentType: entryContentType,
56
- bufferBeforeBuild: entryBuffer,
57
- isJsModule: entryContentType === "application/javascript",
58
-
59
- isEntryPoint: true,
60
- })
61
- entryReference.isProgrammatic = true
62
- if (entryReference.ressource.isJsModule) {
63
- // no need to call getDependenciesAvailablePromise and so on
64
- // rollup is handling js entries
65
- return
66
- }
67
-
68
- await entryReference.ressource.getDependenciesAvailablePromise()
69
-
70
- // on await que les assets, pour le js rollup s'en occupe
71
- await Promise.all(
72
- entryReference.ressource.dependencies.map(async (dependency) => {
73
- if (dependency.contentTypeExpected === "application/importmap+json") {
74
- // don't await for importmap right away, it must be handled as the very last asset
75
- // to be aware of build mappings.
76
- // getReadyPromise() for that importmap will be called during getAllAssetEntryEmittedPromise
77
- // (a simpler approach could keep importmap untouched and override it late
78
- // (but that means updating html hash and importmap hash)
79
- return
80
- }
81
- const { ressource } = dependency
82
- const readyPromise = ressource.getReadyPromise()
83
- if (ressource.isJsModule) {
84
- // await internally for rollup to be done with this ressource js module
85
- // but don't await explicitely or rollup wait for asset builder
86
- // which is waiting for rollup
87
- return
88
- }
89
- if (!ressource.firstStrongReference) {
90
- // await internally for rollup to be done to see if this ressource gets referenced
91
- // but don't await explicitly or rollup would wait
92
- // for asset builder which is waiting for rollup
93
- return
94
- }
95
- if (ressource.isPlaceholder) {
96
- return
97
- }
98
- await readyPromise
99
- }),
100
- )
101
- }
102
-
103
- const createReferenceFoundByRollup = (params) => {
104
- return createReference({
105
- fromRollup: true,
106
- ...params,
107
- })
108
- }
109
-
110
- const createReferenceFoundInJsModule = ({
111
- referenceLabel,
112
- jsUrl,
113
- jsLine,
114
- jsColumn,
115
- isImportAssertion,
116
- isJsModule,
117
-
118
- contentTypeExpected,
119
- ressourceSpecifier,
120
- contentType,
121
- bufferBeforeBuild,
122
- }) => {
123
- const reference = createReference({
124
- isImportAssertion,
125
- ressourceSpecifier,
126
- contentTypeExpected,
127
- referenceLabel,
128
- referenceUrl: jsUrl,
129
- referenceLine: jsLine,
130
- referenceColumn: jsColumn,
131
-
132
- contentType,
133
- bufferBeforeBuild,
134
- isJsModule,
135
- })
136
- return reference
137
- }
138
-
139
- const getAllEntryPointsEmittedPromise = async () => {
140
- const urlToWait = Object.keys(ressourceMap).filter(
141
- (url) => ressourceMap[url].isEntryPoint,
142
- )
143
- await Promise.all(
144
- urlToWait.map(async (url) => {
145
- const ressource = ressourceMap[url]
146
- await ressource.getReadyPromise()
147
- return ressource
148
- }),
149
- )
150
-
151
- // compute all asset fileName
152
- Object.keys(ressourceMap).forEach((key) => {
153
- const ressource = ressourceMap[key]
154
- if (
155
- ressource.isExternal ||
156
- ressource.isJsModule ||
157
- ressource.buildFileNameWithoutHash
158
- ) {
159
- return
160
- }
161
- if (ressource.isPlaceholder && !ressource.buildRelativeUrl) {
162
- return
163
- }
164
- if (!ressource.buildRelativeUrl) {
165
- if (ressource.isPlaceholder) {
166
- // placeholder not filled, that's ok
167
- return
168
- }
169
- if (ressource.references.every((ref) => ref.isRessourceHint)) {
170
- // ressource hint never used, the ressource can be ignored
171
- return
172
- }
173
- }
174
- ressource.buildFileNameWithoutHash = asFileNameWithoutHash(
175
- ressource.buildRelativeUrl,
176
- )
177
- })
178
- }
179
-
180
- const ressourceMap = {}
181
- const ressourceRedirectionMap = {}
182
- const createReference = ({
183
- isRessourceHint,
184
- isImportAssertion,
185
- ressourceSpecifier,
186
- referenceLabel,
187
- referenceUrl,
188
- referenceColumn,
189
- referenceLine,
190
- contentTypeExpected,
191
- crossorigin,
192
- integrity,
193
-
194
- contentType,
195
- bufferBeforeBuild,
196
- isEntryPoint,
197
- isJsModule,
198
- isSourcemap,
199
- isInline,
200
- isPlaceholder,
201
-
202
- urlVersioningDisabled,
203
-
204
- fromRollup,
205
- }) => {
206
- let ressourceImporter
207
- if (referenceUrl) {
208
- const existingRessourceForReference = findRessourceByUrl(referenceUrl)
209
- if (existingRessourceForReference) {
210
- ressourceImporter = existingRessourceForReference
211
- } else {
212
- const referenceOriginalUrl = asOriginalServerUrl(referenceUrl)
213
- if (referenceOriginalUrl) {
214
- ressourceImporter = findRessourceByUrl(referenceOriginalUrl)
215
- }
216
- }
217
- }
218
- if (!ressourceImporter) {
219
- // happens only for entry points?
220
- // in that case the importer is theoric
221
- // see "getCallerLocation()" in createReferenceForEntryPoint
222
- ressourceImporter = {
223
- url: referenceUrl,
224
- isEntryPoint: false,
225
- isJsModule: true,
226
- bufferAfterBuild: "",
227
- }
228
- }
229
-
230
- const shouldBeIgnoredWarning = referenceShouldBeIgnoredWarning({
231
- isJsModule,
232
- ressourceImporter,
233
- ressourceSpecifier,
234
- referenceUrl,
235
- urlToHumanUrl,
236
- })
237
- if (shouldBeIgnoredWarning) {
238
- logger.warn(shouldBeIgnoredWarning)
239
- return null
240
- }
241
-
242
- const ressourceUrlResolution = resolveRessourceUrl({
243
- ressourceSpecifier,
244
- isJsModule,
245
- isInline,
246
- isRessourceHint,
247
- ressourceImporter,
248
- })
249
-
250
- let ressourceUrl
251
- let isExternal = false
252
- let isWorker = false
253
- let isServiceWorker = false
254
- let isCrossOrigin = false
255
- if (typeof ressourceUrlResolution === "object") {
256
- ressourceUrl = ressourceUrlResolution.url
257
- if (ressourceUrlResolution.isCrossOrigin) {
258
- isCrossOrigin = true
259
- }
260
- if (ressourceUrlResolution.isExternal) {
261
- isExternal = true
262
- }
263
- if (ressourceUrlResolution.isWorker) {
264
- isWorker = true
265
- }
266
- if (ressourceUrlResolution.isServiceWorker) {
267
- isServiceWorker = true
268
- }
269
- if (ressourceUrlResolution.isJsModule) {
270
- isJsModule = true
271
- }
272
- } else {
273
- ressourceUrl = ressourceUrlResolution
274
- }
275
-
276
- if (ressourceUrl.startsWith("data:")) {
277
- isExternal = false
278
- isInline = true
279
- const { mediaType, base64Flag, data } = parseDataUrl(ressourceUrl)
280
- contentTypeExpected = mediaType
281
- contentType = mediaType
282
- bufferBeforeBuild = base64Flag
283
- ? Buffer.from(data, "base64")
284
- : decodeURI(data)
285
- }
286
-
287
- // any hash in the url would mess up with filenames
288
- ressourceUrl = removePotentialUrlHash(ressourceUrl)
289
-
290
- const existingRessource = findRessourceByUrl(ressourceUrl)
291
- let ressource
292
- if (existingRessource) {
293
- ressource = existingRessource
294
- // allow to update the bufferBeforeBuild on existingRessource
295
- // this happens when rollup loads a js file and communicates to this code
296
- // what was loaded
297
- if (fromRollup) {
298
- ressource.bufferBeforeBuild = bufferBeforeBuild
299
- ressource.contentType = contentType
300
- }
301
- } else {
302
- ressource = createRessource({
303
- contentType,
304
- ressourceUrl,
305
- ressourceImporter,
306
- bufferBeforeBuild,
307
-
308
- isEntryPoint,
309
- isJsModule,
310
- isSourcemap,
311
- isCrossOrigin,
312
- isExternal,
313
- isInline,
314
- isPlaceholder,
315
- isWorker,
316
- isServiceWorker,
317
-
318
- urlVersioningDisabled,
319
- })
320
- ressourceMap[ressourceUrl] = ressource
321
- }
322
-
323
- const reference = {
324
- fromRollup,
325
- isRessourceHint,
326
- isImportAssertion,
327
- referenceLabel,
328
- referenceUrl,
329
- referenceColumn,
330
- referenceLine,
331
- contentTypeExpected,
332
- crossorigin,
333
- integrity,
334
-
335
- isInline,
336
- inlinedCallback: () => {
337
- reference.isInline = true
338
- const allStrongReferenceAreInline = ressource.references.every(
339
- (reference) => reference.isRessourceHint || reference.isInline,
340
- )
341
- if (allStrongReferenceAreInline) {
342
- ressource.isInline = true
343
- ressource.inlinedCallbacks.forEach((callback) => callback())
344
- }
345
- },
346
- }
347
-
348
- reference.ressource = ressource
349
- if (fromRollup) {
350
- if (ressourceImporter.isEntryPoint) {
351
- // When HTML references JS, ressource builder has emitted the js chunk.
352
- // so it already knows it exists and is part of references
353
- // -> no need to push into reference (would incorrectly consider html references js twice)
354
- // -> no need to log the js ressource (already logged during the HTML parsing)
355
- return reference
356
- }
357
- if (ressource.isEntryPoint) {
358
- // When rollup "loads" a js entry point, ressource builder is already aware of it
359
- // because of "createReferenceForEntryPoint"
360
- return reference
361
- }
362
- }
363
-
364
- ressource.references.push(reference)
365
- const effects = ressource.applyReferenceEffects(reference, { isJsModule })
366
- if (loggerToLevels(logger).debug) {
367
- logger.debug(
368
- formatFoundReference({
369
- reference,
370
- referenceEffects: effects,
371
- showReferenceSourceLocation,
372
- urlToHumanUrl,
373
- }),
374
- )
375
- }
376
- return reference
377
- }
378
-
379
- const ressourceTransformMap = {}
380
-
381
- const createRessource = ({
382
- contentType,
383
- ressourceUrl,
384
- ressourceImporter,
385
- bufferBeforeBuild,
386
-
387
- isEntryPoint = false,
388
- isJsModule = false,
389
- isSourcemap = false,
390
- isCrossOrigin = false,
391
- isExternal = false,
392
- isInline = false,
393
- isPlaceholder = false,
394
- isWorker = false,
395
- isServiceWorker = false,
396
-
397
- urlVersioningDisabled,
398
- }) => {
399
- const ressource = {
400
- contentType,
401
- url: ressourceUrl,
402
- importer: ressourceImporter,
403
- bufferBeforeBuild,
404
- bufferAfterBuild: undefined,
405
- firstStrongReference: null,
406
- references: [],
407
-
408
- isEntryPoint,
409
- isJsModule,
410
- isSourcemap,
411
- isInline,
412
- isCrossOrigin,
413
- isExternal,
414
- isPlaceholder,
415
- isWorker,
416
- isServiceWorker,
417
-
418
- urlVersioningDisabled,
419
-
420
- relativeUrl: ressourceUrl.startsWith(compileServerOrigin)
421
- ? urlToRelativeUrl(ressourceUrl, compileServerOrigin)
422
- : urlToRelativeUrl(ressourceUrl, buildDirectoryUrl),
423
- }
424
-
425
- const { buildRelativeUrlPattern, buildRelativeUrlWithoutHash } =
426
- buildUrlGenerator.prepareBuildUrlForRessource(ressource)
427
- ressource.buildRelativeUrlWithoutHash = buildRelativeUrlWithoutHash
428
- ressource.buildRelativeUrlPattern = buildRelativeUrlPattern
429
-
430
- ressource.usedPromise = new Promise((resolve) => {
431
- ressource.usedCallback = resolve
432
- })
433
- ressource.inlinedCallbacks = []
434
- ressource.buildEndCalledCallbacks = []
435
- ressource.buildEndCalledPromise = new Promise((resolve) => {
436
- ressource.buildEndCalledCallbacks.push(resolve)
437
- })
438
- ressource.rollupBuildDoneCallbacks = []
439
- ressource.rollupBuildDonePromise = new Promise((resolve) => {
440
- ressource.rollupBuildDoneCallbacks.push(resolve)
441
- })
442
-
443
- const getBufferAvailablePromise = memoize(async () => {
444
- if (ressource.isJsModule) {
445
- await ressource.rollupBuildDonePromise
446
- return
447
- }
448
- // sourcemap placeholder buffer is ready once buildEnd is called on it
449
- if (ressource.isPlaceholder) {
450
- await ressource.buildEndCalledPromise
451
- return
452
- }
453
- if (!ressource.firstStrongReference) {
454
- // for preload/prefetch links, we don't want to start the prefetching right away.
455
- // Instead we wait for something else to reference the same ressource
456
- // This is by choice so that:
457
- // 1. The warning about "preload but never used" is prio fetch errors like "preload not found"
458
- // 2. We don't start fetching a ressource found in HTML while rollup
459
- // could do the same later. It means we should synchronize rollup
460
- // and this asset builder fetching to avoid fetching twice.
461
- // This scenario would be reproduced for every js module preloaded
462
- const { usedPromise, rollupBuildDonePromise } = ressource
463
- const winner = await racePromises([usedPromise, rollupBuildDonePromise])
464
- if (winner.promise === rollupBuildDonePromise) {
465
- return
466
- }
467
- }
468
- const ressourceUrl = ressource.url
469
- const response = await urlFetcher.fetchUrl(ressourceUrl, {
470
- contentTypeExpected: ressource.firstStrongReference.contentTypeExpected,
471
- crossorigin: ressource.firstStrongReference.crossorigin,
472
- integrity: ressource.firstStrongReference.integrity,
473
- urlTrace: () => {
474
- return createRessourceTrace({
475
- ressource,
476
- createUrlSiteFromReference,
477
- findRessourceByUrl,
478
- })
479
- },
480
- })
481
- if (response.url !== ressourceUrl) {
482
- const urlBeforeRedirection = ressourceUrl
483
- const urlAfterRedirection = response.url
484
- ressourceRedirectionMap[urlBeforeRedirection] = urlAfterRedirection
485
- ressource.url = urlAfterRedirection
486
- }
487
- const responseContentTypeHeader = response.headers["content-type"]
488
- ressource.contentType = responseContentTypeHeader
489
- const responseBodyAsArrayBuffer = await response.arrayBuffer()
490
- ressource.bufferBeforeBuild = Buffer.from(responseBodyAsArrayBuffer)
491
- // TODO here: integrity check
492
- })
493
-
494
- const setBufferBeforeBuild = (bufferBeforeBuild) => {
495
- ressource.bufferBeforeBuild = bufferBeforeBuild
496
- getBufferAvailablePromise.forceMemoization(Promise.resolve())
497
- }
498
-
499
- const getDependenciesAvailablePromise = memoize(async () => {
500
- await getBufferAvailablePromise()
501
-
502
- if (ressource.isJsModule) {
503
- ressource.dependencies = []
504
- return
505
- }
506
-
507
- const dependencies = []
508
-
509
- let parsingDone = false
510
- const notifyReferenceFound = ({
511
- isRessourceHint,
512
- contentTypeExpected,
513
- crossorigin,
514
- integrity,
515
- ressourceSpecifier,
516
- referenceLabel,
517
- referenceLine,
518
- referenceColumn,
519
-
520
- contentType,
521
- bufferBeforeBuild,
522
- isJsModule = false,
523
- isInline = false,
524
- isSourcemap = false,
525
- isPlaceholder = false,
526
- urlVersioningDisabled,
527
- }) => {
528
- if (parsingDone) {
529
- throw new Error(
530
- `notifyReferenceFound cannot be called once ${ressource.url} parsing is done.`,
531
- )
532
- }
533
-
534
- const dependencyReference = createReference({
535
- ressourceSpecifier,
536
- referenceLabel,
537
- referenceUrl: ressource.url,
538
- referenceLine,
539
- referenceColumn,
540
- isRessourceHint,
541
- contentTypeExpected,
542
- crossorigin,
543
- integrity,
544
-
545
- contentType,
546
- bufferBeforeBuild,
547
- isJsModule,
548
- isInline,
549
- isSourcemap,
550
- isPlaceholder,
551
-
552
- urlVersioningDisabled,
553
- })
554
-
555
- if (dependencyReference) {
556
- dependencies.push(dependencyReference)
557
- }
558
- return dependencyReference
559
- }
560
-
561
- if (!ressource.isEntryPoint) {
562
- logger.debug(`parse ${urlToHumanUrl(ressource.url)}`)
563
- }
564
-
565
- const parseReturnValue = await parseRessource(ressource, {
566
- format,
567
- notifyReferenceFound,
568
- })
569
- parsingDone = true
570
-
571
- if (dependencies.length > 0 && typeof parseReturnValue !== "function") {
572
- throw new Error(
573
- `parse notified some dependencies, it must return a function but received ${parseReturnValue}`,
574
- )
575
- }
576
- if (typeof parseReturnValue === "function") {
577
- ressourceTransformMap[ressource.url] = parseReturnValue
578
- }
579
- ressource.dependencies = dependencies
580
- // if (dependencies.length > 0) {
581
- // logger.debug(formatDependenciesCollectedMessage({ ressource, shortenUrl }))
582
- // }
583
- })
584
-
585
- const getReadyPromise = memoize(async () => {
586
- if (ressource.isExternal) {
587
- // external urls are immediatly available and not modified
588
- return
589
- }
590
-
591
- // la transformation d'un asset c'est avant tout la transformation de ses dépendances
592
- await getDependenciesAvailablePromise()
593
- const dependencies = ressource.dependencies
594
- await Promise.all(
595
- dependencies.map(async (dependencyReference) => {
596
- const dependencyRessource = dependencyReference.ressource
597
- if (dependencyRessource.isPlaceholder) {
598
- return
599
- }
600
- // don't keep waiting for ever in case ressource hint is never used
601
- if (dependencyReference.isRessourceHint) {
602
- return
603
- }
604
- await dependencyRessource.getReadyPromise()
605
- }),
606
- )
607
-
608
- const transform = ressourceTransformMap[ressource.url]
609
- if (typeof transform !== "function") {
610
- if (ressource.isPlaceholder) {
611
- return
612
- }
613
- // sourcemap content depends on their source file
614
- // sourcemap.buildEnd() will be called by the source file
615
- if (ressource.isSourcemap) {
616
- return
617
- }
618
- ressource.buildEnd(
619
- ressource.bufferAfterBuild || ressource.bufferBeforeBuild,
620
- ressource.buildRelativeUrl,
621
- )
622
- return
623
- }
624
-
625
- // assetDependenciesMapping contains all dependencies for an asset
626
- // each key is the absolute url to the dependency file
627
- // each value is an url relative to the asset importing this dependency
628
- // it looks like this:
629
- // {
630
- // "file:///project/coin.png": "./coin-45eiopri.png"
631
- // }
632
- // we don't yet know the exact importerBuildRelativeUrl but we can generate a fake one
633
- // to ensure we resolve dependency against where the importer file will be
634
- const importer = ressource
635
- await transform({
636
- buildDirectoryUrl,
637
- getUrlRelativeToImporter: (referencedRessource) => {
638
- const referenceBuildRelativeUrl = importer.isJsModule
639
- ? // js can reference an url without versionning
640
- // and actually fetch the versioned url thanks to importmap
641
- referencedRessource.buildRelativeUrlWithoutHash
642
- : // other ressource must use the exact url
643
- referencedRessource.buildRelativeUrl
644
- const referenceBuildUrl = resolveUrl(
645
- referenceBuildRelativeUrl,
646
- "file:///",
647
- )
648
- const importerBuildUrl = resolveUrl(
649
- importer.buildRelativeUrlWithoutHash,
650
- "file:///",
651
- )
652
- return urlToRelativeUrl(referenceBuildUrl, importerBuildUrl)
653
- },
654
- getOriginalRessource: (ressource) => {
655
- const originalServerUrl = asOriginalServerUrl(ressource.url)
656
- return ressourceMap[originalServerUrl]
657
- },
658
- })
659
- if (typeof ressource.bufferAfterBuild === "undefined") {
660
- throw new Error(
661
- `transform must call ressource.buildEnd() for ${ressource.url}`,
662
- )
663
- }
664
- })
665
-
666
- // was used to remove sourcemap files that are renamed after they are emitted
667
- // could be useful one day in case an asset is finally discarded
668
- const remove = () => {
669
- ressource.shouldBeIgnored = true
670
- }
671
-
672
- const buildEnd = (bufferAfterBuild, buildRelativeUrl) => {
673
- if (bufferAfterBuild !== undefined) {
674
- ressource.bufferAfterBuild = bufferAfterBuild
675
- if (buildRelativeUrl === undefined) {
676
- ressource.buildRelativeUrl =
677
- buildUrlGenerator.computeBuildRelativeUrl(ressource)
678
- }
679
- }
680
-
681
- if (buildRelativeUrl !== undefined) {
682
- ressource.buildRelativeUrl = buildRelativeUrl
683
- }
684
-
685
- if (
686
- // ressource.bufferAfterBuild can be undefined when ressource is only preloaded
687
- // and never used
688
- ressource.bufferAfterBuild &&
689
- !ressource.isInline &&
690
- !ressource.isJsModule
691
- ) {
692
- onAssetSourceUpdated({ ressource })
693
- }
694
- }
695
-
696
- const applyReferenceEffects = (reference, infoFromReference) => {
697
- const effects = []
698
- if (reference.fromRollup && ressource.isJsModule && ressource.isInline) {
699
- return effects
700
- }
701
- if (ressource.isEntryPoint) {
702
- if (ressource.contentType === "text/html") {
703
- effects.push(`parse html to find references`)
704
- }
705
- }
706
- if (reference.isRessourceHint) {
707
- // do not try to load or fetch this file
708
- // we'll wait for something to reference it
709
- // if nothing references it a warning will be logged
710
- return effects
711
- }
712
- ressource.getBufferAvailablePromise().then(
713
- () => {
714
- if (ressource.firstStrongReference) {
715
- checkContentType(reference, { logger, showReferenceSourceLocation })
716
- }
717
- },
718
- () => {},
719
- )
720
- if (ressource.firstStrongReference) {
721
- // this ressource was already strongly referenced by something
722
- // don't try to load it twice
723
- return effects
724
- }
725
- ressource.firstStrongReference = reference
726
- // the first strong reference is allowed to transform a reference where we did not know if it was
727
- // a js module to a js module
728
- // This happen for preload link following by a script type module
729
- // <link rel="preload" href="file.js" />
730
- // <script type="module" src="file.js"></script>
731
- if (!ressource.isJsModule && infoFromReference.isJsModule) {
732
- effects.push(`mark ${urlToHumanUrl(ressource.url)} as js module`)
733
- ressource.isJsModule = infoFromReference.isJsModule
734
- }
735
- ressource.usedCallback()
736
- if (ressource.isExternal) {
737
- // nothing to do
738
- return effects
739
- }
740
- if (ressource.isJsModule) {
741
- const jsModuleUrl = ressource.url
742
- const rollupChunk = onJsModule({
743
- ressource,
744
- jsModuleUrl,
745
- jsModuleIsInline: ressource.isInline,
746
- jsModuleSource: String(bufferBeforeBuild),
747
- line: reference.referenceLine,
748
- column: reference.referenceColumn,
749
- })
750
- if (rollupChunk) {
751
- ressource.rollupReferenceId = rollupChunk.rollupReferenceId
752
- effects.push(
753
- `emit rollup chunk "${rollupChunk.fileName}" (${rollupChunk.rollupReferenceId})`,
754
- )
755
- }
756
- return effects
757
- }
758
- if (ressource.isInline) {
759
- // nothing to do
760
- return effects
761
- }
762
- const rollupAsset = onAsset({
763
- ressource,
764
- })
765
- ressource.rollupReferenceId = rollupAsset.rollupReferenceId
766
- effects.push(
767
- `emit rollup asset "${rollupAsset.fileName}" (${rollupAsset.rollupReferenceId})`,
768
- )
769
- return effects
770
- }
771
-
772
- if (bufferBeforeBuild !== undefined) {
773
- setBufferBeforeBuild(bufferBeforeBuild)
774
- }
775
- Object.assign(ressource, {
776
- applyReferenceEffects,
777
- getBufferAvailablePromise,
778
- getDependenciesAvailablePromise,
779
- getReadyPromise,
780
- remove,
781
- setBufferBeforeBuild,
782
- buildEnd,
783
- })
784
- return ressource
785
- }
786
-
787
- const rollupBuildEnd = ({
788
- rollupResult,
789
- useImportMapToMaximizeCacheReuse,
790
- }) => {
791
- const jsRessources = {}
792
- Object.keys(ressourceMap).forEach((ressourceUrl) => {
793
- const ressource = ressourceMap[ressourceUrl]
794
- const rollupFileName = Object.keys(rollupResult).find((key) => {
795
- const rollupFileInfo = rollupResult[key]
796
- return (
797
- rollupFileInfo.url === ressourceUrl ||
798
- // asset
799
- ressource.buildFileNameWithoutHash === key ||
800
- ressource.relativeUrl === key
801
- )
802
- })
803
- if (rollupFileName) {
804
- const rollupFileInfo = rollupResult[rollupFileName]
805
- if (rollupFileInfo.type === "asset") {
806
- ressource.buildFileNameWithoutHash = rollupFileName
807
- return
808
- }
809
- if (rollupFileInfo.type === "chunk") {
810
- applyBuildEndEffects(ressource, {
811
- rollupFileInfo,
812
- rollupResult,
813
- useImportMapToMaximizeCacheReuse,
814
- })
815
- const { rollupBuildDoneCallbacks } = ressource
816
- rollupBuildDoneCallbacks.forEach((rollupBuildDoneCallback) => {
817
- rollupBuildDoneCallback()
818
- })
819
- if (rollupFileInfo.type === "chunk") {
820
- jsRessources[ressourceUrl] = ressource
821
- }
822
- return
823
- }
824
- }
825
- })
826
- return { jsRessources }
827
- }
828
-
829
- const applyBuildEndEffects = (
830
- ressource,
831
- { rollupFileInfo, rollupResult, useImportMapToMaximizeCacheReuse },
832
- ) => {
833
- const fileName = rollupFileInfo.fileName
834
- let code = rollupFileInfo.code
835
- ressource.contentType = "application/javascript"
836
- if (useImportMapToMaximizeCacheReuse) {
837
- ressource.buildFileNameWithoutHash = fileName
838
- ressource.buildEnd(code)
839
- } else {
840
- ressource.buildFileNameWithoutHash = asFileNameWithoutHash(fileName)
841
- ressource.buildEnd(code, fileName)
842
- }
843
- const map = rollupFileInfo.map
844
- if (map) {
845
- const sourcemapBuildRelativeUrl = `${ressource.buildRelativeUrl}.map`
846
- const sourcemapRollupFileInfo = rollupResult[sourcemapBuildRelativeUrl]
847
- if (!sourcemapRollupFileInfo) {
848
- const ressourceBuildUrl = resolveUrl(
849
- ressource.buildRelativeUrl,
850
- buildDirectoryUrl,
851
- )
852
- const sourcemapBuildUrl = resolveUrl(
853
- sourcemapBuildRelativeUrl,
854
- buildDirectoryUrl,
855
- )
856
- const sourcemapAsString = JSON.stringify(rollupFileInfo.map, null, " ")
857
- const sourcemapBuildUrlRelativeToFileBuildUrl = urlToRelativeUrl(
858
- sourcemapBuildUrl,
859
- ressourceBuildUrl,
860
- )
861
- const codeWithSourcemapComment = setJavaScriptSourceMappingUrl(
862
- rollupFileInfo.code,
863
- sourcemapBuildUrlRelativeToFileBuildUrl,
864
- )
865
- ressource.bufferAfterBuild = codeWithSourcemapComment
866
- rollupFileInfo.code = codeWithSourcemapComment
867
- const sourcemapReference = createReference({
868
- referenceLabel: "js sourcemapping comment",
869
- contentType: "application/octet-stream",
870
- ressourceSpecifier: sourcemapBuildUrlRelativeToFileBuildUrl,
871
- referenceUrl: ressourceBuildUrl,
872
- referenceLine: codeWithSourcemapComment.split(/\r?\n/).length,
873
- // ${"//#"} is to avoid a parser thinking there is a sourceMappingUrl for this file
874
- referenceColumn: `${"//#"} sourceMappingURL=`.length + 1,
875
- isSourcemap: true,
876
- isPlaceholder: true,
877
- })
878
- sourcemapReference.ressource.buildEnd(
879
- sourcemapAsString,
880
- sourcemapBuildUrlRelativeToFileBuildUrl,
881
- )
882
- }
883
- }
884
- }
885
-
886
- const findRessourceByUrl = (url) => {
887
- if (url in ressourceMap) {
888
- return ressourceMap[url]
889
- }
890
- if (url in ressourceRedirectionMap) {
891
- return findRessourceByUrl(ressourceRedirectionMap[url])
892
- }
893
- return null
894
- }
895
-
896
- const findRessource = (predicate) => {
897
- let ressourceFound = null
898
- Object.keys(ressourceMap).find((url) => {
899
- const ressourceCandidate = ressourceMap[url]
900
- if (predicate(ressourceCandidate)) {
901
- ressourceFound = ressourceCandidate
902
- return true
903
- }
904
- return false
905
- })
906
- return ressourceFound
907
- }
908
-
909
- const createUrlSiteFromReference = (reference) => {
910
- const { referenceUrl, referenceLine, referenceColumn } = reference
911
- const referenceRessource = findRessourceByUrl(referenceUrl)
912
- const referenceSource = referenceRessource
913
- ? referenceRessource.bufferBeforeBuild
914
- : urlLoader.getUrlResponseTextFromMemory(referenceUrl)
915
- const referenceSourceAsString = referenceSource
916
- ? String(referenceSource)
917
- : ""
918
-
919
- const urlSite = {
920
- type:
921
- referenceRessource && referenceRessource.isJsModule
922
- ? "import"
923
- : "reference",
924
- url: urlToHumanUrl(referenceUrl),
925
- line: referenceLine,
926
- column: referenceColumn,
927
- source: referenceSourceAsString,
928
- }
929
-
930
- if (!referenceRessource) {
931
- return urlSite
932
- }
933
- if (!referenceRessource.isInline) {
934
- return urlSite
935
- }
936
- const { firstStrongReference } = referenceRessource
937
- if (!firstStrongReference) {
938
- return urlSite
939
- }
940
- const htmlUrlSite = createUrlSiteFromReference(firstStrongReference)
941
- // when the html node is injected there is no line in the source file to target
942
- if (htmlUrlSite.line === undefined) {
943
- return urlSite
944
- }
945
- const importerRessource = findRessourceByUrl(
946
- firstStrongReference.referenceUrl,
947
- )
948
- if (!importerRessource || importerRessource.contentType !== "text/html") {
949
- return urlSite
950
- }
951
- return {
952
- ...htmlUrlSite,
953
- line:
954
- typeof urlSite.line === "number"
955
- ? htmlUrlSite.line + urlSite.line
956
- : htmlUrlSite.line,
957
- column:
958
- typeof urlSite.column === "number"
959
- ? htmlUrlSite.column + urlSite.column
960
- : htmlUrlSite.column,
961
- }
962
- }
963
-
964
- const showReferenceSourceLocation = (reference) => {
965
- return stringifyUrlSite(createUrlSiteFromReference(reference))
966
- }
967
-
968
- return {
969
- createReferenceForEntryPoint,
970
- createReferenceFoundByRollup,
971
- createReferenceFoundInJsModule,
972
-
973
- rollupBuildEnd,
974
- getAllEntryPointsEmittedPromise,
975
- findRessource,
976
-
977
- inspect: () => {
978
- return {
979
- ressourceMap,
980
- ressourceRedirectionMap,
981
- }
982
- },
983
- }
984
- }
985
-
986
- const asFileNameWithoutHash = (fileName) => {
987
- return fileName.replace(/_[a-z0-9]{8,}(\..*?)?$/, (_, afterHash = "") => {
988
- return afterHash
989
- })
990
- }
991
-
992
- // const preredirectUrlFromRessource = (ressource, ressourceRedirectionMap) => {
993
- // const ressourceUrlPreRedirect = Object.keys(ressourceRedirectionMap).find(
994
- // (urlPreRedirect) =>
995
- // ressourceRedirectionMap[urlPreRedirect] === ressource.url,
996
- // )
997
- // return ressourceUrlPreRedirect
998
- // }
999
-
1000
- export const referenceToCodeForRollup = (reference) => {
1001
- const ressource = reference.ressource
1002
- if (ressource.isInline) {
1003
- return getRessourceAsBase64Url(ressource)
1004
- }
1005
-
1006
- return `import.meta.ROLLUP_FILE_URL_${ressource.rollupReferenceId}`
1007
- }
1008
-
1009
- // const targetFileNameFromBuildManifest = (buildManifest, buildRelativeUrl) => {
1010
- // const key = Object.keys(buildManifest).find((keyCandidate) => {
1011
- // return buildManifest[keyCandidate] === buildRelativeUrl
1012
- // })
1013
- // return buildManifest[key]
1014
- // }
1015
-
1016
- const createRessourceTrace = ({
1017
- ressource,
1018
- createUrlSiteFromReference,
1019
- findRessourceByUrl,
1020
- }) => {
1021
- // we could pass a way to build the import trace
1022
- // it can be deduced by starting with the firstStrongReference
1023
- // and trying to get a ressource for that reference
1024
- // to get an other firstStrongReference
1025
- // everytime we could build the sourcelocation
1026
- // but for importer after the first once just line and column are enough
1027
- // the source code would be too much
1028
-
1029
- const { firstStrongReference } = ressource
1030
- const trace = [createUrlSiteFromReference(firstStrongReference)]
1031
-
1032
- const next = (reference) => {
1033
- const referenceRessource = findRessourceByUrl(reference.referenceUrl)
1034
- if (!referenceRessource) {
1035
- return
1036
- }
1037
- const { firstStrongReference } = referenceRessource
1038
- if (!firstStrongReference) {
1039
- return
1040
- }
1041
- // ignore the programmatic reference
1042
- if (firstStrongReference.isProgrammatic) {
1043
- return
1044
- }
1045
- trace.push(createUrlSiteFromReference(firstStrongReference))
1046
- next(firstStrongReference)
1047
- }
1048
- next(firstStrongReference)
1049
-
1050
- return trace
1051
- }
1052
-
1053
- const removePotentialUrlHash = (url) => {
1054
- const urlObject = new URL(url)
1055
- urlObject.hash = ""
1056
- return String(urlObject)
1057
- }
1058
-
1059
- /*
1060
- * We cannot reference js from asset (svg for example)
1061
- * that is because rollup awaits for html to be ready which waits
1062
- * fetch and parse its dependencies (let's say an svg)
1063
- * which waits for js to be fetched and parsed
1064
- * but the fetching + parsing of js happens in rollup
1065
- * so rollup would end up waiting forever
1066
- *
1067
- * see also:
1068
- * - https://rollupjs.org/guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string
1069
- * - https://github.com/rollup/rollup/issues/2872
1070
- */
1071
- const referenceShouldBeIgnoredWarning = ({
1072
- isJsModule,
1073
- ressourceImporter,
1074
- ressourceSpecifier,
1075
- referenceUrl,
1076
- urlToHumanUrl,
1077
- }) => {
1078
- if (!isJsModule) {
1079
- return false
1080
- }
1081
-
1082
- // js can reference js
1083
- if (ressourceImporter.isJsModule) {
1084
- return false
1085
- }
1086
-
1087
- // entry point can reference js (html)
1088
- if (ressourceImporter.isEntryPoint) {
1089
- return false
1090
- }
1091
-
1092
- return `
1093
- WARNING: Ignoring reference to ${urlToHumanUrl(
1094
- ressourceSpecifier,
1095
- )} found inside ${urlToHumanUrl(referenceUrl)}.
1096
- `
1097
- }