@jsenv/core 26.0.1 → 27.0.0-alpha.2
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.
- package/main.js +17 -24
- package/package.json +35 -71
- package/readme.md +30 -37
- package/src/build/build.js +737 -0
- package/src/build/build_urls_generator.js +64 -0
- package/src/build/inject_version_mappings.js +62 -0
- package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +225 -0
- package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +30 -0
- package/src/build/plugins/minify_js/jsenv_plugin_minify_js.js +47 -0
- package/src/dev/plugins/autoreload/babel_plugin_metadata_import_meta_hot.js +98 -0
- package/src/dev/plugins/autoreload/client/autoreload_preference.js +11 -0
- package/src/dev/plugins/autoreload/client/event_source_client.js +186 -0
- package/src/{internal/dev_server/event_source_client → dev/plugins/autoreload/client}/event_source_connection.js +21 -25
- package/src/dev/plugins/autoreload/client/import_meta_hot.js +80 -0
- package/src/dev/plugins/autoreload/client/reload.js +101 -0
- package/src/dev/plugins/autoreload/client/url_helpers.js +20 -0
- package/src/dev/plugins/autoreload/html_hot_dependencies.js +156 -0
- package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +374 -0
- package/src/dev/plugins/autoreload/sse_service.js +149 -0
- package/src/dev/plugins/explorer/client/explorer.html +607 -0
- package/src/{internal → dev/plugins/explorer/client}/jsenv.png +0 -0
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +74 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/animation/toolbar_animation.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/eventsource/eventsource.css +2 -2
- package/src/dev/plugins/toolbar/client/eventsource/toolbar_eventsource.js +57 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/execution/execution.css +0 -0
- package/src/dev/plugins/toolbar/client/execution/toolbar_execution.js +88 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/focus.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/toolbar_focus.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/jsenv_logo.svg +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/notification/toolbar_notification.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/overflow_menu.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/toolbar_responsive.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/settings.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/toolbar_settings.js +1 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/jsenv_theme.css +1 -15
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/light_theme.css +0 -17
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/toolbar_theme.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar.html +40 -199
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_injector.js +8 -28
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.css +0 -24
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.js +10 -56
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.css +1 -1
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/animation.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/dom.js +0 -0
- package/src/{internal/browser_utils → dev/plugins/toolbar/client/util}/fetch_using_xhr.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/fetching.js +2 -4
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/iframe_to_parent_href.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/jsenv_logger.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/preferences.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/responsive.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/util.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/variant/variant.js +0 -0
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +62 -0
- package/src/dev/start_dev_server.js +105 -0
- package/src/execute/execute.js +132 -0
- package/src/execute/run.js +208 -0
- package/src/execute/runtimes/browsers/chromium.js +8 -0
- package/src/execute/runtimes/browsers/firefox.js +7 -0
- package/src/execute/runtimes/browsers/from_playwright.js +464 -0
- package/src/{browser_runtimes.js → execute/runtimes/browsers/webkit.js} +4 -18
- package/src/{internal/node_launcher/child_process_options.js → execute/runtimes/node/child_exec_options.js} +25 -36
- package/src/{internal/node_launcher/node_controllable_file.mjs → execute/runtimes/node/controllable_file.mjs} +1 -18
- package/src/{internal/node_launcher/node_controllable_process.js → execute/runtimes/node/controlled_process.js} +128 -150
- package/src/execute/runtimes/node/exec_options.js +44 -0
- package/src/{internal/node_launcher → execute/runtimes/node}/kill_process_tree.js +3 -1
- package/src/execute/runtimes/node/node_process.js +92 -0
- package/src/execute/runtimes/node/node_worker_thread.js +28 -0
- package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +29 -0
- package/src/{internal/compile_server/js → omega/core_plugins/babel/babel_helper}/babel_plugin_babel_helpers_as_jsenv_imports.js +15 -19
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/.eslintrc.cjs +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AsyncGenerator/AsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AwaitValue/AwaitValue.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayLikeToArray/arrayLikeToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithHoles/arrayWithHoles.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithoutHoles/arrayWithoutHoles.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/assertThisInitialized/assertThisInitialized.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncIterator/asyncIterator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncToGenerator/asyncToGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCallCheck/classCallCheck.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classNameTDZError/classNameTDZError.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldGet/classPrivateFieldGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldSet/classPrivateFieldSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodGet/classPrivateMethodGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodSet/classPrivateMethodSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/construct/construct.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createClass/createClass.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createRawReactElement/createRawReactElement.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createSuper/createSuper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/decorate/decorate.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defaults/defaults.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineEnumerableProperties/defineEnumerableProperties.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineProperty/defineProperty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/extends/extends.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/get/get.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/getPrototypeOf/getPrototypeOf.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inherits/inherits.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inheritsLoose/inheritsLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerDefineProperty/initializerDefineProperty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerWarningHelper/initializerWarningHelper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/instanceof/instanceof.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireDefault/interopRequireDefault.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireWildcard/interopRequireWildcard.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeFunction/isNativeFunction.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArray/iterableToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimit/iterableToArrayLimit.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/jsx/jsx.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/maybeArrayLike/maybeArrayLike.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/newArrowCheck/newArrowCheck.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableRest/nonIterableRest.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableSpread/nonIterableSpread.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread/objectSpread.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread2/objectSpread2.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutProperties/objectWithoutProperties.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/possibleConstructorReturn/possibleConstructorReturn.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readOnlyError/readOnlyError.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readme.md +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/set/set.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/setPrototypeOf/setPrototypeOf.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArray/slicedToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArrayLoose/slicedToArrayLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/superPropBase/superPropBase.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/tdz/tdz.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalRef/temporalRef.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalUndefined/temporalUndefined.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toArray/toArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toConsumableArray/toConsumableArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPrimitive/toPrimitive.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPropertyKey/toPropertyKey.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/typeof/typeof.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapNativeSuper/wrapNativeSuper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapRegExp/wrapRegExp.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/writeOnlyError/writeOnlyError.js +0 -0
- package/src/omega/core_plugins/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +35 -0
- package/{helpers/global-this/global-this.js → src/omega/core_plugins/babel/global_this/client/global_this.js} +0 -0
- package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +187 -0
- package/src/{internal/features → omega/core_plugins/babel/helpers}/babel_plugins_compatibility.js +1 -24
- package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +97 -0
- package/src/omega/core_plugins/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +117 -0
- package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +24 -0
- package/{helpers/new_stylesheet → src/omega/core_plugins/babel/new_stylesheet/client}/new_stylesheet.js +0 -0
- package/src/omega/core_plugins/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +34 -0
- package/{helpers/regenerator-runtime/regenerator-runtime.js → src/omega/core_plugins/babel/regenerator_runtime/client/regenerator_runtime.js} +0 -0
- package/src/omega/core_plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +169 -0
- package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +67 -0
- package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +58 -0
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_document.js +10 -16
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_notification.js +0 -0
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +168 -0
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +77 -0
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/perf_browser.js +0 -0
- package/src/{internal/runtime_client → omega/core_plugins/html_supervisor/client}/uneval_exception.js +0 -0
- package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +233 -0
- package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +98 -0
- package/src/{internal/building/import_assertions → omega/core_plugins/import_assertions/helpers}/json_module.js +3 -2
- package/src/omega/core_plugins/import_assertions/helpers/text_module.js +6 -0
- package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +211 -0
- package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +80 -0
- package/src/omega/core_plugins/importmap/jsenv_plugin_importmap.js +212 -0
- package/src/omega/core_plugins/inline/client/inline_content.js +6 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_data_urls.js +70 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +13 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_inline_query_param.js +42 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +142 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +210 -0
- package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +12 -0
- package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +77 -0
- package/src/omega/core_plugins/url_resolution/jsenv_plugin_url_resolution.js +28 -0
- package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +50 -0
- package/src/omega/core_plugins.js +39 -0
- package/src/omega/errors.js +168 -0
- package/src/omega/file_url_converter.js +63 -0
- package/src/omega/kitchen.js +777 -0
- package/src/omega/omega_server.js +129 -0
- package/src/omega/plugin_controller.js +240 -0
- package/src/omega/runtime_support/default_runtime_support.js +13 -0
- package/src/omega/runtime_support/features_compatibility.js +91 -0
- package/src/omega/runtime_support/runtime_support.js +20 -0
- package/src/omega/server/file_service.js +155 -0
- package/src/omega/server/user_agent.js +22 -0
- package/src/omega/url_graph/url_graph_load.js +68 -0
- package/src/omega/url_graph/url_graph_report.js +151 -0
- package/src/omega/url_graph/url_graph_sort.js +29 -0
- package/src/omega/url_graph/url_info_transformations.js +161 -0
- package/src/omega/url_graph.js +132 -0
- package/src/omega/url_mentions/css_url_mentions.js +63 -0
- package/src/omega/url_mentions/html_url_mentions.js +185 -0
- package/src/omega/url_mentions/js_module_url_mentions.js +91 -0
- package/src/omega/url_mentions/parse_url_mentions.js +37 -0
- package/src/omega/url_mentions/worker_classic_url_mentions.js +37 -0
- package/src/{internal/executing → test}/execute_plan.js +154 -211
- package/src/{execute_test_plan.js → test/execute_test_plan.js} +26 -81
- package/src/{internal/executing → test}/execution_colors.js +0 -0
- package/src/{internal/executing → test}/execution_steps.js +2 -8
- package/src/{internal/executing → test}/gc.js +0 -0
- package/src/test/logs_file_execution.js +223 -0
- package/dist/browser_client/asset-manifest.json +0 -4
- package/dist/browser_client/browser_client_fb33eaa4.js +0 -5320
- package/dist/browser_client/browser_client_fb33eaa4.js.map +0 -1089
- package/dist/build_manifest.js +0 -12
- package/dist/compile_proxy/asset-manifest.json +0 -4
- package/dist/compile_proxy/compile_proxy.html__inline__20_651d1e7b.js.map +0 -343
- package/dist/compile_proxy/compile_proxy_62f952c4.html +0 -2245
- package/dist/event_source_client/asset-manifest.json +0 -4
- package/dist/event_source_client/event_source_client_69f48287.js +0 -354
- package/dist/event_source_client/event_source_client_69f48287.js.map +0 -128
- package/dist/redirector/asset-manifest.json +0 -4
- package/dist/redirector/redirector.html__inline__12_171e07b4.js.map +0 -349
- package/dist/redirector/redirector_8117ec92.html +0 -2290
- package/dist/toolbar/asset-manifest.json +0 -13
- package/dist/toolbar/assets/compilation.css_7421bd55.map +0 -12
- package/dist/toolbar/assets/eventsource.css_c0c71e7b.map +0 -12
- package/dist/toolbar/assets/execution.css_f3377c10.map +0 -12
- package/dist/toolbar/assets/focus.css_896f3e45.map +0 -12
- package/dist/toolbar/assets/light_theme.css_5bff0336.map +0 -12
- package/dist/toolbar/assets/overflow_menu.css_9a0fc3d8.map +0 -12
- package/dist/toolbar/assets/settings.css_942b5a9e.map +0 -12
- package/dist/toolbar/assets/toolbar_main.css_b1c67dd7.map +0 -28
- package/dist/toolbar/assets/tooltip.css_a94a8bdd.map +0 -12
- package/dist/toolbar/toolbar_b0c9100c.html +0 -4976
- package/dist/toolbar/toolbar_main_f54c1bb0.js.map +0 -776
- package/dist/toolbar_injector/asset-manifest.json +0 -5
- package/dist/toolbar_injector/assets/jsenv_logo_192011c2.svg +0 -95
- package/dist/toolbar_injector/toolbar_injector_65b501eb.js +0 -976
- package/dist/toolbar_injector/toolbar_injector_65b501eb.js.map +0 -294
- package/helpers/import-meta/import-meta-url-commonjs.js +0 -9
- package/helpers/import-meta/import-meta-url-global.js +0 -54
- package/src/build_project.js +0 -336
- package/src/commonjs_to_js_module.js +0 -180
- package/src/dev_server.js +0 -302
- package/src/execute.js +0 -184
- package/src/import_using_child_process.js +0 -68
- package/src/internal/browser_client/browser_client.js +0 -220
- package/src/internal/browser_client/browser_client_factory.js +0 -144
- package/src/internal/browser_client/browser_error_stack_remap.js +0 -43
- package/src/internal/browser_client/browser_system.js +0 -216
- package/src/internal/browser_client/module_namespace_transfer.js +0 -90
- package/src/internal/browser_detection/browser_detection.js +0 -65
- package/src/internal/browser_detection/detect_android.js +0 -13
- package/src/internal/browser_detection/detect_chrome.js +0 -28
- package/src/internal/browser_detection/detect_edge.js +0 -13
- package/src/internal/browser_detection/detect_electron.js +0 -1
- package/src/internal/browser_detection/detect_firefox.js +0 -17
- package/src/internal/browser_detection/detect_internet_explorer.js +0 -14
- package/src/internal/browser_detection/detect_ios.js +0 -19
- package/src/internal/browser_detection/detect_opera.js +0 -27
- package/src/internal/browser_detection/detect_safari.js +0 -13
- package/src/internal/browser_detection/user_agent_data.js +0 -25
- package/src/internal/browser_detection/util.js +0 -13
- package/src/internal/browser_launcher/browser_runtime_profile.js +0 -81
- package/src/internal/browser_launcher/execute_html_file.js +0 -355
- package/src/internal/browser_launcher/from_playwright.js +0 -320
- package/src/internal/browser_launcher/page_errors_and_logs.js +0 -77
- package/src/internal/browser_utils/fetch_and_eval.js +0 -27
- package/src/internal/browser_utils/fetch_and_eval_using_script.js +0 -47
- package/src/internal/browser_utils/fetch_browser.js +0 -34
- package/src/internal/browser_utils/fetch_json.js +0 -7
- package/src/internal/building/build_logs.js +0 -134
- package/src/internal/building/build_stats.js +0 -100
- package/src/internal/building/build_url_generator.js +0 -153
- package/src/internal/building/build_using_rollup.js +0 -359
- package/src/internal/building/css/apply_post_css.js +0 -55
- package/src/internal/building/css/jsenv_parse_css.js +0 -260
- package/src/internal/building/css/move_css_urls.js +0 -44
- package/src/internal/building/css/parse_css_urls.js +0 -38
- package/src/internal/building/css/postcss_plugin_url_visitor.js +0 -245
- package/src/internal/building/css/replace_css_urls.js +0 -68
- package/src/internal/building/global_format/es_to_system.js +0 -34
- package/src/internal/building/html/html_node_mutations.js +0 -29
- package/src/internal/building/html/html_scan.js +0 -70
- package/src/internal/building/html/jsenv_parse_html.js +0 -813
- package/src/internal/building/html/minify_html.js +0 -7
- package/src/internal/building/import_assertions/css_module.js +0 -43
- package/src/internal/building/import_references.js +0 -80
- package/src/internal/building/importmap/jsenv_parse_importmap.js +0 -28
- package/src/internal/building/js/babel_plugin_inline_worker_imports.js +0 -96
- package/src/internal/building/js/jsenv_parse_js.js +0 -122
- package/src/internal/building/js/minify_js.js +0 -33
- package/src/internal/building/js/transform_worker.js +0 -55
- package/src/internal/building/json/jsenv_parse_json.js +0 -11
- package/src/internal/building/parse_ressource.js +0 -207
- package/src/internal/building/ressource_builder.js +0 -1098
- package/src/internal/building/ressource_builder_util.js +0 -194
- package/src/internal/building/rollup_plugin_jsenv.js +0 -1965
- package/src/internal/building/sort_pathnames.js +0 -10
- package/src/internal/building/sourcemap/sourcemap_loader.js +0 -70
- package/src/internal/building/svg/jsenv_parse_svg.js +0 -112
- package/src/internal/building/url_fetcher.js +0 -85
- package/src/internal/building/url_loader.js +0 -127
- package/src/internal/building/url_trace.js +0 -229
- package/src/internal/building/url_versioning/resolve_import_url_helper.js +0 -12
- package/src/internal/building/url_versioning/url_versioning.js +0 -65
- package/src/internal/building/webmanifest/jsenv_parse_webmanifest.js +0 -48
- package/src/internal/compile_server/commonjs/rollup_plugin_commonjs_named_exports.js +0 -187
- package/src/internal/compile_server/compile_file.js +0 -273
- package/src/internal/compile_server/compile_server.js +0 -519
- package/src/internal/compile_server/compiled_file_service.js +0 -264
- package/src/internal/compile_server/html/html_ast.js +0 -534
- package/src/internal/compile_server/html/html_source_file_service.js +0 -453
- package/src/internal/compile_server/html/jsenv_compile_html.js +0 -674
- package/src/internal/compile_server/importmap/jsenv_compile_importmap.js +0 -28
- package/src/internal/compile_server/js/ansi_to_html.js +0 -9
- package/src/internal/compile_server/js/babelHelper.js +0 -145
- package/src/internal/compile_server/js/babel_parse_error.js +0 -9
- package/src/internal/compile_server/js/babel_plugin_global_this_as_jsenv_import.js +0 -34
- package/src/internal/compile_server/js/babel_plugin_import_assertions.js +0 -121
- package/src/internal/compile_server/js/babel_plugin_import_metadata.js +0 -18
- package/src/internal/compile_server/js/babel_plugin_import_visitor.js +0 -84
- package/src/internal/compile_server/js/babel_plugin_new_stylesheet_as_jsenv_import.js +0 -113
- package/src/internal/compile_server/js/babel_plugin_proxy_external_imports.js +0 -31
- package/src/internal/compile_server/js/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -48
- package/src/internal/compile_server/js/babel_plugin_replace_expressions.js +0 -101
- package/src/internal/compile_server/js/babel_plugin_systemjs_prepend.js +0 -23
- package/src/internal/compile_server/js/babel_plugin_transform_import_meta.js +0 -134
- package/src/internal/compile_server/js/babel_plugins.js +0 -37
- package/src/internal/compile_server/js/generateBabelHelper.js +0 -36
- package/src/internal/compile_server/js/js_transformer.js +0 -195
- package/src/internal/compile_server/js/jsenv_compile_js.js +0 -62
- package/src/internal/compile_server/js/load_babel_plugin_map_from_file.js +0 -49
- package/src/internal/compile_server/jsenv_directory/comparison_utils.js +0 -27
- package/src/internal/compile_server/jsenv_directory/compilation_result.js +0 -243
- package/src/internal/compile_server/jsenv_directory/compilation_result_from_build.js +0 -184
- package/src/internal/compile_server/jsenv_directory/compile_asset.js +0 -24
- package/src/internal/compile_server/jsenv_directory/compile_context.js +0 -60
- package/src/internal/compile_server/jsenv_directory/compile_profile.js +0 -217
- package/src/internal/compile_server/jsenv_directory/file_lock_registry.js +0 -24
- package/src/internal/compile_server/jsenv_directory/file_lock_registry.test.js +0 -47
- package/src/internal/compile_server/jsenv_directory/fs_optimized_for_cache.js +0 -57
- package/src/internal/compile_server/jsenv_directory/jsenv_directory.js +0 -183
- package/src/internal/compile_server/jsenv_directory/reuse_or_create_compiled_file.js +0 -269
- package/src/internal/compile_server/jsenv_directory/update_compile_cache.js +0 -131
- package/src/internal/compile_server/jsenv_directory/validate_compile_cache.js +0 -264
- package/src/internal/compile_server/sse_service/sse_service.js +0 -369
- package/src/internal/coverage/babel_plugin_instrument.js +0 -90
- package/src/internal/coverage/coverage_reporter_html_directory.js +0 -37
- package/src/internal/coverage/coverage_reporter_json_file.js +0 -22
- package/src/internal/coverage/coverage_reporter_text_log.js +0 -20
- package/src/internal/coverage/empty_coverage_factory.js +0 -70
- package/src/internal/coverage/file_by_file_coverage.js +0 -28
- package/src/internal/coverage/istanbul_coverage_composition.js +0 -28
- package/src/internal/coverage/istanbul_coverage_map_from_coverage.js +0 -16
- package/src/internal/coverage/list_files_not_covered.js +0 -20
- package/src/internal/coverage/missing_coverage.js +0 -46
- package/src/internal/coverage/report_to_coverage.js +0 -198
- package/src/internal/coverage/v8_and_istanbul.js +0 -38
- package/src/internal/coverage/v8_coverage_composition.js +0 -23
- package/src/internal/coverage/v8_coverage_from_directory.js +0 -86
- package/src/internal/coverage/v8_coverage_to_istanbul.js +0 -100
- package/src/internal/data_url.js +0 -54
- package/src/internal/dev_server/event_source_client/event_source_client.js +0 -63
- package/src/internal/dev_server/event_source_client/file_changes.js +0 -82
- package/src/internal/dev_server/event_source_client/livereload_preference.js +0 -13
- package/src/internal/dev_server/exploring/exploring.css +0 -237
- package/src/internal/dev_server/exploring/exploring.html +0 -79
- package/src/internal/dev_server/exploring/exploring.js +0 -243
- package/src/internal/dev_server/exploring/fetch_exploring_json.js +0 -19
- package/src/internal/dev_server/toolbar/compilation/compilation.css +0 -23
- package/src/internal/dev_server/toolbar/compilation/toolbar_compilation.js +0 -202
- package/src/internal/dev_server/toolbar/eventsource/toolbar_eventsource.js +0 -83
- package/src/internal/dev_server/toolbar/execution/toolbar_execution.js +0 -91
- package/src/internal/error_stack_remap/install_error_stack_remapping.js +0 -142
- package/src/internal/error_stack_remap/remap_call_site.js +0 -315
- package/src/internal/error_stack_remap/remap_stack.js +0 -218
- package/src/internal/error_stack_remap/stringify_stack.js +0 -9
- package/src/internal/executing/launch_and_execute.js +0 -458
- package/src/internal/executing/logs_file_execution.js +0 -160
- package/src/internal/executing/logs_plan_summary.js +0 -144
- package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +0 -20
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +0 -23
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +0 -25
- package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +0 -37
- package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +0 -9
- package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +0 -14
- package/src/internal/features/browser_feature_detection/browser_feature_detection.js +0 -89
- package/src/internal/features/browser_feature_detection/compile_proxy.html +0 -27
- package/src/internal/features/browser_feature_detection/execute_with_script_module.js +0 -24
- package/src/internal/features/features_compat_from_runtime.js +0 -38
- package/src/internal/features/features_compat_from_runtime_support.js +0 -31
- package/src/internal/features/features_compatibility.js +0 -37
- package/src/internal/features/node_feature_detection/feature_detect_dynamic_import.mjs +0 -5
- package/src/internal/features/node_feature_detection/feature_detect_top_level_await.mjs +0 -1
- package/src/internal/features/node_feature_detection/node_feature_detect_dynamic_import.js +0 -5
- package/src/internal/features/node_feature_detection/node_feature_detect_top_level_await.js +0 -16
- package/src/internal/features/node_feature_detection/node_feature_detection.js +0 -66
- package/src/internal/fetching.js +0 -28
- package/src/internal/import_resolution/default_extension.js +0 -40
- package/src/internal/import_resolution/import_resolver_importmap.js +0 -64
- package/src/internal/import_resolution/import_resolver_node.js +0 -254
- package/src/internal/import_resolution/importmap_default.js +0 -37
- package/src/internal/jsenv_builds.js +0 -19
- package/src/internal/jsenv_params_assertions.js +0 -12
- package/src/internal/jsenv_remote_directory.js +0 -156
- package/src/internal/logs/byte.js +0 -10
- package/src/internal/logs/byte_as_file_size.js +0 -9
- package/src/internal/logs/ms_as_duration.js +0 -12
- package/src/internal/memoize.js +0 -24
- package/src/internal/node_launcher/eval_source.js +0 -6
- package/src/internal/node_launcher/fetch_source.js +0 -8
- package/src/internal/node_launcher/node_error_stack_remap.js +0 -22
- package/src/internal/node_launcher/node_execution_dynamic_import.js +0 -75
- package/src/internal/node_launcher/node_execution_performance.js +0 -67
- package/src/internal/node_launcher/node_execution_systemjs.js +0 -125
- package/src/internal/node_launcher/node_runtime_report.js +0 -77
- package/src/internal/node_launcher/node_system.js +0 -192
- package/src/internal/node_launcher/perf_node.js +0 -13
- package/src/internal/node_launcher/process_options.js +0 -46
- package/src/internal/node_launcher/value_install.js +0 -14
- package/src/internal/origin_directory_converter.js +0 -62
- package/src/internal/promise_race.js +0 -19
- package/src/internal/redirector/redirector.html +0 -40
- package/src/internal/regexp_escape.js +0 -34
- package/src/internal/require.js +0 -3
- package/src/internal/response_validation.js +0 -130
- package/src/internal/runtime_client/module_registration.js +0 -207
- package/src/internal/runtime_client/s.js +0 -864
- package/src/internal/runtime_client/s.js.md +0 -1
- package/src/internal/runtime_support/jsenv_runtime_support.js +0 -15
- package/src/internal/runtime_support/runtime_support.js +0 -70
- package/src/internal/semantic_versioning/compare_versions.js +0 -28
- package/src/internal/semantic_versioning/highest_version.js +0 -11
- package/src/internal/semantic_versioning/is_above.js +0 -5
- package/src/internal/semantic_versioning/is_below.js +0 -5
- package/src/internal/semantic_versioning/is_equal.js +0 -3
- package/src/internal/semantic_versioning/lowest_version.js +0 -11
- package/src/internal/semantic_versioning/version_from_value.js +0 -42
- package/src/internal/sourcemap_utils.js +0 -112
- package/src/internal/template_string_escape.js +0 -20
- package/src/internal/url_conversion.js +0 -313
- package/src/internal/url_utils.js +0 -33
- package/src/internal/url_utils.test.js +0 -39
- package/src/internal/windows_file_path_utils.js +0 -16
- package/src/jsenv_file_urls.js +0 -35
- package/src/jsenv_service_worker_finalizer.js +0 -55
- package/src/json_to_js_module.js +0 -13
- package/src/node_runtime.js +0 -227
- package/src/require_using_child_process.js +0 -67
- package/src/text_to_js_module.js +0 -13
|
@@ -1,1965 +0,0 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
import MagicString from "magic-string"
|
|
3
|
-
import { composeTwoImportMaps, normalizeImportMap } from "@jsenv/importmap"
|
|
4
|
-
import { isSpecifierForNodeCoreModule } from "@jsenv/importmap/src/isSpecifierForNodeCoreModule.js"
|
|
5
|
-
import { createDetailedMessage, loggerToLogLevel } from "@jsenv/logger"
|
|
6
|
-
import {
|
|
7
|
-
fileSystemPathToUrl,
|
|
8
|
-
resolveUrl,
|
|
9
|
-
urlToRelativeUrl,
|
|
10
|
-
resolveDirectoryUrl,
|
|
11
|
-
comparePathnames,
|
|
12
|
-
urlIsInsideOf,
|
|
13
|
-
normalizeStructuredMetaMap,
|
|
14
|
-
urlToMeta,
|
|
15
|
-
urlToBasename,
|
|
16
|
-
urlToFilename,
|
|
17
|
-
readFile,
|
|
18
|
-
urlToFileSystemPath,
|
|
19
|
-
} from "@jsenv/filesystem"
|
|
20
|
-
import { UNICODE } from "@jsenv/log"
|
|
21
|
-
|
|
22
|
-
import { jsenvHelpersDirectoryInfo } from "@jsenv/core/src/jsenv_file_urls.js"
|
|
23
|
-
import { require } from "@jsenv/core/src/internal/require.js"
|
|
24
|
-
import { transformJs } from "@jsenv/core/src/internal/compile_server/js/js_transformer.js"
|
|
25
|
-
import { createUrlConverter } from "@jsenv/core/src/internal/url_conversion.js"
|
|
26
|
-
import { createImportResolverForNode } from "@jsenv/core/src/internal/import_resolution/import_resolver_node.js"
|
|
27
|
-
import { createImportResolverForImportmap } from "@jsenv/core/src/internal/import_resolution/import_resolver_importmap.js"
|
|
28
|
-
import { getDefaultImportmap } from "@jsenv/core/src/internal/import_resolution/importmap_default.js"
|
|
29
|
-
import { createJsenvRemoteDirectory } from "@jsenv/core/src/internal/jsenv_remote_directory.js"
|
|
30
|
-
import { setUrlSearchParamsDescriptor } from "@jsenv/core/src/internal/url_utils.js"
|
|
31
|
-
import { shakeBabelPluginMap } from "@jsenv/core/src/internal/compile_server/jsenv_directory/compile_profile.js"
|
|
32
|
-
|
|
33
|
-
import { convertJsonTextToJavascriptModule } from "./import_assertions/json_module.js"
|
|
34
|
-
import { convertCssTextToJavascriptModule } from "./import_assertions/css_module.js"
|
|
35
|
-
import { importMapsFromHtml } from "./html/html_scan.js"
|
|
36
|
-
import { esToSystem } from "./global_format/es_to_system.js"
|
|
37
|
-
import { createUrlFetcher } from "./url_fetcher.js"
|
|
38
|
-
import { createUrlLoader } from "./url_loader.js"
|
|
39
|
-
import { stringifyUrlTrace } from "./url_trace.js"
|
|
40
|
-
import {
|
|
41
|
-
formatBuildStartLog,
|
|
42
|
-
formatUseImportMapFromHtml,
|
|
43
|
-
formatImportmapOutsideCompileDirectory,
|
|
44
|
-
formatRessourceHintNeverUsedWarning,
|
|
45
|
-
formatBuildDoneInfo,
|
|
46
|
-
} from "./build_logs.js"
|
|
47
|
-
import { parseRessource } from "./parse_ressource.js"
|
|
48
|
-
import {
|
|
49
|
-
createRessourceBuilder,
|
|
50
|
-
referenceToCodeForRollup,
|
|
51
|
-
} from "./ressource_builder.js"
|
|
52
|
-
import { createBuildUrlGenerator } from "./build_url_generator.js"
|
|
53
|
-
import { visitImportReferences } from "./import_references.js"
|
|
54
|
-
import { sortObjectByPathnames } from "./sort_pathnames.js"
|
|
55
|
-
import { createBuildStats } from "./build_stats.js"
|
|
56
|
-
|
|
57
|
-
export const createRollupPlugins = async ({
|
|
58
|
-
buildOperation,
|
|
59
|
-
logger,
|
|
60
|
-
|
|
61
|
-
projectDirectoryUrl,
|
|
62
|
-
entryPoints,
|
|
63
|
-
buildDirectoryUrl,
|
|
64
|
-
|
|
65
|
-
urlMappings,
|
|
66
|
-
importResolutionMethod,
|
|
67
|
-
importMapFileRelativeUrl,
|
|
68
|
-
importDefaultExtension,
|
|
69
|
-
externalImportSpecifiers,
|
|
70
|
-
importPaths,
|
|
71
|
-
preservedUrls,
|
|
72
|
-
serviceWorkerFinalizer,
|
|
73
|
-
|
|
74
|
-
format,
|
|
75
|
-
systemJsUrl,
|
|
76
|
-
globals,
|
|
77
|
-
preservedDynamicImports,
|
|
78
|
-
|
|
79
|
-
node,
|
|
80
|
-
compileServer,
|
|
81
|
-
compileProfile,
|
|
82
|
-
compileId,
|
|
83
|
-
|
|
84
|
-
urlVersioning,
|
|
85
|
-
lineBreakNormalization,
|
|
86
|
-
jsConcatenation,
|
|
87
|
-
cssConcatenation,
|
|
88
|
-
useImportMapToMaximizeCacheReuse,
|
|
89
|
-
|
|
90
|
-
minify,
|
|
91
|
-
minifyJsOptions,
|
|
92
|
-
minifyCssOptions,
|
|
93
|
-
minifyHtmlOptions,
|
|
94
|
-
}) => {
|
|
95
|
-
const compileServerOrigin = compileServer.origin
|
|
96
|
-
// For now the compilation is forced during build because this plugin
|
|
97
|
-
// was coded assuming build always requires to be compiled.
|
|
98
|
-
// Ideally jsenv should also be able to build a project using source files
|
|
99
|
-
// and in that case compileProfile and compileId are null
|
|
100
|
-
// the babel plugin map is useless (we can just fetch the source file directly)
|
|
101
|
-
const jsenvDirectoryRelativeUrl = compileServer.jsenvDirectoryRelativeUrl
|
|
102
|
-
const compileDirectoryRelativeUrl = `${jsenvDirectoryRelativeUrl}${compileId}/`
|
|
103
|
-
const babelPluginMap = shakeBabelPluginMap({
|
|
104
|
-
babelPluginMap: compileServer.babelPluginMap,
|
|
105
|
-
compileProfile,
|
|
106
|
-
})
|
|
107
|
-
const importAssertionsSupport = {
|
|
108
|
-
json:
|
|
109
|
-
format === "esmodule" &&
|
|
110
|
-
compileProfile &&
|
|
111
|
-
!compileProfile.missingFeatures["import_assertion_type_json"],
|
|
112
|
-
css:
|
|
113
|
-
format === "esmodule" &&
|
|
114
|
-
compileProfile &&
|
|
115
|
-
!compileProfile.missingFeatures["import_assertion_type_css"],
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const jsenvRemoteDirectory = createJsenvRemoteDirectory({
|
|
119
|
-
projectDirectoryUrl,
|
|
120
|
-
jsenvDirectoryRelativeUrl,
|
|
121
|
-
preservedUrls,
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
const urlImporterMap = {}
|
|
125
|
-
const inlineModuleScripts = {}
|
|
126
|
-
const jsModulesFromEntry = {}
|
|
127
|
-
const buildFileContents = {}
|
|
128
|
-
const buildInlineFileContents = {}
|
|
129
|
-
let buildStats = {}
|
|
130
|
-
const buildStartMs = Date.now()
|
|
131
|
-
|
|
132
|
-
const serviceWorkerUrls = []
|
|
133
|
-
const classicServiceWorkerUrls = []
|
|
134
|
-
|
|
135
|
-
let lastErrorMessage
|
|
136
|
-
const storeLatestJsenvPluginError = (error) => {
|
|
137
|
-
lastErrorMessage = error.message
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const extension = path.extname(entryPoints[Object.keys(entryPoints)[0]])
|
|
141
|
-
const outputExtension = extension === ".html" ? ".js" : extension
|
|
142
|
-
|
|
143
|
-
const entryPointUrls = {}
|
|
144
|
-
Object.keys(entryPoints).forEach((key) => {
|
|
145
|
-
const url = resolveUrl(key, projectDirectoryUrl)
|
|
146
|
-
entryPointUrls[url] = entryPoints[key]
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
let ressourceBuilder
|
|
150
|
-
let importResolver
|
|
151
|
-
let rollupEmitFile = () => {}
|
|
152
|
-
let rollupSetAssetSource = () => {}
|
|
153
|
-
let _rollupGetModuleInfo = () => {}
|
|
154
|
-
const rollupGetModuleInfo = (id) => _rollupGetModuleInfo(id)
|
|
155
|
-
|
|
156
|
-
const {
|
|
157
|
-
compileServerOriginForRollup,
|
|
158
|
-
asRollupUrl,
|
|
159
|
-
asProjectUrl,
|
|
160
|
-
asServerUrl,
|
|
161
|
-
asCompiledServerUrl,
|
|
162
|
-
asOriginalUrl,
|
|
163
|
-
asOriginalServerUrl,
|
|
164
|
-
applyUrlMappings,
|
|
165
|
-
} = createUrlConverter({
|
|
166
|
-
projectDirectoryUrl,
|
|
167
|
-
compileServerOrigin,
|
|
168
|
-
compileDirectoryRelativeUrl,
|
|
169
|
-
urlMappings,
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
const buildUrlGenerator = createBuildUrlGenerator({
|
|
173
|
-
entryPointUrls,
|
|
174
|
-
asOriginalUrl,
|
|
175
|
-
lineBreakNormalization,
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
const urlFetcher = createUrlFetcher({
|
|
179
|
-
jsenvRemoteDirectory,
|
|
180
|
-
asOriginalUrl,
|
|
181
|
-
asProjectUrl,
|
|
182
|
-
applyUrlMappings,
|
|
183
|
-
urlImporterMap,
|
|
184
|
-
beforeThrowingResponseValidationError: (error) => {
|
|
185
|
-
storeLatestJsenvPluginError(error)
|
|
186
|
-
},
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
const urlCustomLoaders = {}
|
|
190
|
-
const urlLoader = createUrlLoader({
|
|
191
|
-
urlCustomLoaders,
|
|
192
|
-
allowJson: acceptsJsonContentType({ node, format }),
|
|
193
|
-
urlImporterMap,
|
|
194
|
-
|
|
195
|
-
asProjectUrl,
|
|
196
|
-
asOriginalUrl,
|
|
197
|
-
|
|
198
|
-
urlFetcher,
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
const urlMetaGetter = createUrlMetaGetter({
|
|
202
|
-
projectDirectoryUrl,
|
|
203
|
-
jsenvRemoteDirectory,
|
|
204
|
-
preservedUrls,
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
// Object mapping project relative urls to build relative urls
|
|
208
|
-
let buildMappings = {}
|
|
209
|
-
// Object mapping ressource names to build relative urls
|
|
210
|
-
let ressourceMappings = {}
|
|
211
|
-
|
|
212
|
-
const ressourcesReferencedByJs = []
|
|
213
|
-
const createImportMapForFilesUsedInJs = () => {
|
|
214
|
-
const topLevelMappings = {}
|
|
215
|
-
ressourcesReferencedByJs.sort(comparePathnames).forEach((ressourceName) => {
|
|
216
|
-
const buildRelativeUrl = ressourceMappings[ressourceName]
|
|
217
|
-
if (
|
|
218
|
-
ressourceName &&
|
|
219
|
-
buildRelativeUrl &&
|
|
220
|
-
ressourceName !== buildRelativeUrl
|
|
221
|
-
) {
|
|
222
|
-
topLevelMappings[`./${ressourceName}`] = `./${buildRelativeUrl}`
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
return {
|
|
226
|
-
imports: topLevelMappings,
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
let rollupBuild
|
|
231
|
-
|
|
232
|
-
const EMPTY_CHUNK_URL = resolveUrl("__empty__", projectDirectoryUrl)
|
|
233
|
-
|
|
234
|
-
const compileDirectoryUrl = resolveDirectoryUrl(
|
|
235
|
-
compileDirectoryRelativeUrl,
|
|
236
|
-
projectDirectoryUrl,
|
|
237
|
-
)
|
|
238
|
-
const compileDirectoryServerUrl = resolveDirectoryUrl(
|
|
239
|
-
compileDirectoryRelativeUrl,
|
|
240
|
-
compileServerOrigin,
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
const emitAsset = ({ fileName, source }) => {
|
|
244
|
-
return rollupEmitFile({
|
|
245
|
-
type: "asset",
|
|
246
|
-
source,
|
|
247
|
-
fileName,
|
|
248
|
-
})
|
|
249
|
-
}
|
|
250
|
-
// rollup expects an input option, if we provide only an html file
|
|
251
|
-
// without any script type module in it, we won't emit "chunk" and rollup will throw.
|
|
252
|
-
// It is valid to build an html not referencing any js (rare but valid)
|
|
253
|
-
// In that case jsenv emits an empty chunk and discards rollup warning about it
|
|
254
|
-
// This chunk is later ignored in "generateBundle" hook
|
|
255
|
-
let atleastOneChunkEmitted = false
|
|
256
|
-
const emitChunk = (chunk) => {
|
|
257
|
-
atleastOneChunkEmitted = true
|
|
258
|
-
return rollupEmitFile({
|
|
259
|
-
type: "chunk",
|
|
260
|
-
...chunk,
|
|
261
|
-
})
|
|
262
|
-
}
|
|
263
|
-
const setAssetSource = (rollupReferenceId, assetSource) => {
|
|
264
|
-
return rollupSetAssetSource(rollupReferenceId, assetSource)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
let onBundleEnd = () => {}
|
|
268
|
-
let minifyJs
|
|
269
|
-
let minifyHtml
|
|
270
|
-
|
|
271
|
-
const rollupPlugins = []
|
|
272
|
-
// When format is systemjs, rollup add async/await
|
|
273
|
-
// that might be unsupported by the runtime.
|
|
274
|
-
// in that case we have to transform the rollup output
|
|
275
|
-
if (babelPluginMap["transform-async-to-promises"] && format === "systemjs") {
|
|
276
|
-
rollupPlugins.push({
|
|
277
|
-
name: "jsenv_fix_async_await",
|
|
278
|
-
async renderChunk(code, chunk) {
|
|
279
|
-
let map = chunk.map
|
|
280
|
-
const result = await transformJs({
|
|
281
|
-
projectDirectoryUrl,
|
|
282
|
-
jsenvRemoteDirectory,
|
|
283
|
-
url: chunk.facadeModuleId
|
|
284
|
-
? asOriginalUrl(chunk.facadeModuleId)
|
|
285
|
-
: resolveUrl(chunk.fileName, buildDirectoryUrl),
|
|
286
|
-
code,
|
|
287
|
-
babelPluginMap: {
|
|
288
|
-
"transform-async-to-promises":
|
|
289
|
-
babelPluginMap["transform-async-to-promises"],
|
|
290
|
-
},
|
|
291
|
-
// pass undefined when format is "systemjs" to avoid
|
|
292
|
-
// re-wrapping the code in systemjs format
|
|
293
|
-
moduleOutFormat: undefined,
|
|
294
|
-
babelHelpersInjectionAsImport: false,
|
|
295
|
-
transformGenerator: false,
|
|
296
|
-
})
|
|
297
|
-
code = result.code
|
|
298
|
-
map = result.map
|
|
299
|
-
return {
|
|
300
|
-
code,
|
|
301
|
-
map,
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
})
|
|
305
|
-
}
|
|
306
|
-
if (format === "global") {
|
|
307
|
-
const globalsForRollup = {}
|
|
308
|
-
Object.keys(globals).forEach((key) => {
|
|
309
|
-
if (key.startsWith("./")) {
|
|
310
|
-
const keyAsUrl = resolveUrl(key, projectDirectoryUrl)
|
|
311
|
-
const keyAsPath = urlToFileSystemPath(keyAsUrl)
|
|
312
|
-
globalsForRollup[keyAsPath] = globals[key]
|
|
313
|
-
} else {
|
|
314
|
-
globalsForRollup[key] = globals[key]
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
const ESIIFE = require("es-iife")
|
|
318
|
-
const globalNameFromChunkInfo = (chunkInfo) => {
|
|
319
|
-
const originalUrl = asOriginalUrl(chunkInfo.facadeModuleId)
|
|
320
|
-
const originalPath = urlToFileSystemPath(originalUrl)
|
|
321
|
-
const nameFromGlobals = globalsForRollup[originalPath]
|
|
322
|
-
return nameFromGlobals || path.parse(chunkInfo.fileName).name
|
|
323
|
-
}
|
|
324
|
-
const structuredMetaMap = normalizeStructuredMetaMap(
|
|
325
|
-
{ preserved: preservedDynamicImports },
|
|
326
|
-
projectDirectoryUrl,
|
|
327
|
-
)
|
|
328
|
-
const isPreservedDynamicImport = (url) => {
|
|
329
|
-
const meta = urlToMeta({ url, structuredMetaMap })
|
|
330
|
-
return Boolean(meta.preserved)
|
|
331
|
-
}
|
|
332
|
-
rollupPlugins.push({
|
|
333
|
-
async transform(code, id) {
|
|
334
|
-
const serverUrl = asServerUrl(id)
|
|
335
|
-
const originalUrl = asOriginalUrl(id)
|
|
336
|
-
if (isPreservedDynamicImport(originalUrl)) {
|
|
337
|
-
return null
|
|
338
|
-
}
|
|
339
|
-
const jsRessource = ressourceBuilder.findRessource((ressource) => {
|
|
340
|
-
return ressource.url === serverUrl
|
|
341
|
-
})
|
|
342
|
-
if (!jsRessource || !jsRessource.isEntryPoint) {
|
|
343
|
-
return null
|
|
344
|
-
}
|
|
345
|
-
let map = null
|
|
346
|
-
const ast = this.parse(code, {
|
|
347
|
-
// used to know node line and column
|
|
348
|
-
locations: true,
|
|
349
|
-
})
|
|
350
|
-
let useDynamicImport = false
|
|
351
|
-
const { walk } = await import("estree-walker")
|
|
352
|
-
walk(ast, {
|
|
353
|
-
enter: (node) => {
|
|
354
|
-
if (node.type === "ImportExpression") {
|
|
355
|
-
useDynamicImport = true
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
})
|
|
359
|
-
if (!useDynamicImport) {
|
|
360
|
-
return null
|
|
361
|
-
}
|
|
362
|
-
const magicString = new MagicString(code)
|
|
363
|
-
magicString.prepend(
|
|
364
|
-
`import "@jsenv/core/src/internal/runtime_client/s.js";`,
|
|
365
|
-
)
|
|
366
|
-
code = magicString.toString()
|
|
367
|
-
map = magicString.generateMap({ hires: true })
|
|
368
|
-
return { code, map }
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
outputOptions: (outputOptions) => {
|
|
372
|
-
outputOptions.globals = globalsForRollup
|
|
373
|
-
outputOptions.format = "esm"
|
|
374
|
-
},
|
|
375
|
-
resolveImportMeta: (property, { chunkId }) => {
|
|
376
|
-
if (property === "url") {
|
|
377
|
-
return `(document.currentScript && document.currentScript.src || new URL("${chunkId}", document.baseURI).href);`
|
|
378
|
-
}
|
|
379
|
-
return undefined
|
|
380
|
-
},
|
|
381
|
-
renderDynamicImport: ({ moduleId }) => {
|
|
382
|
-
const originalUrl = asOriginalUrl(moduleId)
|
|
383
|
-
if (isPreservedDynamicImport(originalUrl)) {
|
|
384
|
-
return null
|
|
385
|
-
}
|
|
386
|
-
return {
|
|
387
|
-
left: "System.import(",
|
|
388
|
-
right: ")",
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
async renderChunk(code, chunkInfo) {
|
|
392
|
-
const serverUrl = asServerUrl(chunkInfo.facadeModuleId)
|
|
393
|
-
const jsRessource = ressourceBuilder.findRessource(
|
|
394
|
-
(ressource) => ressource.url === serverUrl,
|
|
395
|
-
)
|
|
396
|
-
if (jsRessource.isEntryPoint) {
|
|
397
|
-
const name = globalNameFromChunkInfo(chunkInfo)
|
|
398
|
-
const out = ESIIFE.transform({
|
|
399
|
-
code,
|
|
400
|
-
parse: this.parse,
|
|
401
|
-
name,
|
|
402
|
-
sourcemap: true,
|
|
403
|
-
resolveGlobal: (specifier) => {
|
|
404
|
-
const url = resolveUrl(specifier, chunkInfo.facadeModuleId)
|
|
405
|
-
const globalName = urlToBasename(url)
|
|
406
|
-
return globalName
|
|
407
|
-
},
|
|
408
|
-
strict: true,
|
|
409
|
-
})
|
|
410
|
-
code = out.code
|
|
411
|
-
const map = out.map
|
|
412
|
-
return {
|
|
413
|
-
code,
|
|
414
|
-
map,
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return esToSystem({
|
|
418
|
-
code,
|
|
419
|
-
url: serverUrl,
|
|
420
|
-
map: chunkInfo.map,
|
|
421
|
-
})
|
|
422
|
-
},
|
|
423
|
-
})
|
|
424
|
-
}
|
|
425
|
-
if (minify) {
|
|
426
|
-
const methodHooks = {
|
|
427
|
-
minifyJs: async (...args) => {
|
|
428
|
-
const { minifyJs } = await import("./js/minify_js.js")
|
|
429
|
-
return minifyJs(...args)
|
|
430
|
-
},
|
|
431
|
-
minifyHtml: async (...args) => {
|
|
432
|
-
const { minifyHtml } = await import("./html/minify_html.js")
|
|
433
|
-
return minifyHtml(...args)
|
|
434
|
-
},
|
|
435
|
-
}
|
|
436
|
-
minifyJs = async ({ url, code, map, ...rest }) => {
|
|
437
|
-
const result = await methodHooks.minifyJs({
|
|
438
|
-
url,
|
|
439
|
-
code,
|
|
440
|
-
map,
|
|
441
|
-
...minifyJsOptions,
|
|
442
|
-
...rest,
|
|
443
|
-
})
|
|
444
|
-
return {
|
|
445
|
-
code: result.code,
|
|
446
|
-
map: result.map,
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
minifyHtml = async (html) => {
|
|
450
|
-
return methodHooks.minifyHtml(html, minifyHtmlOptions)
|
|
451
|
-
}
|
|
452
|
-
rollupPlugins.push({
|
|
453
|
-
name: "jsenv_minifier",
|
|
454
|
-
async renderChunk(code, chunk) {
|
|
455
|
-
let map = chunk.map
|
|
456
|
-
const result = await minifyJs({
|
|
457
|
-
url: chunk.facadeModuleId
|
|
458
|
-
? asOriginalUrl(chunk.facadeModuleId)
|
|
459
|
-
: resolveUrl(chunk.fileName, buildDirectoryUrl),
|
|
460
|
-
code,
|
|
461
|
-
map,
|
|
462
|
-
module: format === "esmodule",
|
|
463
|
-
...(format === "global" ? { toplevel: false } : { toplevel: true }),
|
|
464
|
-
})
|
|
465
|
-
code = result.code
|
|
466
|
-
map = result.map
|
|
467
|
-
return {
|
|
468
|
-
code,
|
|
469
|
-
map,
|
|
470
|
-
}
|
|
471
|
-
},
|
|
472
|
-
})
|
|
473
|
-
}
|
|
474
|
-
rollupPlugins.unshift({
|
|
475
|
-
name: "jsenv",
|
|
476
|
-
|
|
477
|
-
async buildStart() {
|
|
478
|
-
logger.info(formatBuildStartLog({ entryPoints }))
|
|
479
|
-
|
|
480
|
-
const entryPointsPrepared = await prepareEntryPoints(entryPoints, {
|
|
481
|
-
logger,
|
|
482
|
-
projectDirectoryUrl,
|
|
483
|
-
buildDirectoryUrl,
|
|
484
|
-
compileServerOrigin,
|
|
485
|
-
urlFetcher,
|
|
486
|
-
})
|
|
487
|
-
const htmlEntryPoints = entryPointsPrepared.filter(
|
|
488
|
-
(entryPointPrepared) => {
|
|
489
|
-
return entryPointPrepared.entryContentType === "text/html"
|
|
490
|
-
},
|
|
491
|
-
)
|
|
492
|
-
const htmlEntryPointCount = htmlEntryPoints.length
|
|
493
|
-
if (node && htmlEntryPointCount > 0) {
|
|
494
|
-
logger.warn(
|
|
495
|
-
`WARNING: Found an HTML entry point and "node" is part of "runtimeSupport", it's not supposed to happen`,
|
|
496
|
-
)
|
|
497
|
-
}
|
|
498
|
-
if (htmlEntryPointCount > 1) {
|
|
499
|
-
const error = new Error(
|
|
500
|
-
`Cannot handle more than one html entry point, got ${htmlEntryPointCount}`,
|
|
501
|
-
)
|
|
502
|
-
storeLatestJsenvPluginError(error)
|
|
503
|
-
throw error
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (typeof useImportMapToMaximizeCacheReuse === "undefined") {
|
|
507
|
-
useImportMapToMaximizeCacheReuse =
|
|
508
|
-
htmlEntryPointCount > 0 &&
|
|
509
|
-
// node has no importmap concept, let's use the versionned url in that case
|
|
510
|
-
!node
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// https://github.com/easesu/rollup-plugin-html-input/blob/master/index.js
|
|
514
|
-
// https://rollupjs.org/guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string
|
|
515
|
-
rollupEmitFile = (...args) => this.emitFile(...args)
|
|
516
|
-
rollupSetAssetSource = (...args) => this.setAssetSource(...args)
|
|
517
|
-
_rollupGetModuleInfo = (id) => this.getModuleInfo(id)
|
|
518
|
-
|
|
519
|
-
let importMapInfoFromHtml = null
|
|
520
|
-
if (htmlEntryPointCount === 1) {
|
|
521
|
-
const htmlEntryPoint = htmlEntryPoints[0]
|
|
522
|
-
const htmlSource = String(htmlEntryPoint.entryBuffer)
|
|
523
|
-
|
|
524
|
-
const importMaps = importMapsFromHtml(htmlSource)
|
|
525
|
-
const importMapCount = importMaps.length
|
|
526
|
-
if (importMapCount > 1) {
|
|
527
|
-
const error = new Error(`Many importmap found in html file`)
|
|
528
|
-
storeLatestJsenvPluginError(error)
|
|
529
|
-
throw error
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (importMapCount === 1) {
|
|
533
|
-
const htmlUrl = resolveUrl(
|
|
534
|
-
htmlEntryPoint.entryProjectRelativeUrl,
|
|
535
|
-
projectDirectoryUrl,
|
|
536
|
-
)
|
|
537
|
-
importMapInfoFromHtml = {
|
|
538
|
-
...importMaps[0],
|
|
539
|
-
htmlUrl,
|
|
540
|
-
htmlSource,
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (importResolutionMethod === "node") {
|
|
546
|
-
importResolver = await createImportResolverForNode({
|
|
547
|
-
projectDirectoryUrl,
|
|
548
|
-
compileServerOrigin,
|
|
549
|
-
compileDirectoryRelativeUrl,
|
|
550
|
-
importDefaultExtension,
|
|
551
|
-
})
|
|
552
|
-
} else {
|
|
553
|
-
let importMap
|
|
554
|
-
let importMapUrl
|
|
555
|
-
let fetchImportMap
|
|
556
|
-
if (importMapInfoFromHtml) {
|
|
557
|
-
logger.debug(formatUseImportMapFromHtml(importMapInfoFromHtml))
|
|
558
|
-
|
|
559
|
-
if (importMapInfoFromHtml.type === "remote") {
|
|
560
|
-
importMapUrl = resolveUrl(
|
|
561
|
-
importMapInfoFromHtml.src,
|
|
562
|
-
asCompiledServerUrl(importMapInfoFromHtml.htmlUrl),
|
|
563
|
-
)
|
|
564
|
-
importMapUrl = applyUrlMappings(importMapUrl)
|
|
565
|
-
if (!urlIsInsideOf(importMapUrl, compileDirectoryServerUrl)) {
|
|
566
|
-
logger.warn(
|
|
567
|
-
formatImportmapOutsideCompileDirectory({
|
|
568
|
-
importMapInfo: importMapInfoFromHtml,
|
|
569
|
-
compileDirectoryUrl,
|
|
570
|
-
}),
|
|
571
|
-
)
|
|
572
|
-
}
|
|
573
|
-
fetchImportMap = () => {
|
|
574
|
-
return fetchImportMapFromUrl(
|
|
575
|
-
importMapUrl,
|
|
576
|
-
importMapInfoFromHtml.htmlUrl,
|
|
577
|
-
)
|
|
578
|
-
}
|
|
579
|
-
} else {
|
|
580
|
-
const firstHtmlEntryPoint = htmlEntryPoints[0]
|
|
581
|
-
const htmlProjectRelativeUrl =
|
|
582
|
-
firstHtmlEntryPoint.entryProjectRelativeUrl
|
|
583
|
-
const htmlCompiledUrl = resolveUrl(
|
|
584
|
-
htmlProjectRelativeUrl,
|
|
585
|
-
compileDirectoryServerUrl,
|
|
586
|
-
)
|
|
587
|
-
importMapUrl = htmlCompiledUrl
|
|
588
|
-
fetchImportMap = () => {
|
|
589
|
-
const importmapFileUrl = asProjectUrl(importMapUrl)
|
|
590
|
-
const jsenvImportmap = getDefaultImportmap(importmapFileUrl, {
|
|
591
|
-
projectDirectoryUrl,
|
|
592
|
-
compileDirectoryUrl,
|
|
593
|
-
})
|
|
594
|
-
const htmlImportmap = JSON.parse(importMapInfoFromHtml.text)
|
|
595
|
-
const importmap = composeTwoImportMaps(
|
|
596
|
-
jsenvImportmap,
|
|
597
|
-
htmlImportmap,
|
|
598
|
-
)
|
|
599
|
-
const importmapNormalized = normalizeImportMap(
|
|
600
|
-
importmap,
|
|
601
|
-
importMapUrl,
|
|
602
|
-
)
|
|
603
|
-
return importmapNormalized
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
} else if (importMapFileRelativeUrl) {
|
|
607
|
-
importMapUrl = resolveUrl(
|
|
608
|
-
importMapFileRelativeUrl,
|
|
609
|
-
compileDirectoryServerUrl,
|
|
610
|
-
)
|
|
611
|
-
fetchImportMap = () => {
|
|
612
|
-
return fetchImportMapFromUrl(
|
|
613
|
-
importMapUrl,
|
|
614
|
-
"importMapFileRelativeUrl parameter",
|
|
615
|
-
)
|
|
616
|
-
}
|
|
617
|
-
} else {
|
|
618
|
-
// there is no importmap, it's fine, it's not mandatory
|
|
619
|
-
fetchImportMap = () => {
|
|
620
|
-
const firstEntryPoint = htmlEntryPoints[0] || entryPointsPrepared[0]
|
|
621
|
-
const { entryProjectRelativeUrl } = firstEntryPoint
|
|
622
|
-
const entryCompileUrl = resolveUrl(
|
|
623
|
-
entryProjectRelativeUrl,
|
|
624
|
-
compileDirectoryUrl,
|
|
625
|
-
)
|
|
626
|
-
const jsenvImportmap = getDefaultImportmap(entryCompileUrl, {
|
|
627
|
-
projectDirectoryUrl,
|
|
628
|
-
compileDirectoryUrl,
|
|
629
|
-
})
|
|
630
|
-
const entryCompileServerUrl = resolveUrl(
|
|
631
|
-
entryProjectRelativeUrl,
|
|
632
|
-
compileDirectoryServerUrl,
|
|
633
|
-
)
|
|
634
|
-
const importmapNormalized = normalizeImportMap(
|
|
635
|
-
jsenvImportmap,
|
|
636
|
-
entryCompileServerUrl,
|
|
637
|
-
)
|
|
638
|
-
return importmapNormalized
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
try {
|
|
643
|
-
importMap = await fetchImportMap()
|
|
644
|
-
} catch (e) {
|
|
645
|
-
storeLatestJsenvPluginError(e)
|
|
646
|
-
throw e
|
|
647
|
-
}
|
|
648
|
-
importResolver = await createImportResolverForImportmap({
|
|
649
|
-
compileServerOrigin,
|
|
650
|
-
compileDirectoryRelativeUrl,
|
|
651
|
-
importMap,
|
|
652
|
-
importMapUrl,
|
|
653
|
-
importDefaultExtension,
|
|
654
|
-
onBareSpecifierError: (error) => {
|
|
655
|
-
storeLatestJsenvPluginError(error)
|
|
656
|
-
},
|
|
657
|
-
})
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
ressourceBuilder = createRessourceBuilder(
|
|
661
|
-
{
|
|
662
|
-
urlFetcher,
|
|
663
|
-
urlLoader,
|
|
664
|
-
parseRessource: async (ressource, notifiers) => {
|
|
665
|
-
return parseRessource(ressource, notifiers, {
|
|
666
|
-
format,
|
|
667
|
-
systemJsUrl,
|
|
668
|
-
projectDirectoryUrl,
|
|
669
|
-
jsenvRemoteDirectory,
|
|
670
|
-
asProjectUrl,
|
|
671
|
-
asOriginalUrl,
|
|
672
|
-
asOriginalServerUrl,
|
|
673
|
-
ressourceHintNeverUsedCallback: (linkInfo) => {
|
|
674
|
-
logger.warn(formatRessourceHintNeverUsedWarning(linkInfo))
|
|
675
|
-
},
|
|
676
|
-
useImportMapToMaximizeCacheReuse,
|
|
677
|
-
createImportMapForFilesUsedInJs,
|
|
678
|
-
minify,
|
|
679
|
-
minifyJs,
|
|
680
|
-
minifyHtml,
|
|
681
|
-
minifyCssOptions,
|
|
682
|
-
cssConcatenation,
|
|
683
|
-
})
|
|
684
|
-
},
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
logLevel: loggerToLogLevel(logger),
|
|
688
|
-
format,
|
|
689
|
-
// projectDirectoryUrl,
|
|
690
|
-
compileServerOrigin,
|
|
691
|
-
buildDirectoryUrl,
|
|
692
|
-
|
|
693
|
-
asOriginalServerUrl,
|
|
694
|
-
urlToCompiledServerUrl: (url) => {
|
|
695
|
-
return asCompiledServerUrl(url)
|
|
696
|
-
},
|
|
697
|
-
urlToHumanUrl: (
|
|
698
|
-
url,
|
|
699
|
-
{ showCompiledHint = false, preferRelativeUrls = false } = {},
|
|
700
|
-
) => {
|
|
701
|
-
if (
|
|
702
|
-
!url.startsWith("http:") &&
|
|
703
|
-
!url.startsWith("https:") &&
|
|
704
|
-
!url.startsWith("file:")
|
|
705
|
-
) {
|
|
706
|
-
return url
|
|
707
|
-
}
|
|
708
|
-
const originalUrl = asOriginalUrl(url)
|
|
709
|
-
const isCompiled = urlIsInsideOf(url, compileServerOrigin)
|
|
710
|
-
const originalRelativeUrl = urlToRelativeUrl(
|
|
711
|
-
originalUrl,
|
|
712
|
-
projectDirectoryUrl,
|
|
713
|
-
)
|
|
714
|
-
if (showCompiledHint && isCompiled) {
|
|
715
|
-
if (preferRelativeUrls) {
|
|
716
|
-
return `${originalRelativeUrl}[compiled]`
|
|
717
|
-
}
|
|
718
|
-
return `${originalUrl}[compiled]`
|
|
719
|
-
}
|
|
720
|
-
if (preferRelativeUrls) {
|
|
721
|
-
return originalRelativeUrl
|
|
722
|
-
}
|
|
723
|
-
return originalUrl
|
|
724
|
-
},
|
|
725
|
-
resolveRessourceUrl: ({
|
|
726
|
-
ressourceSpecifier,
|
|
727
|
-
isJsModule,
|
|
728
|
-
// isRessourceHint,
|
|
729
|
-
ressourceImporter,
|
|
730
|
-
}) => {
|
|
731
|
-
const getRessourceUrl = () => {
|
|
732
|
-
// Entry point is not a JS module and references a js module (html referencing js)
|
|
733
|
-
if (
|
|
734
|
-
ressourceImporter.isEntryPoint &&
|
|
735
|
-
!ressourceImporter.isJsModule &&
|
|
736
|
-
isJsModule
|
|
737
|
-
) {
|
|
738
|
-
const importerCompiledUrl = asCompiledServerUrl(
|
|
739
|
-
ressourceImporter.url,
|
|
740
|
-
)
|
|
741
|
-
const jsModuleUrl = resolveUrl(
|
|
742
|
-
ressourceSpecifier,
|
|
743
|
-
importerCompiledUrl,
|
|
744
|
-
)
|
|
745
|
-
return jsModuleUrl
|
|
746
|
-
}
|
|
747
|
-
// Entry point (likely html, unlikely css) is referecing a ressource
|
|
748
|
-
// In this situation:
|
|
749
|
-
// - when importmap is referenced: parse the original importmap ressource
|
|
750
|
-
// - other ressource: force compilation (because the HTML url is the original url)
|
|
751
|
-
if (
|
|
752
|
-
ressourceImporter.isEntryPoint &&
|
|
753
|
-
!ressourceImporter.isJsModule
|
|
754
|
-
) {
|
|
755
|
-
if (ressourceSpecifier.endsWith(".importmap")) {
|
|
756
|
-
const importmapUrl = resolveUrl(
|
|
757
|
-
ressourceSpecifier,
|
|
758
|
-
ressourceImporter.url,
|
|
759
|
-
)
|
|
760
|
-
return importmapUrl
|
|
761
|
-
}
|
|
762
|
-
const importerCompiled = asCompiledServerUrl(
|
|
763
|
-
ressourceImporter.url,
|
|
764
|
-
)
|
|
765
|
-
const ressourceCompiledUrl = resolveUrl(
|
|
766
|
-
ressourceSpecifier,
|
|
767
|
-
importerCompiled,
|
|
768
|
-
)
|
|
769
|
-
return ressourceCompiledUrl
|
|
770
|
-
}
|
|
771
|
-
const ressourceCompiledUrl = resolveUrl(
|
|
772
|
-
ressourceSpecifier,
|
|
773
|
-
ressourceImporter.url,
|
|
774
|
-
)
|
|
775
|
-
return ressourceCompiledUrl
|
|
776
|
-
}
|
|
777
|
-
const ressourceUrl = getRessourceUrl()
|
|
778
|
-
const resolutionResult = { url: ressourceUrl }
|
|
779
|
-
const ressourceOriginalUrl =
|
|
780
|
-
asOriginalUrl(ressourceUrl) || ressourceUrl
|
|
781
|
-
|
|
782
|
-
if (!urlIsInsideOf(ressourceUrl, compileServerOrigin)) {
|
|
783
|
-
resolutionResult.isCrossOrigin = true
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
const urlMeta = urlMetaGetter(ressourceOriginalUrl)
|
|
787
|
-
if (urlMeta.preserve) {
|
|
788
|
-
resolutionResult.isExternal = true
|
|
789
|
-
} else if (jsenvRemoteDirectory.isRemoteUrl(ressourceOriginalUrl)) {
|
|
790
|
-
const fileUrl =
|
|
791
|
-
jsenvRemoteDirectory.fileUrlFromRemoteUrl(ressourceOriginalUrl)
|
|
792
|
-
const compiledFileUrl = asCompiledServerUrl(fileUrl)
|
|
793
|
-
resolutionResult.url = compiledFileUrl
|
|
794
|
-
}
|
|
795
|
-
const { searchParams } = new URL(ressourceUrl)
|
|
796
|
-
if (searchParams.has("module")) {
|
|
797
|
-
resolutionResult.isJsModule = true
|
|
798
|
-
} else if (searchParams.has("worker")) {
|
|
799
|
-
resolutionResult.isWorker = true
|
|
800
|
-
resolutionResult.isJsModule = true
|
|
801
|
-
} else if (searchParams.has("service_worker")) {
|
|
802
|
-
resolutionResult.isServiceWorker = true
|
|
803
|
-
resolutionResult.isJsModule = true
|
|
804
|
-
serviceWorkerUrls.push(ressourceOriginalUrl)
|
|
805
|
-
} else if (searchParams.has("worker_type_classic")) {
|
|
806
|
-
resolutionResult.isWorker = true
|
|
807
|
-
} else if (searchParams.has("service_worker_type_classic")) {
|
|
808
|
-
resolutionResult.isServiceWorker = true
|
|
809
|
-
classicServiceWorkerUrls.push(ressourceOriginalUrl)
|
|
810
|
-
}
|
|
811
|
-
return resolutionResult
|
|
812
|
-
},
|
|
813
|
-
onJsModule: ({ ressource, jsModuleUrl, jsModuleIsInline }) => {
|
|
814
|
-
// we want to emit chunk only when ressource is referenced by something else than rollup
|
|
815
|
-
if (
|
|
816
|
-
jsConcatenation &&
|
|
817
|
-
ressource.references.every((ref) => ref.fromRollup)
|
|
818
|
-
) {
|
|
819
|
-
return null
|
|
820
|
-
}
|
|
821
|
-
if (ressource.isEntryPoint) {
|
|
822
|
-
} else {
|
|
823
|
-
const importerUrl = resolveUrl(
|
|
824
|
-
entryPointsPrepared[0].entryProjectRelativeUrl,
|
|
825
|
-
compileDirectoryServerUrl,
|
|
826
|
-
)
|
|
827
|
-
urlImporterMap[jsModuleUrl] = {
|
|
828
|
-
url: importerUrl,
|
|
829
|
-
line: undefined,
|
|
830
|
-
column: undefined,
|
|
831
|
-
}
|
|
832
|
-
jsModulesFromEntry[asRollupUrl(jsModuleUrl)] = true
|
|
833
|
-
if (jsModuleIsInline) {
|
|
834
|
-
inlineModuleScripts[jsModuleUrl] = ressource
|
|
835
|
-
urlCustomLoaders[jsModuleUrl] = async () => {
|
|
836
|
-
const url = asOriginalUrl(jsModuleUrl) // transformJs expect a file:// url
|
|
837
|
-
let code = String(ressource.bufferBeforeBuild)
|
|
838
|
-
const transformResult = await transformJs({
|
|
839
|
-
projectDirectoryUrl,
|
|
840
|
-
jsenvRemoteDirectory,
|
|
841
|
-
url,
|
|
842
|
-
babelPluginMap,
|
|
843
|
-
// moduleOutFormat: format // we are compiling for rollup output must be "esmodule"
|
|
844
|
-
// we compile for rollup, let top level await untouched
|
|
845
|
-
// it will be converted, if needed, during "renderChunk" hook
|
|
846
|
-
topLevelAwait: "ignore",
|
|
847
|
-
// if we put babel helpers, rollup might try to share them and a file
|
|
848
|
-
// might try to import from an inline script resulting in 404.
|
|
849
|
-
babelHelpersInjectionAsImport: false,
|
|
850
|
-
code,
|
|
851
|
-
})
|
|
852
|
-
return {
|
|
853
|
-
code: transformResult.code,
|
|
854
|
-
map: transformResult.map,
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
const fileName = ressource.buildRelativeUrlWithoutHash
|
|
860
|
-
const name = urlToBasename(resolveUrl(fileName, "file://"))
|
|
861
|
-
const rollupReferenceId = emitChunk({
|
|
862
|
-
id: jsModuleUrl,
|
|
863
|
-
name,
|
|
864
|
-
...(useImportMapToMaximizeCacheReuse && !ressource.isInline
|
|
865
|
-
? { fileName }
|
|
866
|
-
: {}),
|
|
867
|
-
})
|
|
868
|
-
return {
|
|
869
|
-
rollupReferenceId,
|
|
870
|
-
fileName:
|
|
871
|
-
useImportMapToMaximizeCacheReuse && !ressource.isInline
|
|
872
|
-
? fileName
|
|
873
|
-
: name,
|
|
874
|
-
}
|
|
875
|
-
},
|
|
876
|
-
onAsset: ({ ressource }) => {
|
|
877
|
-
const fileName = ressource.buildRelativeUrlWithoutHash
|
|
878
|
-
const rollupReferenceId = emitAsset({
|
|
879
|
-
fileName,
|
|
880
|
-
})
|
|
881
|
-
return {
|
|
882
|
-
rollupReferenceId,
|
|
883
|
-
fileName,
|
|
884
|
-
}
|
|
885
|
-
},
|
|
886
|
-
onAssetSourceUpdated: ({ ressource }) => {
|
|
887
|
-
setAssetSource(
|
|
888
|
-
ressource.rollupReferenceId,
|
|
889
|
-
ressource.bufferAfterBuild,
|
|
890
|
-
)
|
|
891
|
-
},
|
|
892
|
-
buildUrlGenerator,
|
|
893
|
-
},
|
|
894
|
-
)
|
|
895
|
-
|
|
896
|
-
await Promise.all(
|
|
897
|
-
entryPointsPrepared.map(
|
|
898
|
-
async ({
|
|
899
|
-
entryContentType,
|
|
900
|
-
entryProjectRelativeUrl,
|
|
901
|
-
entryBuffer,
|
|
902
|
-
}) => {
|
|
903
|
-
if (entryContentType === "application/javascript") {
|
|
904
|
-
await ressourceBuilder.createReferenceForEntryPoint({
|
|
905
|
-
entryContentType,
|
|
906
|
-
entryUrl: resolveUrl(
|
|
907
|
-
entryProjectRelativeUrl,
|
|
908
|
-
compileDirectoryServerUrl,
|
|
909
|
-
),
|
|
910
|
-
})
|
|
911
|
-
return
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
if (
|
|
915
|
-
entryContentType !== "text/html" &&
|
|
916
|
-
entryContentType !== "text/css"
|
|
917
|
-
) {
|
|
918
|
-
logger.warn(
|
|
919
|
-
`Unusual content type for entry point, got "${entryContentType}" for ${entryProjectRelativeUrl}`,
|
|
920
|
-
)
|
|
921
|
-
}
|
|
922
|
-
const entryUrl =
|
|
923
|
-
entryContentType === "text/html"
|
|
924
|
-
? resolveUrl(entryProjectRelativeUrl, compileServerOrigin)
|
|
925
|
-
: resolveUrl(entryProjectRelativeUrl, compileDirectoryServerUrl)
|
|
926
|
-
await ressourceBuilder.createReferenceForEntryPoint({
|
|
927
|
-
entryContentType,
|
|
928
|
-
entryUrl,
|
|
929
|
-
entryBuffer,
|
|
930
|
-
})
|
|
931
|
-
},
|
|
932
|
-
),
|
|
933
|
-
)
|
|
934
|
-
|
|
935
|
-
if (!atleastOneChunkEmitted) {
|
|
936
|
-
emitChunk({
|
|
937
|
-
id: EMPTY_CHUNK_URL,
|
|
938
|
-
fileName: "__empty__",
|
|
939
|
-
})
|
|
940
|
-
}
|
|
941
|
-
},
|
|
942
|
-
|
|
943
|
-
async resolveId(specifier, importer, { custom = {} } = {}) {
|
|
944
|
-
if (specifier === EMPTY_CHUNK_URL) {
|
|
945
|
-
return specifier
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
let importerUrl
|
|
949
|
-
if (importer === undefined) {
|
|
950
|
-
if (specifier.endsWith(".html")) {
|
|
951
|
-
importerUrl = compileServerOrigin
|
|
952
|
-
} else {
|
|
953
|
-
importerUrl = compileDirectoryServerUrl
|
|
954
|
-
}
|
|
955
|
-
} else {
|
|
956
|
-
importerUrl = asServerUrl(importer)
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
const { importAssertionInfo } = custom
|
|
960
|
-
const onExternal = ({ specifier, reason }) => {
|
|
961
|
-
logger.debug(`${specifier} marked as external (reason: ${reason})`)
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
if (node && isSpecifierForNodeCoreModule(specifier)) {
|
|
965
|
-
onExternal({
|
|
966
|
-
specifier,
|
|
967
|
-
reason: `node builtin module`,
|
|
968
|
-
})
|
|
969
|
-
return false
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
if (externalImportSpecifiers.includes(specifier)) {
|
|
973
|
-
onExternal({
|
|
974
|
-
specifier,
|
|
975
|
-
reason: `declared in "externalImportSpecifiers"`,
|
|
976
|
-
})
|
|
977
|
-
return { id: specifier, external: true }
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
if (inlineModuleScripts.hasOwnProperty(specifier)) {
|
|
981
|
-
return asRollupUrl(specifier)
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
const specifierUrl = await importResolver.resolveImport(
|
|
985
|
-
specifier,
|
|
986
|
-
importerUrl,
|
|
987
|
-
)
|
|
988
|
-
const existingImporter = urlImporterMap[specifierUrl]
|
|
989
|
-
if (!existingImporter) {
|
|
990
|
-
urlImporterMap[specifierUrl] = importAssertionInfo
|
|
991
|
-
? {
|
|
992
|
-
url: importerUrl,
|
|
993
|
-
column: importAssertionInfo.column,
|
|
994
|
-
line: importAssertionInfo.line,
|
|
995
|
-
}
|
|
996
|
-
: {
|
|
997
|
-
url: importerUrl,
|
|
998
|
-
// rollup do not expose a way to know line and column for the static or dynamic import
|
|
999
|
-
// referencing that file
|
|
1000
|
-
column: undefined,
|
|
1001
|
-
line: undefined,
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
// keep external url intact
|
|
1005
|
-
const specifierProjectUrl = asProjectUrl(specifierUrl)
|
|
1006
|
-
if (!specifierProjectUrl) {
|
|
1007
|
-
onExternal({
|
|
1008
|
-
specifier,
|
|
1009
|
-
reason: `outside project directory`,
|
|
1010
|
-
})
|
|
1011
|
-
return { id: specifier, external: true }
|
|
1012
|
-
}
|
|
1013
|
-
const specifierOriginalUrl = asOriginalUrl(specifierProjectUrl)
|
|
1014
|
-
const urlMeta = urlMetaGetter(specifierOriginalUrl)
|
|
1015
|
-
if (urlMeta.preserve) {
|
|
1016
|
-
if (urlMeta.remote) {
|
|
1017
|
-
specifier =
|
|
1018
|
-
jsenvRemoteDirectory.remoteUrlFromFileUrl(specifierOriginalUrl)
|
|
1019
|
-
}
|
|
1020
|
-
onExternal({
|
|
1021
|
-
specifier,
|
|
1022
|
-
reason: `matches "preservedUrls"`,
|
|
1023
|
-
})
|
|
1024
|
-
return { id: specifier, external: true }
|
|
1025
|
-
}
|
|
1026
|
-
// const rollupId = urlToRollupId(importUrl, { projectDirectoryUrl, compileServerOrigin })
|
|
1027
|
-
// logger.debug(`${specifier} imported by ${importer} resolved to ${importUrl}`)
|
|
1028
|
-
const specifierRollupUrl = asRollupUrl(specifierUrl)
|
|
1029
|
-
return specifierRollupUrl
|
|
1030
|
-
},
|
|
1031
|
-
|
|
1032
|
-
resolveFileUrl: ({ referenceId, fileName }) => {
|
|
1033
|
-
ressourcesReferencedByJs.push(fileName)
|
|
1034
|
-
const getAssetRelativeUrl = () => {
|
|
1035
|
-
const ressource = ressourceBuilder.findRessource((ressource) => {
|
|
1036
|
-
return ressource.rollupReferenceId === referenceId
|
|
1037
|
-
})
|
|
1038
|
-
ressource.buildRelativeUrlWithoutHash = fileName
|
|
1039
|
-
if (ressource.isJsModule) {
|
|
1040
|
-
return fileName
|
|
1041
|
-
}
|
|
1042
|
-
const buildRelativeUrl = ressource.buildRelativeUrl
|
|
1043
|
-
return buildRelativeUrl
|
|
1044
|
-
}
|
|
1045
|
-
if (format === "esmodule") {
|
|
1046
|
-
if (!node && useImportMapToMaximizeCacheReuse && urlVersioning) {
|
|
1047
|
-
return `window.__resolveImportUrl__("./${fileName}", import.meta.url)`
|
|
1048
|
-
}
|
|
1049
|
-
return `new URL("${getAssetRelativeUrl()}", import.meta.url)`
|
|
1050
|
-
}
|
|
1051
|
-
if (format === "systemjs") {
|
|
1052
|
-
return `new URL(System.resolve("./${fileName}", module.meta.url))`
|
|
1053
|
-
}
|
|
1054
|
-
if (format === "global") {
|
|
1055
|
-
return `new URL("${getAssetRelativeUrl()}", document.currentScript && document.currentScript.src || document.baseURI)`
|
|
1056
|
-
}
|
|
1057
|
-
if (format === "commonjs") {
|
|
1058
|
-
return `new URL("${getAssetRelativeUrl()}", "file:///" + __filename.replace(/\\/g, "/"))`
|
|
1059
|
-
}
|
|
1060
|
-
return null
|
|
1061
|
-
},
|
|
1062
|
-
|
|
1063
|
-
// https://rollupjs.org/guide/en#resolvedynamicimport
|
|
1064
|
-
// resolveDynamicImport: (specifier, importer) => {
|
|
1065
|
-
|
|
1066
|
-
// },
|
|
1067
|
-
|
|
1068
|
-
async load(rollupUrl) {
|
|
1069
|
-
if (rollupUrl === EMPTY_CHUNK_URL) {
|
|
1070
|
-
return ""
|
|
1071
|
-
}
|
|
1072
|
-
let url = asServerUrl(rollupUrl)
|
|
1073
|
-
// Jsenv helpers are injected as import statements to provide code like babel helpers
|
|
1074
|
-
// For now we just compute the information that the target file is a jsenv helper
|
|
1075
|
-
// without doing anything special with "targetIsJsenvHelperFile" information
|
|
1076
|
-
const projectUrl = asProjectUrl(rollupUrl)
|
|
1077
|
-
const originalUrl = asOriginalUrl(rollupUrl)
|
|
1078
|
-
const isJsenvHelperFile = urlIsInsideOf(
|
|
1079
|
-
originalUrl,
|
|
1080
|
-
jsenvHelpersDirectoryInfo.url,
|
|
1081
|
-
)
|
|
1082
|
-
// const isEntryPoint = entryPointUrls[originalUrl]
|
|
1083
|
-
const loadResult = await buildOperation.withSignal((signal) => {
|
|
1084
|
-
let urlToLoad
|
|
1085
|
-
const jsModuleRessource = ressourceBuilder.findRessource(
|
|
1086
|
-
(ressource) => ressource.url === url,
|
|
1087
|
-
)
|
|
1088
|
-
if (
|
|
1089
|
-
jsModuleRessource &&
|
|
1090
|
-
jsModuleRessource.firstStrongReference &&
|
|
1091
|
-
jsModuleRessource.firstStrongReference.integrity
|
|
1092
|
-
) {
|
|
1093
|
-
urlToLoad = setUrlSearchParamsDescriptor(url, {
|
|
1094
|
-
integrity: jsModuleRessource.firstStrongReference.integrity,
|
|
1095
|
-
})
|
|
1096
|
-
urlImporterMap[urlToLoad] = urlImporterMap[url]
|
|
1097
|
-
} else {
|
|
1098
|
-
urlToLoad = url
|
|
1099
|
-
}
|
|
1100
|
-
return urlLoader.loadUrl(urlToLoad, {
|
|
1101
|
-
signal,
|
|
1102
|
-
logger,
|
|
1103
|
-
})
|
|
1104
|
-
})
|
|
1105
|
-
// if (loadResult.url) url = loadResult.url
|
|
1106
|
-
const code = loadResult.code
|
|
1107
|
-
const map = loadResult.map
|
|
1108
|
-
if (jsenvRemoteDirectory.isFileUrlForRemoteUrl(originalUrl)) {
|
|
1109
|
-
map.sources.forEach((source, index) => {
|
|
1110
|
-
if (jsenvRemoteDirectory.isRemoteUrl(source)) {
|
|
1111
|
-
const sourceFileUrl =
|
|
1112
|
-
jsenvRemoteDirectory.fileUrlFromRemoteUrl(source)
|
|
1113
|
-
const sourceRelativeUrl = urlToRelativeUrl(
|
|
1114
|
-
sourceFileUrl,
|
|
1115
|
-
projectUrl,
|
|
1116
|
-
)
|
|
1117
|
-
map.sources[index] = sourceRelativeUrl
|
|
1118
|
-
}
|
|
1119
|
-
})
|
|
1120
|
-
}
|
|
1121
|
-
const importer = urlImporterMap[url]
|
|
1122
|
-
// Inform ressource builder that this js module exists
|
|
1123
|
-
// It can only be a js module and happens when:
|
|
1124
|
-
// - entry point (html) references js
|
|
1125
|
-
// - js is referenced by static or dynamic imports
|
|
1126
|
-
// For import assertions, the imported ressource (css,json,...)
|
|
1127
|
-
// is already converted to a js module
|
|
1128
|
-
ressourceBuilder.createReferenceFoundByRollup({
|
|
1129
|
-
contentTypeExpected: "application/javascript",
|
|
1130
|
-
referenceLabel: "static or dynamic import",
|
|
1131
|
-
referenceUrl: importer.url,
|
|
1132
|
-
referenceColumn: importer.column,
|
|
1133
|
-
referenceLine: importer.line,
|
|
1134
|
-
ressourceSpecifier: url,
|
|
1135
|
-
isJsenvHelperFile,
|
|
1136
|
-
contentType: "application/javascript",
|
|
1137
|
-
isJsModule: true,
|
|
1138
|
-
bufferBeforeBuild: Buffer.from(code),
|
|
1139
|
-
})
|
|
1140
|
-
return {
|
|
1141
|
-
code,
|
|
1142
|
-
map,
|
|
1143
|
-
}
|
|
1144
|
-
},
|
|
1145
|
-
|
|
1146
|
-
async transform(code, id) {
|
|
1147
|
-
let map = null
|
|
1148
|
-
// we should try/catch here?
|
|
1149
|
-
// because this.parse might fail
|
|
1150
|
-
const ast = this.parse(code, {
|
|
1151
|
-
// used to know node line and column
|
|
1152
|
-
locations: true,
|
|
1153
|
-
})
|
|
1154
|
-
// const moduleInfo = this.getModuleInfo(id)
|
|
1155
|
-
const url = asServerUrl(id)
|
|
1156
|
-
const mutations = []
|
|
1157
|
-
await visitImportReferences({
|
|
1158
|
-
ast,
|
|
1159
|
-
onReferenceWithImportMetaUrlPattern: async ({ importNode }) => {
|
|
1160
|
-
const specifier = importNode.arguments[0].value
|
|
1161
|
-
const { line, column } = importNode.loc.start
|
|
1162
|
-
const { id } = normalizeRollupResolveReturnValue(
|
|
1163
|
-
await this.resolve(specifier, url),
|
|
1164
|
-
)
|
|
1165
|
-
const ressourceUrl = asServerUrl(id)
|
|
1166
|
-
const reference = ressourceBuilder.createReferenceFoundInJsModule({
|
|
1167
|
-
referenceLabel: "URL + import.meta.url",
|
|
1168
|
-
jsUrl: url,
|
|
1169
|
-
jsLine: line,
|
|
1170
|
-
jsColumn: column,
|
|
1171
|
-
ressourceSpecifier: ressourceUrl,
|
|
1172
|
-
})
|
|
1173
|
-
if (!reference) {
|
|
1174
|
-
return
|
|
1175
|
-
}
|
|
1176
|
-
if (!reference.ressource.isJsModule) {
|
|
1177
|
-
// so that ressource.buildRelativeUrl is known during "resolveFileUrl" hook`
|
|
1178
|
-
await reference.ressource.getReadyPromise()
|
|
1179
|
-
}
|
|
1180
|
-
mutations.push((magicString) => {
|
|
1181
|
-
magicString.overwrite(
|
|
1182
|
-
importNode.start,
|
|
1183
|
-
importNode.end,
|
|
1184
|
-
referenceToCodeForRollup(reference),
|
|
1185
|
-
)
|
|
1186
|
-
})
|
|
1187
|
-
},
|
|
1188
|
-
onReferenceWithImportAssertion: async ({
|
|
1189
|
-
importNode,
|
|
1190
|
-
typePropertyNode,
|
|
1191
|
-
assertions,
|
|
1192
|
-
}) => {
|
|
1193
|
-
const { source } = importNode
|
|
1194
|
-
const importSpecifier = source.value
|
|
1195
|
-
const { line, column } = importNode.loc.start
|
|
1196
|
-
// "type" is dynamic on dynamic import such as
|
|
1197
|
-
// import("./data.json", {
|
|
1198
|
-
// assert: {
|
|
1199
|
-
// type: true ? "json" : "css"
|
|
1200
|
-
// }
|
|
1201
|
-
// })
|
|
1202
|
-
if (typePropertyNode) {
|
|
1203
|
-
const typePropertyValue = typePropertyNode.value
|
|
1204
|
-
if (typePropertyValue.type !== "Literal") {
|
|
1205
|
-
if (importAssertionSupportedByRuntime) {
|
|
1206
|
-
return // keep untouched
|
|
1207
|
-
}
|
|
1208
|
-
throw new Error(
|
|
1209
|
-
createDetailedMessage(
|
|
1210
|
-
`Dynamic "type" not supported for dynamic import assertion`,
|
|
1211
|
-
{
|
|
1212
|
-
"import assertion trace": stringifyUrlTrace(
|
|
1213
|
-
urlLoader.createUrlTrace({ url, line, column }),
|
|
1214
|
-
),
|
|
1215
|
-
},
|
|
1216
|
-
),
|
|
1217
|
-
)
|
|
1218
|
-
}
|
|
1219
|
-
assertions = {
|
|
1220
|
-
type: typePropertyValue.value,
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
const { type } = assertions
|
|
1224
|
-
// "specifier" is dynamic on dynamic import such as
|
|
1225
|
-
// import(true ? "./a.json" : "b.json", {
|
|
1226
|
-
// assert: {
|
|
1227
|
-
// type: "json"
|
|
1228
|
-
// }
|
|
1229
|
-
// })
|
|
1230
|
-
const importAssertionSupportedByRuntime =
|
|
1231
|
-
importAssertionsSupport[type]
|
|
1232
|
-
if (source.type !== "Literal") {
|
|
1233
|
-
if (importAssertionSupportedByRuntime) {
|
|
1234
|
-
return // keep untouched
|
|
1235
|
-
}
|
|
1236
|
-
throw new Error(
|
|
1237
|
-
createDetailedMessage(
|
|
1238
|
-
`Dynamic specifier not supported for dynamic import assertion`,
|
|
1239
|
-
{
|
|
1240
|
-
"import assertion trace": stringifyUrlTrace(
|
|
1241
|
-
urlLoader.createUrlTrace({ url, line, column }),
|
|
1242
|
-
),
|
|
1243
|
-
},
|
|
1244
|
-
),
|
|
1245
|
-
)
|
|
1246
|
-
}
|
|
1247
|
-
// There is no strategy for css import assertion on Node.js
|
|
1248
|
-
if (type === "css" && node) {
|
|
1249
|
-
throw new Error(
|
|
1250
|
-
createDetailedMessage(
|
|
1251
|
-
`{ type: "css" } is not supported when "node" is part of "runtimeSupport"`,
|
|
1252
|
-
{
|
|
1253
|
-
"import assertion trace": stringifyUrlTrace(
|
|
1254
|
-
urlLoader.createUrlTrace({ url, line, column }),
|
|
1255
|
-
),
|
|
1256
|
-
},
|
|
1257
|
-
),
|
|
1258
|
-
)
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
const { id, external } = normalizeRollupResolveReturnValue(
|
|
1262
|
-
await this.resolve(importSpecifier, url, {
|
|
1263
|
-
custom: {
|
|
1264
|
-
importAssertionInfo: {
|
|
1265
|
-
line,
|
|
1266
|
-
column,
|
|
1267
|
-
type,
|
|
1268
|
-
supportedByRuntime: importAssertionSupportedByRuntime,
|
|
1269
|
-
},
|
|
1270
|
-
},
|
|
1271
|
-
}),
|
|
1272
|
-
)
|
|
1273
|
-
// remove import
|
|
1274
|
-
let ressourceUrl = asServerUrl(id)
|
|
1275
|
-
// lod the asset without ?import_type in it
|
|
1276
|
-
ressourceUrl = ressourceUrl.replace(`?import_type=${type}`, "")
|
|
1277
|
-
const fileReference = ressourceBuilder.createReferenceFoundInJsModule(
|
|
1278
|
-
{
|
|
1279
|
-
referenceLabel: `${type} import assertion`,
|
|
1280
|
-
// If all references to a ressource are only import assertions
|
|
1281
|
-
// the file referenced do not need to be written on filesystem
|
|
1282
|
-
// as it was converted to a js file
|
|
1283
|
-
// We pass "isImportAssertion: true" for this purpose
|
|
1284
|
-
isImportAssertion: true,
|
|
1285
|
-
jsUrl: url,
|
|
1286
|
-
jsLine: line,
|
|
1287
|
-
jsColumn: column,
|
|
1288
|
-
ressourceSpecifier: ressourceUrl,
|
|
1289
|
-
contentTypeExpected:
|
|
1290
|
-
type === "css" ? "text/css" : "application/json",
|
|
1291
|
-
},
|
|
1292
|
-
)
|
|
1293
|
-
// reference can be null for cross origin urls
|
|
1294
|
-
if (!fileReference) {
|
|
1295
|
-
return
|
|
1296
|
-
}
|
|
1297
|
-
if (external && !importAssertionSupportedByRuntime) {
|
|
1298
|
-
throw new Error(
|
|
1299
|
-
createDetailedMessage(
|
|
1300
|
-
`import assertion ressource cannot be external when runtime do not support import assertions`,
|
|
1301
|
-
{
|
|
1302
|
-
"import assertion trace": stringifyUrlTrace(
|
|
1303
|
-
urlLoader.createUrlTrace({ url, line, column }),
|
|
1304
|
-
),
|
|
1305
|
-
},
|
|
1306
|
-
),
|
|
1307
|
-
)
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
// await fileReference.ressource.getReadyPromise()
|
|
1311
|
-
// once the file is ready, we know its buildRelativeUrl
|
|
1312
|
-
// we can update either to the fileName or buildRelativeUrl
|
|
1313
|
-
// should be use the rollup reference id?
|
|
1314
|
-
const ressourceUrlAsJsModule = resolveUrl(
|
|
1315
|
-
`${urlToBasename(
|
|
1316
|
-
ressourceUrl,
|
|
1317
|
-
)}${outputExtension}?import_type=${type}`,
|
|
1318
|
-
ressourceUrl,
|
|
1319
|
-
)
|
|
1320
|
-
const jsUrl = url
|
|
1321
|
-
urlCustomLoaders[ressourceUrlAsJsModule] = async () => {
|
|
1322
|
-
let code
|
|
1323
|
-
let map
|
|
1324
|
-
|
|
1325
|
-
if (type === "json") {
|
|
1326
|
-
await fileReference.ressource.getReadyPromise()
|
|
1327
|
-
code = String(fileReference.ressource.bufferAfterBuild)
|
|
1328
|
-
const jsModuleConversionResult =
|
|
1329
|
-
await convertJsonTextToJavascriptModule({
|
|
1330
|
-
code,
|
|
1331
|
-
map,
|
|
1332
|
-
})
|
|
1333
|
-
code = jsModuleConversionResult.code
|
|
1334
|
-
map = jsModuleConversionResult.map
|
|
1335
|
-
} else if (type === "css") {
|
|
1336
|
-
await fileReference.ressource.getReadyPromise()
|
|
1337
|
-
const cssBuildUrl = resolveUrl(
|
|
1338
|
-
fileReference.ressource.buildRelativeUrl,
|
|
1339
|
-
buildDirectoryUrl,
|
|
1340
|
-
)
|
|
1341
|
-
const jsBuildUrl = resolveUrl(
|
|
1342
|
-
urlToFilename(jsUrl),
|
|
1343
|
-
buildDirectoryUrl,
|
|
1344
|
-
)
|
|
1345
|
-
code = String(fileReference.ressource.bufferAfterBuild)
|
|
1346
|
-
const sourcemapReference =
|
|
1347
|
-
fileReference.ressource.dependencies.find((dependency) => {
|
|
1348
|
-
return dependency.ressource.isSourcemap
|
|
1349
|
-
})
|
|
1350
|
-
if (sourcemapReference) {
|
|
1351
|
-
// because css is ready, it's sourcemap is also ready
|
|
1352
|
-
// we can read directly sourcemapReference.ressource.bufferAfterBuild
|
|
1353
|
-
map = JSON.parse(sourcemapReference.ressource.bufferAfterBuild)
|
|
1354
|
-
}
|
|
1355
|
-
const jsModuleConversionResult =
|
|
1356
|
-
await convertCssTextToJavascriptModule({
|
|
1357
|
-
cssUrl: cssBuildUrl,
|
|
1358
|
-
jsUrl: jsBuildUrl,
|
|
1359
|
-
code,
|
|
1360
|
-
map,
|
|
1361
|
-
})
|
|
1362
|
-
code = jsModuleConversionResult.code
|
|
1363
|
-
map = jsModuleConversionResult.map
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
return { code, map }
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
mutations.push((magicString) => {
|
|
1370
|
-
magicString.overwrite(
|
|
1371
|
-
importNode.source.start,
|
|
1372
|
-
importNode.source.end,
|
|
1373
|
-
`"${ressourceUrlAsJsModule}"`,
|
|
1374
|
-
)
|
|
1375
|
-
if (typePropertyNode) {
|
|
1376
|
-
magicString.remove(typePropertyNode.start, typePropertyNode.end)
|
|
1377
|
-
}
|
|
1378
|
-
})
|
|
1379
|
-
},
|
|
1380
|
-
})
|
|
1381
|
-
if (mutations.length > 0) {
|
|
1382
|
-
const magicString = new MagicString(code)
|
|
1383
|
-
mutations.forEach((mutation) => {
|
|
1384
|
-
mutation(magicString)
|
|
1385
|
-
})
|
|
1386
|
-
code = magicString.toString()
|
|
1387
|
-
map = magicString.generateMap({ hires: true })
|
|
1388
|
-
}
|
|
1389
|
-
return { code, map }
|
|
1390
|
-
},
|
|
1391
|
-
|
|
1392
|
-
// resolveImportMeta: () => {}
|
|
1393
|
-
outputOptions: (outputOptions) => {
|
|
1394
|
-
outputOptions.paths = (id) => {
|
|
1395
|
-
const mapping = importPaths[id]
|
|
1396
|
-
if (mapping) {
|
|
1397
|
-
return mapping
|
|
1398
|
-
}
|
|
1399
|
-
if (format === "commonjs") {
|
|
1400
|
-
if (id.startsWith("node:")) {
|
|
1401
|
-
return id.slice("node:".length)
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
return id
|
|
1405
|
-
}
|
|
1406
|
-
// outputOptions.assetFileNames = () => {
|
|
1407
|
-
// return `assets/[name]_[hash][extname]`
|
|
1408
|
-
// }
|
|
1409
|
-
outputOptions.entryFileNames = () => {
|
|
1410
|
-
if (useImportMapToMaximizeCacheReuse) {
|
|
1411
|
-
return `[name]${outputExtension}`
|
|
1412
|
-
}
|
|
1413
|
-
return entryPoints
|
|
1414
|
-
}
|
|
1415
|
-
outputOptions.chunkFileNames = (chunkInfo) => {
|
|
1416
|
-
// maybe we should find ressource from ressource builder and return
|
|
1417
|
-
// the buildRelativeUrlPattern?
|
|
1418
|
-
|
|
1419
|
-
// const originalUrl = asOriginalUrl(chunkInfo.facadeModuleId)
|
|
1420
|
-
// const basename = urlToBasename(originalUrl)
|
|
1421
|
-
if (useImportMapToMaximizeCacheReuse) {
|
|
1422
|
-
return `[name]${outputExtension}`
|
|
1423
|
-
}
|
|
1424
|
-
if (chunkInfo.isEntry) {
|
|
1425
|
-
const originalUrl = asOriginalUrl(chunkInfo.facadeModuleId)
|
|
1426
|
-
const entryPointPattern = entryPointUrls[originalUrl]
|
|
1427
|
-
if (entryPointPattern) {
|
|
1428
|
-
return entryPointPattern
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
return urlVersioning
|
|
1432
|
-
? `[name]_[hash]${outputExtension}`
|
|
1433
|
-
: `[name]${outputExtension}`
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
const getStringAfter = (string, substring) => {
|
|
1437
|
-
const index = string.indexOf(substring)
|
|
1438
|
-
if (index === -1) return ""
|
|
1439
|
-
return string.slice(index + substring.length)
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
// rollup does not expects to have http dependency in the mix: fix them
|
|
1443
|
-
outputOptions.sourcemapPathTransform = (relativePath, sourcemapPath) => {
|
|
1444
|
-
const sourcemapUrl = fileSystemPathToUrl(sourcemapPath)
|
|
1445
|
-
// here relativePath contains a protocol
|
|
1446
|
-
// because rollup don't work with url but with filesystem paths
|
|
1447
|
-
// let fix it below
|
|
1448
|
-
const sourceRollupUrlRaw = resolveUrl(relativePath, sourcemapUrl)
|
|
1449
|
-
const afterOrigin =
|
|
1450
|
-
getStringAfter(sourceRollupUrlRaw, "http:/jsenv.com") ||
|
|
1451
|
-
getStringAfter(sourceRollupUrlRaw, "https:/jsenv.com")
|
|
1452
|
-
const sourceRollupUrl = afterOrigin
|
|
1453
|
-
? `${compileServerOriginForRollup}${afterOrigin}`
|
|
1454
|
-
: sourceRollupUrlRaw
|
|
1455
|
-
|
|
1456
|
-
const sourceServerUrl = asServerUrl(sourceRollupUrl)
|
|
1457
|
-
const sourceUrl =
|
|
1458
|
-
urlFetcher.getUrlBeforeRedirection(sourceServerUrl) || sourceServerUrl
|
|
1459
|
-
const sourceProjectUrl = asProjectUrl(sourceUrl)
|
|
1460
|
-
|
|
1461
|
-
if (jsenvRemoteDirectory.isFileUrlForRemoteUrl(sourceProjectUrl)) {
|
|
1462
|
-
const remoteUrl =
|
|
1463
|
-
jsenvRemoteDirectory.remoteUrlFromFileUrl(sourceProjectUrl)
|
|
1464
|
-
return remoteUrl
|
|
1465
|
-
}
|
|
1466
|
-
if (sourceProjectUrl) {
|
|
1467
|
-
relativePath = urlToRelativeUrl(sourceProjectUrl, sourcemapUrl)
|
|
1468
|
-
return relativePath
|
|
1469
|
-
}
|
|
1470
|
-
return sourceUrl
|
|
1471
|
-
}
|
|
1472
|
-
return outputOptions
|
|
1473
|
-
},
|
|
1474
|
-
|
|
1475
|
-
async renderChunk(code, chunk) {
|
|
1476
|
-
const { facadeModuleId } = chunk
|
|
1477
|
-
if (!facadeModuleId) {
|
|
1478
|
-
// happens for inline module scripts for instance
|
|
1479
|
-
return null
|
|
1480
|
-
}
|
|
1481
|
-
const url = asOriginalUrl(facadeModuleId)
|
|
1482
|
-
const { searchParams } = new URL(url)
|
|
1483
|
-
if (
|
|
1484
|
-
format === "systemjs" &&
|
|
1485
|
-
(searchParams.has("worker") || searchParams.has("service_worker"))
|
|
1486
|
-
) {
|
|
1487
|
-
const magicString = new MagicString(code)
|
|
1488
|
-
const systemjsCode = await readFile(
|
|
1489
|
-
new URL("../runtime_client/s.js", import.meta.url),
|
|
1490
|
-
)
|
|
1491
|
-
magicString.prepend(systemjsCode)
|
|
1492
|
-
code = magicString.toString()
|
|
1493
|
-
const map = magicString.generateMap({ hires: true })
|
|
1494
|
-
return {
|
|
1495
|
-
code,
|
|
1496
|
-
map,
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
return null
|
|
1500
|
-
},
|
|
1501
|
-
|
|
1502
|
-
async generateBundle(outputOptions, rollupResult) {
|
|
1503
|
-
// it's important to do this to emit late asset
|
|
1504
|
-
rollupEmitFile = (...args) => this.emitFile(...args)
|
|
1505
|
-
rollupSetAssetSource = (...args) => this.setAssetSource(...args)
|
|
1506
|
-
// To keep in mind: rollupResult object can be mutated by late asset emission
|
|
1507
|
-
// however late chunk (js module) emission is not possible
|
|
1508
|
-
// as rollup rightfully prevent late js emission
|
|
1509
|
-
Object.keys(rollupResult).forEach((fileName) => {
|
|
1510
|
-
const rollupFileInfo = rollupResult[fileName]
|
|
1511
|
-
// there is 3 types of file: "placeholder", "asset", "chunk"
|
|
1512
|
-
if (rollupFileInfo.type === "chunk") {
|
|
1513
|
-
const { facadeModuleId } = rollupFileInfo
|
|
1514
|
-
if (facadeModuleId === EMPTY_CHUNK_URL) {
|
|
1515
|
-
delete rollupResult[fileName]
|
|
1516
|
-
return
|
|
1517
|
-
}
|
|
1518
|
-
if (facadeModuleId) {
|
|
1519
|
-
rollupFileInfo.url = asServerUrl(facadeModuleId)
|
|
1520
|
-
} else {
|
|
1521
|
-
const sourcePath =
|
|
1522
|
-
rollupFileInfo.map.sources[rollupFileInfo.map.sources.length - 1]
|
|
1523
|
-
const fileBuildUrl = resolveUrl(fileName, buildDirectoryUrl)
|
|
1524
|
-
const originalProjectUrl = resolveUrl(sourcePath, fileBuildUrl)
|
|
1525
|
-
rollupFileInfo.url = asCompiledServerUrl(originalProjectUrl, {
|
|
1526
|
-
projectDirectoryUrl,
|
|
1527
|
-
compileServerOrigin,
|
|
1528
|
-
compileDirectoryRelativeUrl,
|
|
1529
|
-
})
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
if (
|
|
1533
|
-
rollupFileInfo.url in inlineModuleScripts &&
|
|
1534
|
-
format === "systemjs"
|
|
1535
|
-
) {
|
|
1536
|
-
const code = rollupFileInfo.code
|
|
1537
|
-
const systemRegisterIndex = code.indexOf("System.register([")
|
|
1538
|
-
const magicString = new MagicString(code)
|
|
1539
|
-
magicString.overwrite(
|
|
1540
|
-
systemRegisterIndex,
|
|
1541
|
-
systemRegisterIndex + "System.register([".length,
|
|
1542
|
-
`System.register("${fileName}", [`,
|
|
1543
|
-
)
|
|
1544
|
-
rollupFileInfo.code = magicString.toString()
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
const jsRessource = ressourceBuilder.findRessource((ressource) => {
|
|
1548
|
-
return ressource.url === rollupFileInfo.url
|
|
1549
|
-
})
|
|
1550
|
-
if (
|
|
1551
|
-
isReferencedByJs({
|
|
1552
|
-
rollupFileInfo,
|
|
1553
|
-
jsConcatenation,
|
|
1554
|
-
jsRessource,
|
|
1555
|
-
})
|
|
1556
|
-
) {
|
|
1557
|
-
ressourcesReferencedByJs.push(fileName)
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
})
|
|
1561
|
-
|
|
1562
|
-
// malheureusement rollup ne permet pas de savoir lorsqu'un chunk
|
|
1563
|
-
// a fini d'etre résolu (parsing des imports statiques et dynamiques recursivement)
|
|
1564
|
-
// donc lorsque le build se termine on va indiquer
|
|
1565
|
-
// aux assets faisant référence a ces chunk js qu'ils sont terminés
|
|
1566
|
-
// et donc les assets peuvent connaitre le nom du chunk
|
|
1567
|
-
// et mettre a jour leur dépendance vers ce fichier js
|
|
1568
|
-
const { jsRessources } = ressourceBuilder.rollupBuildEnd({
|
|
1569
|
-
rollupResult,
|
|
1570
|
-
useImportMapToMaximizeCacheReuse,
|
|
1571
|
-
})
|
|
1572
|
-
Object.keys(jsRessources).forEach((ressourceUrl) => {
|
|
1573
|
-
const jsRessource = jsRessources[ressourceUrl]
|
|
1574
|
-
if (jsRessource.isInline) {
|
|
1575
|
-
buildInlineFileContents[jsRessource.buildRelativeUrl] =
|
|
1576
|
-
jsRessource.bufferAfterBuild
|
|
1577
|
-
// if (format === "systemjs") {
|
|
1578
|
-
// ressourcesReferencedByJs.push(jsRessource.fileName)
|
|
1579
|
-
// }
|
|
1580
|
-
} else {
|
|
1581
|
-
const originalProjectUrl = asOriginalUrl(ressourceUrl)
|
|
1582
|
-
if (jsenvRemoteDirectory.isFileUrlForRemoteUrl(originalProjectUrl)) {
|
|
1583
|
-
const remoteUrl =
|
|
1584
|
-
jsenvRemoteDirectory.remoteUrlFromFileUrl(originalProjectUrl)
|
|
1585
|
-
buildMappings[remoteUrl] = jsRessource.buildRelativeUrl
|
|
1586
|
-
} else {
|
|
1587
|
-
const originalProjectRelativeUrl = urlToRelativeUrl(
|
|
1588
|
-
originalProjectUrl,
|
|
1589
|
-
projectDirectoryUrl,
|
|
1590
|
-
)
|
|
1591
|
-
buildMappings[originalProjectRelativeUrl] =
|
|
1592
|
-
jsRessource.buildRelativeUrl
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
ressourceMappings[jsRessource.buildRelativeUrlWithoutHash] =
|
|
1596
|
-
jsRessource.buildRelativeUrl
|
|
1597
|
-
})
|
|
1598
|
-
// wait for asset build relative urls
|
|
1599
|
-
// to ensure the importmap will contain remappings for them
|
|
1600
|
-
// (not sure this is required anymore)
|
|
1601
|
-
await Promise.all(
|
|
1602
|
-
ressourcesReferencedByJs.map(async (ressourceFileName) => {
|
|
1603
|
-
const ressource = ressourceBuilder.findRessource((ressource) => {
|
|
1604
|
-
return ressource.buildRelativeUrlWithoutHash === ressourceFileName
|
|
1605
|
-
})
|
|
1606
|
-
if (ressource && !ressource.isJsModule) {
|
|
1607
|
-
await ressource.getReadyPromise()
|
|
1608
|
-
ressourceMappings[ressource.buildRelativeUrlWithoutHash] =
|
|
1609
|
-
ressource.buildRelativeUrl
|
|
1610
|
-
}
|
|
1611
|
-
}),
|
|
1612
|
-
)
|
|
1613
|
-
// wait html files to be emitted
|
|
1614
|
-
await ressourceBuilder.getAllEntryPointsEmittedPromise()
|
|
1615
|
-
onBundleEnd()
|
|
1616
|
-
|
|
1617
|
-
const jsModuleBuild = {}
|
|
1618
|
-
const assetBuild = {}
|
|
1619
|
-
Object.keys(rollupResult).forEach((fileName) => {
|
|
1620
|
-
const rollupFileInfo = rollupResult[fileName]
|
|
1621
|
-
|
|
1622
|
-
if (rollupFileInfo.type === "chunk") {
|
|
1623
|
-
const jsRessource = ressourceBuilder.findRessource((ressource) => {
|
|
1624
|
-
return ressource.url === rollupFileInfo.url
|
|
1625
|
-
})
|
|
1626
|
-
jsModuleBuild[jsRessource.buildRelativeUrl] = rollupFileInfo
|
|
1627
|
-
return
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
if (rollupFileInfo.type === "asset") {
|
|
1631
|
-
const assetRessource = ressourceBuilder.findRessource(
|
|
1632
|
-
(ressource) =>
|
|
1633
|
-
// happens for import.meta.url pattern
|
|
1634
|
-
ressource.buildRelativeUrlWithoutHash === fileName ||
|
|
1635
|
-
// happens for sourcemap
|
|
1636
|
-
ressource.relativeUrl === fileName,
|
|
1637
|
-
)
|
|
1638
|
-
// ignore potential useless assets which happens when:
|
|
1639
|
-
// - sourcemap re-emitted
|
|
1640
|
-
// - importmap re-emitted to have buildRelativeUrlMap
|
|
1641
|
-
if (assetRessource.shouldBeIgnored) {
|
|
1642
|
-
return
|
|
1643
|
-
}
|
|
1644
|
-
// Ignore file only referenced by import assertions
|
|
1645
|
-
// - if file is referenced by import assertion and html or import meta url
|
|
1646
|
-
// then source file is duplicated. If concatenation is disabled
|
|
1647
|
-
// and import assertions are supported, the file is still converted to js module
|
|
1648
|
-
const isReferencedOnlyByImportAssertions =
|
|
1649
|
-
assetRessource.references.every((reference) => {
|
|
1650
|
-
return reference.isImportAssertion
|
|
1651
|
-
})
|
|
1652
|
-
if (isReferencedOnlyByImportAssertions) {
|
|
1653
|
-
return
|
|
1654
|
-
}
|
|
1655
|
-
const buildRelativeUrl = assetRessource.buildRelativeUrl
|
|
1656
|
-
if (assetRessource.isInline) {
|
|
1657
|
-
buildInlineFileContents[buildRelativeUrl] = rollupFileInfo.source
|
|
1658
|
-
return
|
|
1659
|
-
}
|
|
1660
|
-
// in case sourcemap is mutated, we must not trust rollup but the asset builder source instead
|
|
1661
|
-
rollupFileInfo.source = assetRessource.bufferAfterBuild
|
|
1662
|
-
assetBuild[buildRelativeUrl] = rollupFileInfo
|
|
1663
|
-
ressourceMappings[assetRessource.buildRelativeUrlWithoutHash] =
|
|
1664
|
-
buildRelativeUrl
|
|
1665
|
-
if (assetRessource.bufferBeforeBuild) {
|
|
1666
|
-
const originalProjectUrl = asOriginalUrl(assetRessource.url)
|
|
1667
|
-
const originalProjectRelativeUrl = urlToRelativeUrl(
|
|
1668
|
-
originalProjectUrl,
|
|
1669
|
-
projectDirectoryUrl,
|
|
1670
|
-
)
|
|
1671
|
-
buildMappings[originalProjectRelativeUrl] = buildRelativeUrl
|
|
1672
|
-
}
|
|
1673
|
-
return
|
|
1674
|
-
}
|
|
1675
|
-
})
|
|
1676
|
-
rollupBuild = {
|
|
1677
|
-
...jsModuleBuild,
|
|
1678
|
-
...assetBuild,
|
|
1679
|
-
}
|
|
1680
|
-
rollupBuild = sortObjectByPathnames(rollupBuild)
|
|
1681
|
-
// fill "buildFileContents", "buildInlineFilesContents"
|
|
1682
|
-
// and update "buildMappings"
|
|
1683
|
-
// in case some ressource where inlined by ressourceBuilder.rollupBuildEnd
|
|
1684
|
-
Object.keys(rollupBuild).forEach((buildRelativeUrl) => {
|
|
1685
|
-
const rollupFileInfo = rollupBuild[buildRelativeUrl]
|
|
1686
|
-
const ressource = ressourceBuilder.findRessource((ressource) => {
|
|
1687
|
-
if (ressource.buildRelativeUrl === buildRelativeUrl) {
|
|
1688
|
-
return true
|
|
1689
|
-
}
|
|
1690
|
-
if (ressource.url === rollupFileInfo.url) {
|
|
1691
|
-
return true
|
|
1692
|
-
}
|
|
1693
|
-
return false
|
|
1694
|
-
})
|
|
1695
|
-
if (ressource.isInline) {
|
|
1696
|
-
if (ressource.isJsModule) {
|
|
1697
|
-
delete jsModuleBuild[buildRelativeUrl]
|
|
1698
|
-
} else {
|
|
1699
|
-
delete assetBuild[buildRelativeUrl]
|
|
1700
|
-
}
|
|
1701
|
-
const originalProjectUrl = asOriginalUrl(ressource.url)
|
|
1702
|
-
const originalRelativeUrl = urlToRelativeUrl(
|
|
1703
|
-
originalProjectUrl,
|
|
1704
|
-
projectDirectoryUrl,
|
|
1705
|
-
)
|
|
1706
|
-
delete buildMappings[originalRelativeUrl]
|
|
1707
|
-
buildInlineFileContents[ressource.buildRelativeUrl] =
|
|
1708
|
-
ressource.bufferAfterBuild
|
|
1709
|
-
} else {
|
|
1710
|
-
buildFileContents[ressource.buildRelativeUrl] =
|
|
1711
|
-
ressource.bufferAfterBuild
|
|
1712
|
-
}
|
|
1713
|
-
})
|
|
1714
|
-
|
|
1715
|
-
ressourceMappings = sortObjectByPathnames(ressourceMappings)
|
|
1716
|
-
buildMappings = sortObjectByPathnames(buildMappings)
|
|
1717
|
-
await visitServiceWorkers({
|
|
1718
|
-
projectDirectoryUrl,
|
|
1719
|
-
serviceWorkerFinalizer,
|
|
1720
|
-
serviceWorkerUrls,
|
|
1721
|
-
classicServiceWorkerUrls,
|
|
1722
|
-
buildMappings,
|
|
1723
|
-
ressourceMappings,
|
|
1724
|
-
buildFileContents,
|
|
1725
|
-
lineBreakNormalization,
|
|
1726
|
-
})
|
|
1727
|
-
const buildDuration = Date.now() - buildStartMs
|
|
1728
|
-
buildStats = createBuildStats({
|
|
1729
|
-
buildFileContents,
|
|
1730
|
-
ressourceBuilder,
|
|
1731
|
-
buildDuration,
|
|
1732
|
-
})
|
|
1733
|
-
logger.info(
|
|
1734
|
-
formatBuildDoneInfo({
|
|
1735
|
-
buildStats,
|
|
1736
|
-
buildDirectoryRelativeUrl: urlToRelativeUrl(
|
|
1737
|
-
buildDirectoryUrl,
|
|
1738
|
-
projectDirectoryUrl,
|
|
1739
|
-
),
|
|
1740
|
-
}),
|
|
1741
|
-
)
|
|
1742
|
-
},
|
|
1743
|
-
})
|
|
1744
|
-
|
|
1745
|
-
const fetchImportMapFromUrl = async (importMapUrl, importer) => {
|
|
1746
|
-
const importMapResponse = await urlFetcher.fetchUrl(importMapUrl, {
|
|
1747
|
-
urlTrace: importer,
|
|
1748
|
-
contentTypeExpected: "application/importmap+json",
|
|
1749
|
-
})
|
|
1750
|
-
const importMap = await importMapResponse.json()
|
|
1751
|
-
const importMapNormalized = normalizeImportMap(
|
|
1752
|
-
importMap,
|
|
1753
|
-
importMapResponse.url,
|
|
1754
|
-
)
|
|
1755
|
-
return importMapNormalized
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
return {
|
|
1759
|
-
rollupPlugins,
|
|
1760
|
-
getLastErrorMessage: () => lastErrorMessage,
|
|
1761
|
-
getResult: async () => {
|
|
1762
|
-
return {
|
|
1763
|
-
rollupBuild,
|
|
1764
|
-
urlResponseBodyMap: urlLoader.getUrlResponseBodyMap(),
|
|
1765
|
-
buildMappings,
|
|
1766
|
-
ressourceMappings,
|
|
1767
|
-
// Object mapping build relative urls without hash to build relative urls
|
|
1768
|
-
buildManifest: createBuildManifest({
|
|
1769
|
-
buildFileContents,
|
|
1770
|
-
}),
|
|
1771
|
-
buildImportMap: createImportMapForFilesUsedInJs(),
|
|
1772
|
-
buildFileContents,
|
|
1773
|
-
buildInlineFileContents,
|
|
1774
|
-
buildStats,
|
|
1775
|
-
}
|
|
1776
|
-
},
|
|
1777
|
-
asOriginalUrl,
|
|
1778
|
-
asProjectUrl,
|
|
1779
|
-
rollupGetModuleInfo,
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
const createBuildManifest = ({ buildFileContents }) => {
|
|
1784
|
-
const buildManifest = {}
|
|
1785
|
-
Object.keys(buildFileContents).forEach((buildRelativeUrl) => {
|
|
1786
|
-
const relativeUrlWithoutHash = asFileNameWithoutHash(buildRelativeUrl)
|
|
1787
|
-
buildManifest[relativeUrlWithoutHash] = buildRelativeUrl
|
|
1788
|
-
})
|
|
1789
|
-
return buildManifest
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
const asFileNameWithoutHash = (fileName) => {
|
|
1793
|
-
return fileName.replace(/_[a-z0-9]{8,}(\..*?)?$/, (_, afterHash = "") => {
|
|
1794
|
-
return afterHash
|
|
1795
|
-
})
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
const prepareEntryPoints = async (
|
|
1799
|
-
entryPoints,
|
|
1800
|
-
{
|
|
1801
|
-
logger,
|
|
1802
|
-
projectDirectoryUrl,
|
|
1803
|
-
buildDirectoryUrl,
|
|
1804
|
-
compileServerOrigin,
|
|
1805
|
-
urlFetcher,
|
|
1806
|
-
},
|
|
1807
|
-
) => {
|
|
1808
|
-
const entryFileRelativeUrls = Object.keys(entryPoints)
|
|
1809
|
-
const entryPointsPrepared = []
|
|
1810
|
-
await entryFileRelativeUrls.reduce(async (previous, entryFileRelativeUrl) => {
|
|
1811
|
-
await previous
|
|
1812
|
-
|
|
1813
|
-
const entryProjectUrl = resolveUrl(
|
|
1814
|
-
entryFileRelativeUrl,
|
|
1815
|
-
projectDirectoryUrl,
|
|
1816
|
-
)
|
|
1817
|
-
const entryBuildUrl = resolveUrl(
|
|
1818
|
-
entryPoints[entryFileRelativeUrl],
|
|
1819
|
-
buildDirectoryUrl,
|
|
1820
|
-
)
|
|
1821
|
-
const entryProjectRelativeUrl = urlToRelativeUrl(
|
|
1822
|
-
entryProjectUrl,
|
|
1823
|
-
projectDirectoryUrl,
|
|
1824
|
-
)
|
|
1825
|
-
const entryBuildRelativeUrl = urlToRelativeUrl(
|
|
1826
|
-
entryBuildUrl,
|
|
1827
|
-
buildDirectoryUrl,
|
|
1828
|
-
)
|
|
1829
|
-
logger.debug(`${UNICODE.INFO} load entry point ${entryProjectRelativeUrl}`)
|
|
1830
|
-
const entryServerUrl = resolveUrl(
|
|
1831
|
-
entryProjectRelativeUrl,
|
|
1832
|
-
compileServerOrigin,
|
|
1833
|
-
)
|
|
1834
|
-
const entryResponse = await urlFetcher.fetchUrl(entryServerUrl, {
|
|
1835
|
-
urlTrace: `entryPoints`,
|
|
1836
|
-
})
|
|
1837
|
-
const entryContentType = entryResponse.headers["content-type"]
|
|
1838
|
-
const isHtml = entryContentType === "text/html"
|
|
1839
|
-
entryPointsPrepared.push({
|
|
1840
|
-
entryContentType:
|
|
1841
|
-
entryContentType === "text/javascript"
|
|
1842
|
-
? "application/javascript"
|
|
1843
|
-
: entryContentType,
|
|
1844
|
-
entryProjectRelativeUrl,
|
|
1845
|
-
entryBuildRelativeUrl,
|
|
1846
|
-
...(isHtml
|
|
1847
|
-
? { entryBuffer: Buffer.from(await entryResponse.arrayBuffer()) }
|
|
1848
|
-
: {}),
|
|
1849
|
-
})
|
|
1850
|
-
}, Promise.resolve())
|
|
1851
|
-
|
|
1852
|
-
return entryPointsPrepared
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
const normalizeRollupResolveReturnValue = (resolveReturnValue) => {
|
|
1856
|
-
if (resolveReturnValue === null) {
|
|
1857
|
-
return { id: null, external: true }
|
|
1858
|
-
}
|
|
1859
|
-
if (typeof resolveReturnValue === "string") {
|
|
1860
|
-
return { id: resolveReturnValue, external: false }
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
return resolveReturnValue
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
const createUrlMetaGetter = ({
|
|
1867
|
-
projectDirectoryUrl,
|
|
1868
|
-
jsenvRemoteDirectory,
|
|
1869
|
-
preservedUrls,
|
|
1870
|
-
}) => {
|
|
1871
|
-
const preservedFileUrls = {}
|
|
1872
|
-
const remoteFileUrls = {}
|
|
1873
|
-
Object.keys(preservedUrls).forEach((pattern) => {
|
|
1874
|
-
if (jsenvRemoteDirectory.isRemoteUrl(pattern)) {
|
|
1875
|
-
const fileUrlPattern = jsenvRemoteDirectory.fileUrlFromRemoteUrl(pattern)
|
|
1876
|
-
preservedFileUrls[fileUrlPattern] = preservedUrls[pattern]
|
|
1877
|
-
remoteFileUrls[fileUrlPattern] = true
|
|
1878
|
-
}
|
|
1879
|
-
})
|
|
1880
|
-
const structuredMetaMap = normalizeStructuredMetaMap(
|
|
1881
|
-
{
|
|
1882
|
-
preserve: {
|
|
1883
|
-
...preservedUrls,
|
|
1884
|
-
...preservedFileUrls,
|
|
1885
|
-
},
|
|
1886
|
-
remote: remoteFileUrls,
|
|
1887
|
-
},
|
|
1888
|
-
projectDirectoryUrl,
|
|
1889
|
-
)
|
|
1890
|
-
return (url) => {
|
|
1891
|
-
const meta = urlToMeta({
|
|
1892
|
-
url,
|
|
1893
|
-
structuredMetaMap,
|
|
1894
|
-
})
|
|
1895
|
-
return meta
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
const acceptsJsonContentType = ({ node, format }) => {
|
|
1900
|
-
if (!node) {
|
|
1901
|
-
return false
|
|
1902
|
-
}
|
|
1903
|
-
if (format === "commonjs") {
|
|
1904
|
-
return true
|
|
1905
|
-
}
|
|
1906
|
-
if (process.execArgv.includes("--experimental-json-modules")) {
|
|
1907
|
-
return true
|
|
1908
|
-
}
|
|
1909
|
-
return false
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
const isReferencedByJs = ({ rollupFileInfo, jsConcatenation, jsRessource }) => {
|
|
1913
|
-
if (rollupFileInfo.isDynamicEntry) {
|
|
1914
|
-
return true
|
|
1915
|
-
}
|
|
1916
|
-
if (!jsConcatenation && rollupFileInfo.isEntry) {
|
|
1917
|
-
return true
|
|
1918
|
-
}
|
|
1919
|
-
if (
|
|
1920
|
-
jsRessource &&
|
|
1921
|
-
jsRessource.references.some((ref) => ref.isRessourceHint)
|
|
1922
|
-
) {
|
|
1923
|
-
return true
|
|
1924
|
-
}
|
|
1925
|
-
return false
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
|
-
const visitServiceWorkers = async ({
|
|
1929
|
-
projectDirectoryUrl,
|
|
1930
|
-
serviceWorkerUrls,
|
|
1931
|
-
classicServiceWorkerUrls,
|
|
1932
|
-
serviceWorkerFinalizer,
|
|
1933
|
-
buildMappings,
|
|
1934
|
-
buildFileContents,
|
|
1935
|
-
lineBreakNormalization,
|
|
1936
|
-
}) => {
|
|
1937
|
-
const allServiceWorkerUrls = [
|
|
1938
|
-
...serviceWorkerUrls,
|
|
1939
|
-
...classicServiceWorkerUrls,
|
|
1940
|
-
]
|
|
1941
|
-
await Promise.all(
|
|
1942
|
-
allServiceWorkerUrls.map(async (serviceWorkerUrl) => {
|
|
1943
|
-
const serviceWorkerRelativeUrl = urlToRelativeUrl(
|
|
1944
|
-
serviceWorkerUrl,
|
|
1945
|
-
projectDirectoryUrl,
|
|
1946
|
-
)
|
|
1947
|
-
const serviceWorkerBuildRelativeUrl =
|
|
1948
|
-
buildMappings[serviceWorkerRelativeUrl]
|
|
1949
|
-
if (!serviceWorkerBuildRelativeUrl) {
|
|
1950
|
-
throw new Error(
|
|
1951
|
-
`"${serviceWorkerRelativeUrl}" service worker file missing in the build`,
|
|
1952
|
-
)
|
|
1953
|
-
}
|
|
1954
|
-
if (serviceWorkerFinalizer) {
|
|
1955
|
-
let code = buildFileContents[serviceWorkerBuildRelativeUrl]
|
|
1956
|
-
code = await serviceWorkerFinalizer(code, {
|
|
1957
|
-
serviceWorkerBuildRelativeUrl,
|
|
1958
|
-
buildFileContents,
|
|
1959
|
-
lineBreakNormalization,
|
|
1960
|
-
})
|
|
1961
|
-
buildFileContents[serviceWorkerBuildRelativeUrl] = code
|
|
1962
|
-
}
|
|
1963
|
-
}),
|
|
1964
|
-
)
|
|
1965
|
-
}
|