@jsenv/core 27.0.0-alpha.3 → 27.0.0-alpha.32
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 +4 -0
- package/package.json +17 -14
- package/readme.md +4 -12
- package/src/build/build.js +690 -429
- package/src/build/build_urls_generator.js +33 -21
- package/src/build/graph_utils.js +31 -0
- package/src/build/{inject_version_mappings.js → inject_global_version_mappings.js} +33 -15
- package/src/build/inject_service_worker_urls.js +79 -0
- package/src/build/resync_ressource_hints.js +68 -0
- package/src/build/start_build_server.js +201 -0
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +2 -2
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -1
- package/src/dev/start_dev_server.js +58 -26
- package/src/execute/execute.js +30 -4
- package/src/execute/run.js +19 -56
- package/src/execute/runtimes/browsers/from_playwright.js +201 -147
- package/src/execute/runtimes/node/controllable_file.mjs +26 -10
- package/src/execute/runtimes/node/node_execution_performance.js +67 -0
- package/src/execute/runtimes/node/node_process.js +280 -39
- package/src/omega/{runtime_support/default_runtime_support.js → compat/default_runtime_compat.js} +3 -5
- package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +66 -4
- package/src/omega/compat/runtime_compat.js +50 -0
- package/src/omega/errors.js +51 -58
- package/src/omega/fetched_content_compliance.js +24 -0
- package/src/omega/file_url_converter.js +8 -50
- package/src/omega/kitchen.js +409 -286
- package/src/omega/server/file_service.js +9 -11
- package/src/omega/url_graph/url_graph_load.js +14 -7
- package/src/omega/url_graph/url_graph_report.js +17 -15
- package/src/omega/url_graph.js +32 -10
- package/src/omega/web_workers.js +42 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +2 -2
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +0 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
- package/src/{dev/plugins/autoreload/jsenv_plugin_autoreload.js → plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js} +27 -168
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
- package/src/plugins/bundling/css/bundle_css.js +21 -0
- package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
- package/src/{build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js → plugins/bundling/js_module/bundle_js_module.js} +120 -79
- package/src/plugins/bundling/jsenv_plugin_bundling.js +51 -0
- package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +48 -41
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +66 -0
- package/src/{omega/core_plugins → plugins}/filesystem_magic/jsenv_plugin_filesystem_magic.js +7 -4
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_installer.js +3 -2
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_setup.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/jsenv_plugin_html_supervisor.js +38 -46
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +12 -0
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +2 -2
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +98 -0
- package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +26 -8
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
- package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +37 -31
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +25 -0
- package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +18 -14
- package/src/{omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js → plugins/inline/jsenv_plugin_html_inline_content.js} +61 -40
- package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +6 -6
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +263 -0
- package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
- package/src/plugins/minification/css/minify_css.js +9 -0
- package/src/plugins/minification/html/minify_html.js +15 -0
- package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
- package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
- package/src/plugins/minification/json/minify_json.js +8 -0
- package/src/{omega/core_plugins → plugins}/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +15 -15
- package/src/{omega → plugins}/plugin_controller.js +18 -10
- package/src/plugins/plugins.js +73 -0
- package/src/plugins/transpilation/as_js_classic/client/s.js +808 -0
- package/src/plugins/transpilation/as_js_classic/client/s.js.md +1 -0
- package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
- package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +183 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +256 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_workers_type_module_as_classic.js +139 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
- package/src/{omega/core_plugins/babel/babel_helper → plugins/transpilation/babel/helpers}/babel_plugin_babel_helpers_as_jsenv_imports.js +1 -2
- package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +161 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +38 -22
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +30 -6
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/.eslintrc.cjs +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
- package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
- package/src/plugins/transpilation/fetch_original_url_info.js +30 -0
- package/src/{omega/core_plugins → plugins/transpilation}/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -0
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +225 -0
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +37 -0
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +44 -0
- package/src/plugins/url_references/css/css_urls.js +49 -0
- package/src/plugins/url_references/html/html_urls.js +273 -0
- package/src/plugins/url_references/js/js_urls.js +163 -0
- package/src/plugins/url_references/jsenv_plugin_url_references.js +18 -0
- package/src/plugins/url_references/webmanifest/webmanifest_urls.js +17 -0
- package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +12 -5
- package/src/{omega/core_plugins → plugins}/url_version/jsenv_plugin_url_version.js +8 -8
- package/src/test/execute_plan.js +25 -11
- package/src/test/execute_test_plan.js +14 -1
- package/src/test/logs_file_execution.js +8 -7
- package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
- package/src/dev/plugins/autoreload/client/event_source_connection.js +0 -195
- package/src/dev/plugins/autoreload/sse_service.js +0 -149
- package/src/execute/runtimes/node/controlled_process.js +0 -316
- package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +0 -29
- package/src/omega/core_plugins/babel/babel_helper/client/.eslintrc.cjs +0 -24
- package/src/omega/core_plugins/babel/babel_helper/client/AsyncGenerator/AsyncGenerator.js +0 -81
- package/src/omega/core_plugins/babel/babel_helper/client/AwaitValue/AwaitValue.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -33
- package/src/omega/core_plugins/babel/babel_helper/client/arrayLikeToArray/arrayLikeToArray.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/arrayWithHoles/arrayWithHoles.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/assertThisInitialized/assertThisInitialized.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -40
- package/src/omega/core_plugins/babel/babel_helper/client/asyncIterator/asyncIterator.js +0 -65
- package/src/omega/core_plugins/babel/babel_helper/client/asyncToGenerator/asyncToGenerator.js +0 -34
- package/src/omega/core_plugins/babel/babel_helper/client/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -20
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/classCallCheck/classCallCheck.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classNameTDZError/classNameTDZError.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -9
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/construct/construct.js +0 -16
- package/src/omega/core_plugins/babel/babel_helper/client/createClass/createClass.js +0 -15
- package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -60
- package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/createRawReactElement/createRawReactElement.js +0 -50
- package/src/omega/core_plugins/babel/babel_helper/client/createSuper/createSuper.js +0 -22
- package/src/omega/core_plugins/babel/babel_helper/client/decorate/decorate.js +0 -403
- package/src/omega/core_plugins/babel/babel_helper/client/defaults/defaults.js +0 -11
- package/src/omega/core_plugins/babel/babel_helper/client/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/defineProperty/defineProperty.js +0 -18
- package/src/omega/core_plugins/babel/babel_helper/client/extends/extends.js +0 -14
- package/src/omega/core_plugins/babel/babel_helper/client/get/get.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/getPrototypeOf/getPrototypeOf.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/inherits/inherits.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/inheritsLoose/inheritsLoose.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/initializerDefineProperty/initializerDefineProperty.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/initializerWarningHelper/initializerWarningHelper.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/instanceof/instanceof.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/interopRequireDefault/interopRequireDefault.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/interopRequireWildcard/interopRequireWildcard.js +0 -37
- package/src/omega/core_plugins/babel/babel_helper/client/isNativeFunction/isNativeFunction.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -21
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArray/iterableToArray.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimit/iterableToArrayLimit.js +0 -36
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/jsx/jsx.js +0 -50
- package/src/omega/core_plugins/babel/babel_helper/client/maybeArrayLike/maybeArrayLike.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/newArrowCheck/newArrowCheck.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/nonIterableRest/nonIterableRest.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/nonIterableSpread/nonIterableSpread.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/objectSpread/objectSpread.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/objectSpread2/objectSpread2.js +0 -41
- package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutProperties/objectWithoutProperties.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/possibleConstructorReturn/possibleConstructorReturn.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/readOnlyError/readOnlyError.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/readme.md +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/set/set.js +0 -44
- package/src/omega/core_plugins/babel/babel_helper/client/setPrototypeOf/setPrototypeOf.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/slicedToArray/slicedToArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/superPropBase/superPropBase.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/tdz/tdz.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/temporalRef/temporalRef.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/temporalUndefined/temporalUndefined.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/toArray/toArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toConsumableArray/toConsumableArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toPrimitive/toPrimitive.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toPropertyKey/toPropertyKey.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/typeof/typeof.js +0 -14
- package/src/omega/core_plugins/babel/babel_helper/client/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
- package/src/omega/core_plugins/babel/babel_helper/client/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/wrapNativeSuper/wrapNativeSuper.js +0 -30
- package/src/omega/core_plugins/babel/babel_helper/client/wrapRegExp/wrapRegExp.js +0 -63
- package/src/omega/core_plugins/babel/babel_helper/client/writeOnlyError/writeOnlyError.js +0 -4
- package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +0 -187
- package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
- package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
- package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
- package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
- package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -210
- package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
- package/src/omega/core_plugins.js +0 -39
- package/src/omega/runtime_support/runtime_support.js +0 -20
- package/src/omega/url_mentions/css_url_mentions.js +0 -63
- package/src/omega/url_mentions/html_url_mentions.js +0 -185
- package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
- package/src/omega/url_mentions/parse_url_mentions.js +0 -37
- package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
|
@@ -42,15 +42,11 @@ export const createFileService = ({
|
|
|
42
42
|
const { runtimeName, runtimeVersion } = parseUserAgentHeader(
|
|
43
43
|
request.headers["user-agent"],
|
|
44
44
|
)
|
|
45
|
-
const
|
|
46
|
-
[runtimeName]: runtimeVersion,
|
|
47
|
-
}
|
|
48
|
-
const reference = kitchen.createReference({
|
|
45
|
+
const [reference, urlInfo] = kitchen.prepareEntryPoint({
|
|
49
46
|
parentUrl: inferParentFromRequest(request, rootDirectoryUrl),
|
|
50
47
|
type: "entry_point",
|
|
51
48
|
specifier: request.ressource,
|
|
52
49
|
})
|
|
53
|
-
const requestedUrlInfo = kitchen.resolveReference(reference)
|
|
54
50
|
const referenceFromGraph = urlGraph.inferReference(
|
|
55
51
|
reference.url,
|
|
56
52
|
reference.parentUrl,
|
|
@@ -58,11 +54,13 @@ export const createFileService = ({
|
|
|
58
54
|
try {
|
|
59
55
|
await kitchen.cook({
|
|
60
56
|
reference: referenceFromGraph || reference,
|
|
61
|
-
urlInfo
|
|
57
|
+
urlInfo,
|
|
62
58
|
outDirectoryUrl: `${rootDirectoryUrl}.jsenv/${scenario}/${runtimeName}@${runtimeVersion}/`,
|
|
63
|
-
|
|
59
|
+
clientRuntimeCompat: {
|
|
60
|
+
[runtimeName]: runtimeVersion,
|
|
61
|
+
},
|
|
64
62
|
})
|
|
65
|
-
const { response, contentType, content } =
|
|
63
|
+
const { response, contentType, content } = urlInfo
|
|
66
64
|
if (response) {
|
|
67
65
|
return response
|
|
68
66
|
}
|
|
@@ -86,11 +84,11 @@ export const createFileService = ({
|
|
|
86
84
|
statusText: e.reason,
|
|
87
85
|
statusMessage: e.message,
|
|
88
86
|
headers: {
|
|
89
|
-
"content-type":
|
|
90
|
-
"content-length": Buffer.byteLength(
|
|
87
|
+
"content-type": urlInfo.contentType,
|
|
88
|
+
"content-length": Buffer.byteLength(urlInfo.content),
|
|
91
89
|
"cache-control": "no-store",
|
|
92
90
|
},
|
|
93
|
-
body:
|
|
91
|
+
body: urlInfo.content,
|
|
94
92
|
}
|
|
95
93
|
}
|
|
96
94
|
if (code === "EISDIR") {
|
|
@@ -5,23 +5,24 @@ export const loadUrlGraph = async ({
|
|
|
5
5
|
kitchen,
|
|
6
6
|
startLoading,
|
|
7
7
|
outDirectoryUrl,
|
|
8
|
-
|
|
8
|
+
clientRuntimeCompat,
|
|
9
9
|
}) => {
|
|
10
10
|
if (outDirectoryUrl) {
|
|
11
11
|
await ensureEmptyDirectory(outDirectoryUrl)
|
|
12
12
|
}
|
|
13
13
|
const promises = []
|
|
14
|
+
const promiseMap = new Map()
|
|
14
15
|
const cook = ({ urlInfo, ...rest }) => {
|
|
15
|
-
const promiseFromData = urlInfo
|
|
16
|
+
const promiseFromData = promiseMap.get(urlInfo)
|
|
16
17
|
if (promiseFromData) return promiseFromData
|
|
17
18
|
const promise = _cook({
|
|
18
19
|
urlInfo,
|
|
19
20
|
outDirectoryUrl,
|
|
20
|
-
|
|
21
|
+
clientRuntimeCompat,
|
|
21
22
|
...rest,
|
|
22
23
|
})
|
|
23
24
|
promises.push(promise)
|
|
24
|
-
urlInfo
|
|
25
|
+
promiseMap.set(urlInfo, promise)
|
|
25
26
|
return promise
|
|
26
27
|
}
|
|
27
28
|
const _cook = async ({ urlInfo, ...rest }) => {
|
|
@@ -32,26 +33,31 @@ export const loadUrlGraph = async ({
|
|
|
32
33
|
})
|
|
33
34
|
const { references } = urlInfo
|
|
34
35
|
references.forEach((reference) => {
|
|
36
|
+
// we use reference.generatedUrl to mimic what a browser would do:
|
|
37
|
+
// do a fetch to the specifier as found in the file
|
|
38
|
+
const referencedUrlInfo = urlGraph.reuseOrCreateUrlInfo(
|
|
39
|
+
reference.generatedUrl,
|
|
40
|
+
)
|
|
35
41
|
cook({
|
|
36
42
|
reference,
|
|
37
|
-
urlInfo:
|
|
43
|
+
urlInfo: referencedUrlInfo,
|
|
38
44
|
})
|
|
39
45
|
})
|
|
40
46
|
}
|
|
41
47
|
startLoading(
|
|
42
48
|
({ trace, parentUrl = kitchen.rootDirectoryUrl, type, specifier }) => {
|
|
43
|
-
const entryReference = kitchen.
|
|
49
|
+
const [entryReference, entryUrlInfo] = kitchen.prepareEntryPoint({
|
|
44
50
|
trace,
|
|
45
51
|
parentUrl,
|
|
46
52
|
type,
|
|
47
53
|
specifier,
|
|
48
54
|
})
|
|
49
|
-
const entryUrlInfo = kitchen.resolveReference(entryReference)
|
|
50
55
|
entryUrlInfo.data.isEntryPoint = true
|
|
51
56
|
cook({
|
|
52
57
|
reference: entryReference,
|
|
53
58
|
urlInfo: entryUrlInfo,
|
|
54
59
|
})
|
|
60
|
+
return [entryReference, entryUrlInfo]
|
|
55
61
|
},
|
|
56
62
|
)
|
|
57
63
|
|
|
@@ -65,4 +71,5 @@ export const loadUrlGraph = async ({
|
|
|
65
71
|
await waitAll()
|
|
66
72
|
}
|
|
67
73
|
await waitAll()
|
|
74
|
+
promiseMap.clear()
|
|
68
75
|
}
|
|
@@ -22,7 +22,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
22
22
|
html: 0,
|
|
23
23
|
css: 0,
|
|
24
24
|
js: 0,
|
|
25
|
-
|
|
25
|
+
other: 0,
|
|
26
26
|
sourcemaps: 0,
|
|
27
27
|
total: 0,
|
|
28
28
|
}
|
|
@@ -31,7 +31,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
31
31
|
css: 0,
|
|
32
32
|
js: 0,
|
|
33
33
|
sourcemaps: 0,
|
|
34
|
-
|
|
34
|
+
other: 0,
|
|
35
35
|
total: 0,
|
|
36
36
|
}
|
|
37
37
|
Object.keys(urlInfos).forEach((url) => {
|
|
@@ -39,8 +39,10 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
39
39
|
return
|
|
40
40
|
}
|
|
41
41
|
const urlInfo = urlInfos[url]
|
|
42
|
-
// ignore
|
|
43
|
-
|
|
42
|
+
// ignore:
|
|
43
|
+
// - inline files: they are already taken into account in the file where they appear
|
|
44
|
+
// - external files: we don't know their content
|
|
45
|
+
if (urlInfo.isInline || urlInfo.external) {
|
|
44
46
|
return
|
|
45
47
|
}
|
|
46
48
|
// file loaded via import assertion are already inside the graph
|
|
@@ -49,9 +51,9 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
49
51
|
// and only the js module remain (likely bundled)
|
|
50
52
|
const urlObject = new URL(urlInfo.url)
|
|
51
53
|
if (
|
|
52
|
-
urlObject.searchParams.has("
|
|
53
|
-
urlObject.searchParams.has("
|
|
54
|
-
urlObject.searchParams.has("
|
|
54
|
+
urlObject.searchParams.has("as_json_module") ||
|
|
55
|
+
urlObject.searchParams.has("as_css_module") ||
|
|
56
|
+
urlObject.searchParams.has("as_text_module")
|
|
55
57
|
) {
|
|
56
58
|
return
|
|
57
59
|
}
|
|
@@ -79,8 +81,8 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
79
81
|
sizeGroups.js += urlContentSize
|
|
80
82
|
return
|
|
81
83
|
}
|
|
82
|
-
countGroups.
|
|
83
|
-
sizeGroups.
|
|
84
|
+
countGroups.other++
|
|
85
|
+
sizeGroups.other += urlContentSize
|
|
84
86
|
return
|
|
85
87
|
})
|
|
86
88
|
return {
|
|
@@ -88,7 +90,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
88
90
|
css: { count: countGroups.css, size: sizeGroups.css },
|
|
89
91
|
js: { count: countGroups.js, size: sizeGroups.js },
|
|
90
92
|
sourcemaps: { count: countGroups.sourcemaps, size: sizeGroups.sourcemaps },
|
|
91
|
-
|
|
93
|
+
other: { count: countGroups.other, size: sizeGroups.other },
|
|
92
94
|
total: { count: countGroups.total, size: sizeGroups.total },
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -106,10 +108,10 @@ const determineCategory = (urlInfo) => {
|
|
|
106
108
|
if (urlInfo.type === "js_module" || urlInfo.type === "js_classic") {
|
|
107
109
|
return "js"
|
|
108
110
|
}
|
|
109
|
-
return "
|
|
111
|
+
return "other"
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
const createRepartitionMessage = ({ html, css, js,
|
|
114
|
+
const createRepartitionMessage = ({ html, css, js, other }) => {
|
|
113
115
|
const parts = []
|
|
114
116
|
if (html.count) {
|
|
115
117
|
parts.push(
|
|
@@ -139,10 +141,10 @@ const createRepartitionMessage = ({ html, css, js, assets }) => {
|
|
|
139
141
|
// } (${byteAsFileSize(sourcemaps.size)})`,
|
|
140
142
|
// )
|
|
141
143
|
// }
|
|
142
|
-
if (
|
|
144
|
+
if (other.count) {
|
|
143
145
|
parts.push(
|
|
144
|
-
`${ANSI.color(`
|
|
145
|
-
|
|
146
|
+
`${ANSI.color(`other:`, ANSI.GREY)} ${other.count} (${byteAsFileSize(
|
|
147
|
+
other.size,
|
|
146
148
|
)})`,
|
|
147
149
|
)
|
|
148
150
|
}
|
package/src/omega/url_graph.js
CHANGED
|
@@ -4,7 +4,16 @@ import { urlToRelativeUrl } from "@jsenv/filesystem"
|
|
|
4
4
|
export const createUrlGraph = () => {
|
|
5
5
|
const urlInfos = {}
|
|
6
6
|
const getUrlInfo = (url) => urlInfos[url]
|
|
7
|
-
const deleteUrlInfo = (url) =>
|
|
7
|
+
const deleteUrlInfo = (url) => {
|
|
8
|
+
const urlInfo = urlInfos[url]
|
|
9
|
+
if (urlInfo) {
|
|
10
|
+
delete urlInfos[url]
|
|
11
|
+
if (urlInfo.sourcemapReference) {
|
|
12
|
+
deleteUrlInfo(urlInfo.sourcemapReference.url)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
const reuseOrCreateUrlInfo = (url) => {
|
|
9
18
|
const existingUrlInfo = urlInfos[url]
|
|
10
19
|
if (existingUrlInfo) return existingUrlInfo
|
|
@@ -44,9 +53,19 @@ export const createUrlGraph = () => {
|
|
|
44
53
|
const updateReferences = (urlInfo, references) => {
|
|
45
54
|
const dependencyUrls = []
|
|
46
55
|
references.forEach((reference) => {
|
|
47
|
-
if (
|
|
48
|
-
|
|
56
|
+
if (reference.isRessourceHint) {
|
|
57
|
+
// ressource hint are a special kind of reference.
|
|
58
|
+
// They are a sort of weak reference to an url.
|
|
59
|
+
// We ignore them so that url referenced only by ressource hints
|
|
60
|
+
// have url.dependents.size === 0 and can be considered as not used
|
|
61
|
+
// It means html won't consider url referenced solely
|
|
62
|
+
// by <link> as dependency and it's fine
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
if (dependencyUrls.includes(reference.url)) {
|
|
66
|
+
return
|
|
49
67
|
}
|
|
68
|
+
dependencyUrls.push(reference.url)
|
|
50
69
|
})
|
|
51
70
|
pruneDependencies(
|
|
52
71
|
urlInfo,
|
|
@@ -115,18 +134,21 @@ export const createUrlGraph = () => {
|
|
|
115
134
|
const createUrlInfo = (url) => {
|
|
116
135
|
return {
|
|
117
136
|
data: {}, // plugins can put whatever they want here
|
|
137
|
+
references: [],
|
|
138
|
+
dependencies: new Set(),
|
|
139
|
+
dependents: new Set(),
|
|
140
|
+
type: undefined, // "html", "css", "js_classic", "js_module", "importmap", "json", "webmanifest", ...
|
|
141
|
+
subtype: undefined, // "worker", "service_worker", "shared_worker" for js, otherwise undefined
|
|
142
|
+
contentType: "", // "text/html", "text/css", "text/javascript", "application/json", ...
|
|
118
143
|
url,
|
|
144
|
+
filename: "",
|
|
119
145
|
generatedUrl: null,
|
|
120
146
|
isInline: false,
|
|
121
147
|
inlineUrlSite: null,
|
|
122
|
-
|
|
123
|
-
originalContent:
|
|
124
|
-
content:
|
|
148
|
+
external: false,
|
|
149
|
+
originalContent: undefined,
|
|
150
|
+
content: undefined,
|
|
125
151
|
sourcemap: null,
|
|
126
152
|
sourcemapReference: null,
|
|
127
|
-
type: "",
|
|
128
|
-
references: [],
|
|
129
|
-
dependencies: new Set(),
|
|
130
|
-
dependents: new Set(),
|
|
131
153
|
}
|
|
132
154
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// the following apis are creating js entry points:
|
|
2
|
+
// - new Worker()
|
|
3
|
+
// - new SharedWorker()
|
|
4
|
+
// - navigator.serviceWorker.register()
|
|
5
|
+
export const isWebWorkerEntryPointReference = (reference) => {
|
|
6
|
+
if (reference.subtype === "new_url_first_arg") {
|
|
7
|
+
return ["worker", "service_worker", "shared_worker"].includes(
|
|
8
|
+
reference.expectedSubtype,
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
return [
|
|
12
|
+
"new_worker_first_arg",
|
|
13
|
+
"new_shared_worker_first_arg",
|
|
14
|
+
"service_worker_register_first_arg",
|
|
15
|
+
].includes(reference.subtype)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const isWebWorkerUrlInfo = (urlInfo) => {
|
|
19
|
+
return (
|
|
20
|
+
urlInfo.subtype === "worker" ||
|
|
21
|
+
urlInfo.subtype === "service_worker" ||
|
|
22
|
+
urlInfo.subtype === "shared_worker"
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// export const isEntryPoint = (urlInfo, urlGraph) => {
|
|
27
|
+
// if (urlInfo.data.isEntryPoint) {
|
|
28
|
+
// return true
|
|
29
|
+
// }
|
|
30
|
+
// if (isWebWorker(urlInfo)) {
|
|
31
|
+
// // - new Worker("a.js") -> "a.js" is an entry point
|
|
32
|
+
// // - self.importScripts("b.js") -> "b.js" is not an entry point
|
|
33
|
+
// // So the following logic applies to infer if the file is a web worker entry point
|
|
34
|
+
// // "When a non-webworker file references a worker file, the worker file is an entry point"
|
|
35
|
+
// const dependents = Array.from(urlInfo.dependents)
|
|
36
|
+
// return dependents.some((dependentUrl) => {
|
|
37
|
+
// const dependentUrlInfo = urlGraph.getUrlInfo(dependentUrl)
|
|
38
|
+
// return !isWebWorker(dependentUrlInfo)
|
|
39
|
+
// })
|
|
40
|
+
// }
|
|
41
|
+
// return false
|
|
42
|
+
// }
|
package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js
RENAMED
|
File without changes
|
package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createEventSourceConnection } from "
|
|
1
|
+
import { createEventSourceConnection } from "@jsenv/utils/event_source/event_source.js"
|
|
2
|
+
import { urlHotMetas } from "../../../import_meta_hot/client/import_meta_hot.js"
|
|
2
3
|
import {
|
|
3
4
|
isAutoreloadEnabled,
|
|
4
5
|
setAutoreloadPreference,
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
reloadDOMNodesUsingUrl,
|
|
10
11
|
reloadJsImport,
|
|
11
12
|
} from "./reload.js"
|
|
12
|
-
import { urlHotMetas } from "./import_meta_hot.js"
|
|
13
13
|
|
|
14
14
|
const reloadMessages = []
|
|
15
15
|
const reloadMessagesSignal = { onchange: () => {} }
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseHtmlString,
|
|
3
|
+
stringifyHtmlAst,
|
|
4
|
+
injectScriptAsEarlyAsPossible,
|
|
5
|
+
createHtmlNode,
|
|
6
|
+
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
7
|
+
|
|
8
|
+
export const jsenvPluginDevSSEClient = () => {
|
|
9
|
+
const eventSourceClientFileUrl = new URL(
|
|
10
|
+
"./client/event_source_client.js",
|
|
11
|
+
import.meta.url,
|
|
12
|
+
).href
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
name: "jsenv:dev_sse_client",
|
|
16
|
+
appliesDuring: { dev: true },
|
|
17
|
+
transformUrlContent: {
|
|
18
|
+
html: (htmlUrlInfo, context) => {
|
|
19
|
+
const htmlAst = parseHtmlString(htmlUrlInfo.content)
|
|
20
|
+
const [eventSourceClientReference] = context.referenceUtils.inject({
|
|
21
|
+
type: "script_src",
|
|
22
|
+
expectedType: "js_module",
|
|
23
|
+
specifier: eventSourceClientFileUrl,
|
|
24
|
+
})
|
|
25
|
+
injectScriptAsEarlyAsPossible(
|
|
26
|
+
htmlAst,
|
|
27
|
+
createHtmlNode({
|
|
28
|
+
"tagName": "script",
|
|
29
|
+
"type": "module",
|
|
30
|
+
"src": eventSourceClientReference.generatedSpecifier,
|
|
31
|
+
"injected-by": "jsenv:dev_sse_client",
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
34
|
+
const htmlModified = stringifyHtmlAst(htmlAst)
|
|
35
|
+
return {
|
|
36
|
+
content: htmlModified,
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,177 +1,35 @@
|
|
|
1
1
|
import { urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
2
|
import { createCallbackList } from "@jsenv/abort"
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
6
|
-
import {
|
|
7
|
-
parseHtmlString,
|
|
8
|
-
stringifyHtmlAst,
|
|
9
|
-
injectScriptAsEarlyAsPossible,
|
|
10
|
-
createHtmlNode,
|
|
11
|
-
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
12
|
-
import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
|
|
4
|
+
import { createSSEService } from "@jsenv/utils/event_source/sse_service.js"
|
|
13
5
|
|
|
14
|
-
|
|
15
|
-
import { collectHotDataFromHtmlAst } from "./html_hot_dependencies.js"
|
|
16
|
-
import { babelPluginMetadataImportMetaHot } from "./babel_plugin_metadata_import_meta_hot.js"
|
|
17
|
-
|
|
18
|
-
export const jsenvPluginAutoreload = ({
|
|
6
|
+
export const jsenvPluginDevSSEServer = ({
|
|
19
7
|
rootDirectoryUrl,
|
|
20
8
|
urlGraph,
|
|
21
|
-
|
|
9
|
+
watchedFilePatterns,
|
|
10
|
+
cooldownBetweenFileEvents,
|
|
22
11
|
}) => {
|
|
23
|
-
|
|
24
|
-
jsenvPluginHot(),
|
|
25
|
-
jsenvPluginHotSSE({
|
|
26
|
-
rootDirectoryUrl,
|
|
27
|
-
urlGraph,
|
|
28
|
-
autoreloadPatterns,
|
|
29
|
-
}),
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const jsenvPluginHot = () => {
|
|
34
|
-
const eventSourceClientFileUrl = new URL(
|
|
35
|
-
"./client/event_source_client.js",
|
|
36
|
-
import.meta.url,
|
|
37
|
-
).href
|
|
38
|
-
const importMetaHotClientFileUrl = new URL(
|
|
39
|
-
"./client/import_meta_hot.js",
|
|
40
|
-
import.meta.url,
|
|
41
|
-
).href
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
name: "jsenv:hot",
|
|
45
|
-
appliesDuring: { dev: true },
|
|
46
|
-
normalize: ({ url, data }) => {
|
|
47
|
-
const urlObject = new URL(url)
|
|
48
|
-
if (!urlObject.searchParams.has("hmr")) {
|
|
49
|
-
data.hmr = false
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
data.hmr = true
|
|
53
|
-
// "hmr" search param goal is to mark url as enabling hmr:
|
|
54
|
-
// this goal is achieved when we reach this part of the code
|
|
55
|
-
// We get rid of this params so that urlGraph and other parts of the code
|
|
56
|
-
// recognize the url (it is not considered as a different url)
|
|
57
|
-
urlObject.searchParams.delete("hmr")
|
|
58
|
-
urlObject.searchParams.delete("v")
|
|
59
|
-
return urlObject.href
|
|
60
|
-
},
|
|
61
|
-
transformReferencedUrl: ({ parentUrl, url, data }, { urlGraph }) => {
|
|
62
|
-
const parentUrlInfo = urlGraph.getUrlInfo(parentUrl)
|
|
63
|
-
if (!parentUrlInfo || !parentUrlInfo.data.hmr) {
|
|
64
|
-
return null
|
|
65
|
-
}
|
|
66
|
-
if (!data.hmrTimestamp) {
|
|
67
|
-
return null
|
|
68
|
-
}
|
|
69
|
-
return injectQueryParams(url, {
|
|
70
|
-
hmr: "",
|
|
71
|
-
v: data.hmrTimestamp,
|
|
72
|
-
})
|
|
73
|
-
},
|
|
74
|
-
transform: {
|
|
75
|
-
html: ({ data, content }, { referenceUtils }) => {
|
|
76
|
-
const htmlAst = parseHtmlString(content)
|
|
77
|
-
const { hotReferences } = collectHotDataFromHtmlAst(htmlAst)
|
|
78
|
-
data.hotDecline = false
|
|
79
|
-
data.hotAcceptSelf = false
|
|
80
|
-
data.hotAcceptDependencies = hotReferences.map(
|
|
81
|
-
({ type, specifier }) => {
|
|
82
|
-
const [reference] = referenceUtils.inject({
|
|
83
|
-
type,
|
|
84
|
-
specifier,
|
|
85
|
-
})
|
|
86
|
-
return reference.url
|
|
87
|
-
},
|
|
88
|
-
)
|
|
89
|
-
const [eventSourceClientReference] = referenceUtils.inject({
|
|
90
|
-
type: "script_src",
|
|
91
|
-
specifier: eventSourceClientFileUrl,
|
|
92
|
-
})
|
|
93
|
-
injectScriptAsEarlyAsPossible(
|
|
94
|
-
htmlAst,
|
|
95
|
-
createHtmlNode({
|
|
96
|
-
"tagName": "script",
|
|
97
|
-
"type": "module",
|
|
98
|
-
"src": eventSourceClientReference.generatedSpecifier,
|
|
99
|
-
"injected-by": "jsenv:hot",
|
|
100
|
-
}),
|
|
101
|
-
)
|
|
102
|
-
const htmlModified = stringifyHtmlAst(htmlAst)
|
|
103
|
-
return {
|
|
104
|
-
content: htmlModified,
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
css: ({ data }) => {
|
|
108
|
-
data.hotDecline = false
|
|
109
|
-
data.hotAcceptSelf = false
|
|
110
|
-
data.hotAcceptDependencies = []
|
|
111
|
-
},
|
|
112
|
-
js_module: async (
|
|
113
|
-
{ url, generatedUrl, data, content },
|
|
114
|
-
{ referenceUtils },
|
|
115
|
-
) => {
|
|
116
|
-
const { metadata } = await applyBabelPlugins({
|
|
117
|
-
babelPlugins: [babelPluginMetadataImportMetaHot],
|
|
118
|
-
url,
|
|
119
|
-
generatedUrl,
|
|
120
|
-
content,
|
|
121
|
-
})
|
|
122
|
-
const {
|
|
123
|
-
importMetaHotDetected,
|
|
124
|
-
hotDecline,
|
|
125
|
-
hotAcceptSelf,
|
|
126
|
-
hotAcceptDependencies,
|
|
127
|
-
} = metadata
|
|
128
|
-
data.hotDecline = hotDecline
|
|
129
|
-
data.hotAcceptSelf = hotAcceptSelf
|
|
130
|
-
data.hotAcceptDependencies = hotAcceptDependencies
|
|
131
|
-
if (!importMetaHotDetected) {
|
|
132
|
-
return null
|
|
133
|
-
}
|
|
134
|
-
// For some reason using magic source here produce
|
|
135
|
-
// better sourcemap than doing the equivalent with babel
|
|
136
|
-
// I suspect it's because I was doing injectAstAfterImport(programPath, ast.program.body[0])
|
|
137
|
-
// which is likely not well supported by babel
|
|
138
|
-
const [importMetaHotClientFileReference] = referenceUtils.inject({
|
|
139
|
-
parentUrl: url,
|
|
140
|
-
type: "js_import_export",
|
|
141
|
-
specifier: importMetaHotClientFileUrl,
|
|
142
|
-
})
|
|
143
|
-
const magicSource = createMagicSource(content)
|
|
144
|
-
magicSource.prepend(
|
|
145
|
-
`import { createImportMetaHot } from ${importMetaHotClientFileReference.generatedSpecifier}
|
|
146
|
-
import.meta.hot = createImportMetaHot(import.meta.url)
|
|
147
|
-
`,
|
|
148
|
-
)
|
|
149
|
-
return magicSource.toContentAndSourcemap()
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const jsenvPluginHotSSE = ({
|
|
156
|
-
rootDirectoryUrl,
|
|
157
|
-
urlGraph,
|
|
158
|
-
autoreloadPatterns,
|
|
159
|
-
}) => {
|
|
160
|
-
const hotUpdateCallbackList = createCallbackList()
|
|
12
|
+
const serverEventCallbackList = createCallbackList()
|
|
161
13
|
const notifyDeclined = ({ cause, reason, declinedBy }) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
14
|
+
serverEventCallbackList.notify({
|
|
15
|
+
type: "reload",
|
|
16
|
+
data: JSON.stringify({
|
|
17
|
+
cause,
|
|
18
|
+
type: "full",
|
|
19
|
+
typeReason: reason,
|
|
20
|
+
declinedBy,
|
|
21
|
+
}),
|
|
167
22
|
})
|
|
168
23
|
}
|
|
169
24
|
const notifyAccepted = ({ cause, reason, instructions }) => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
25
|
+
serverEventCallbackList.notify({
|
|
26
|
+
type: "reload",
|
|
27
|
+
data: JSON.stringify({
|
|
28
|
+
cause,
|
|
29
|
+
type: "hot",
|
|
30
|
+
typeReason: reason,
|
|
31
|
+
hotInstructions: instructions,
|
|
32
|
+
}),
|
|
175
33
|
})
|
|
176
34
|
}
|
|
177
35
|
const updateHmrTimestamp = (urlInfo, hmrTimestamp) => {
|
|
@@ -273,9 +131,11 @@ const jsenvPluginHotSSE = ({
|
|
|
273
131
|
}
|
|
274
132
|
const sseService = createSSEService({
|
|
275
133
|
rootDirectoryUrl,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
134
|
+
watchedFilePatterns,
|
|
135
|
+
cooldownBetweenFileEvents,
|
|
136
|
+
serverEventCallbackList,
|
|
137
|
+
onFileChange: ({ url, event }) => {
|
|
138
|
+
const relativeUrl = urlToRelativeUrl(url, rootDirectoryUrl)
|
|
279
139
|
const urlInfo = urlGraph.urlInfos[url]
|
|
280
140
|
// file not part of dependency graph
|
|
281
141
|
if (!urlInfo) {
|
|
@@ -297,7 +157,6 @@ const jsenvPluginHotSSE = ({
|
|
|
297
157
|
})
|
|
298
158
|
}
|
|
299
159
|
},
|
|
300
|
-
hotUpdateCallbackList,
|
|
301
160
|
})
|
|
302
161
|
urlGraph.prunedCallbackList.add(({ prunedUrlInfos, firstUrlInfo }) => {
|
|
303
162
|
prunedUrlInfos.forEach((prunedUrlInfo) => {
|
|
@@ -346,7 +205,7 @@ const jsenvPluginHotSSE = ({
|
|
|
346
205
|
})
|
|
347
206
|
|
|
348
207
|
return {
|
|
349
|
-
name: "jsenv:
|
|
208
|
+
name: "jsenv:sse_server",
|
|
350
209
|
appliesDuring: { dev: true },
|
|
351
210
|
serve: (request, { urlGraph, rootDirectoryUrl }) => {
|
|
352
211
|
if (request.ressource === "/__graph__") {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsenvPluginHmr } from "./jsenv_plugin_hmr.js"
|
|
2
|
+
import { jsenvPluginDevSSEClient } from "./dev_sse/jsenv_plugin_dev_sse_client.js"
|
|
3
|
+
import { jsenvPluginDevSSEServer } from "./dev_sse/jsenv_plugin_dev_sse_server.js"
|
|
4
|
+
|
|
5
|
+
export const jsenvPluginAutoreload = ({
|
|
6
|
+
rootDirectoryUrl,
|
|
7
|
+
urlGraph,
|
|
8
|
+
scenario,
|
|
9
|
+
watchedFilePatterns,
|
|
10
|
+
cooldownBetweenFileEvents,
|
|
11
|
+
}) => {
|
|
12
|
+
if (scenario === "build") {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
return [
|
|
16
|
+
jsenvPluginHmr(),
|
|
17
|
+
jsenvPluginDevSSEClient(),
|
|
18
|
+
jsenvPluginDevSSEServer({
|
|
19
|
+
rootDirectoryUrl,
|
|
20
|
+
urlGraph,
|
|
21
|
+
watchedFilePatterns,
|
|
22
|
+
cooldownBetweenFileEvents,
|
|
23
|
+
}),
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const jsenvPluginHmr = () => {
|
|
2
|
+
return {
|
|
3
|
+
name: "jsenv:hmr",
|
|
4
|
+
appliesDuring: { dev: true },
|
|
5
|
+
normalizeUrl: (reference) => {
|
|
6
|
+
const urlObject = new URL(reference.url)
|
|
7
|
+
if (!urlObject.searchParams.has("hmr")) {
|
|
8
|
+
reference.data.hmr = false
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
reference.data.hmr = true
|
|
12
|
+
// "hmr" search param goal is to mark url as enabling hmr:
|
|
13
|
+
// this goal is achieved when we reach this part of the code
|
|
14
|
+
// We get rid of this params so that urlGraph and other parts of the code
|
|
15
|
+
// recognize the url (it is not considered as a different url)
|
|
16
|
+
urlObject.searchParams.delete("hmr")
|
|
17
|
+
urlObject.searchParams.delete("v")
|
|
18
|
+
return urlObject.href
|
|
19
|
+
},
|
|
20
|
+
transformUrlSearchParams: (reference, context) => {
|
|
21
|
+
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
|
|
22
|
+
if (!parentUrlInfo || !parentUrlInfo.data.hmr) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
const urlInfo = context.urlGraph.getUrlInfo(reference.url)
|
|
26
|
+
if (!urlInfo.data.hmrTimestamp) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
hmr: "",
|
|
31
|
+
v: urlInfo.data.hmrTimestamp,
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|