@jsenv/core 27.0.0-alpha.4 → 27.0.0-alpha.40
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/dist/event_source_client.js +549 -0
- package/dist/event_source_client.js.map +188 -0
- package/dist/html_supervisor_installer.js +1145 -0
- package/dist/html_supervisor_installer.js.map +322 -0
- package/dist/html_supervisor_setup.js +92 -0
- package/dist/html_supervisor_setup.js.map +57 -0
- package/main.js +8 -1
- package/package.json +22 -21
- package/readme.md +4 -12
- package/src/build/build.js +731 -433
- package/src/build/build_urls_generator.js +55 -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 +205 -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/jsenv_root_directory_url.js +1 -0
- 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 +414 -285
- package/src/omega/server/file_service.js +21 -22
- 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/url_info_transformations.js +17 -5
- package/src/omega/url_graph.js +33 -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 +46 -0
- package/src/{dev/plugins/autoreload/jsenv_plugin_autoreload.js → plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js} +31 -172
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +27 -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 +54 -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 +8 -5
- 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 +52 -55
- 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 +101 -0
- package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +33 -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 +67 -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 +296 -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/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +146 -0
- package/src/{omega → plugins}/plugin_controller.js +39 -11
- package/src/plugins/plugins.js +89 -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 +93 -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 → plugins/transpilation}/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_structure.js +4 -22
- 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 +37 -21
- 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/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +200 -0
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +70 -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 +43 -0
- package/src/plugins/url_references/jsenv_plugin_imports_analysis.js +46 -0
- package/src/plugins/url_references/jsenv_plugin_url_analysis.js +18 -0
- package/src/plugins/url_references/jsenv_plugin_url_references.js +6 -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 +12 -15
- package/src/test/execute_plan.js +28 -11
- package/src/test/execute_test_plan.js +23 -8
- 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/file_urls/jsenv_plugin_file_urls.js +0 -67
- package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -98
- 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/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +0 -77
- 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
package/src/omega/errors.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const createResolveUrlError = ({
|
|
4
|
+
pluginController,
|
|
5
|
+
reference,
|
|
6
|
+
error,
|
|
7
|
+
}) => {
|
|
8
|
+
const createFailedToResolveUrlError = ({
|
|
9
|
+
code = error.code || "RESOLVE_URL_ERROR",
|
|
6
10
|
reason,
|
|
7
11
|
...details
|
|
8
12
|
}) => {
|
|
9
13
|
const resolveError = new Error(
|
|
10
|
-
createDetailedMessage(`Failed to resolve
|
|
14
|
+
createDetailedMessage(`Failed to resolve url reference`, {
|
|
11
15
|
reason,
|
|
12
16
|
...details,
|
|
13
17
|
"specifier": `"${reference.specifier}"`,
|
|
@@ -15,35 +19,35 @@ export const createResolveError = ({ pluginController, reference, error }) => {
|
|
|
15
19
|
...detailsFromPluginController(pluginController),
|
|
16
20
|
}),
|
|
17
21
|
)
|
|
18
|
-
resolveError.name = "
|
|
22
|
+
resolveError.name = "RESOLVE_URL_ERROR"
|
|
19
23
|
resolveError.code = code
|
|
20
24
|
resolveError.reason = reason
|
|
21
25
|
return resolveError
|
|
22
26
|
}
|
|
23
27
|
if (error.message === "NO_RESOLVE") {
|
|
24
|
-
return
|
|
25
|
-
reason: `no plugin has handled the specifier during "
|
|
28
|
+
return createFailedToResolveUrlError({
|
|
29
|
+
reason: `no plugin has handled the specifier during "resolveUrl" hook`,
|
|
26
30
|
})
|
|
27
31
|
}
|
|
28
|
-
return
|
|
32
|
+
return createFailedToResolveUrlError({
|
|
29
33
|
reason: `An error occured during specifier resolution`,
|
|
30
34
|
...detailsFromValueThrown(error),
|
|
31
35
|
})
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
export const
|
|
38
|
+
export const createFetchUrlContentError = ({
|
|
35
39
|
pluginController,
|
|
36
40
|
reference,
|
|
37
41
|
urlInfo,
|
|
38
42
|
error,
|
|
39
43
|
}) => {
|
|
40
|
-
const
|
|
41
|
-
code = error.code || "
|
|
44
|
+
const createFailedToFetchUrlContentError = ({
|
|
45
|
+
code = error.code || "FETCH_URL_CONTENT_ERROR",
|
|
42
46
|
reason,
|
|
43
47
|
...details
|
|
44
48
|
}) => {
|
|
45
|
-
const
|
|
46
|
-
createDetailedMessage(`Failed to
|
|
49
|
+
const fetchContentError = new Error(
|
|
50
|
+
createDetailedMessage(`Failed to fetch url content`, {
|
|
47
51
|
reason,
|
|
48
52
|
...details,
|
|
49
53
|
"url": urlInfo.url,
|
|
@@ -51,80 +55,49 @@ export const createLoadError = ({
|
|
|
51
55
|
...detailsFromPluginController(pluginController),
|
|
52
56
|
}),
|
|
53
57
|
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
+
fetchContentError.name = "FETCH_URL_CONTENT_ERROR"
|
|
59
|
+
fetchContentError.code = code
|
|
60
|
+
fetchContentError.reason = reason
|
|
61
|
+
return fetchContentError
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
if (error.message === "NO_LOAD") {
|
|
61
|
-
return createFailedToLoadError({
|
|
62
|
-
code: "NOT_FOUND",
|
|
63
|
-
reason: `no plugin has handled the url during "load" hook`,
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
64
|
if (error.code === "EPERM") {
|
|
67
|
-
return
|
|
65
|
+
return createFailedToFetchUrlContentError({
|
|
68
66
|
code: "NOT_ALLOWED",
|
|
69
67
|
reason: `not allowed to read entry on filesystem`,
|
|
70
68
|
})
|
|
71
69
|
}
|
|
72
70
|
if (error.code === "EISDIR") {
|
|
73
|
-
return
|
|
71
|
+
return createFailedToFetchUrlContentError({
|
|
74
72
|
code: "EISDIR",
|
|
75
73
|
reason: `found a directory on filesystem`,
|
|
76
74
|
})
|
|
77
75
|
}
|
|
78
76
|
if (error.code === "ENOENT") {
|
|
79
|
-
return
|
|
77
|
+
return createFailedToFetchUrlContentError({
|
|
80
78
|
code: "NOT_FOUND",
|
|
81
79
|
reason: "no entry on filesystem",
|
|
82
80
|
})
|
|
83
81
|
}
|
|
84
|
-
return
|
|
85
|
-
reason: `An error occured during "
|
|
86
|
-
...detailsFromValueThrown(error),
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const createParseError = ({ reference, urlInfo, error }) => {
|
|
91
|
-
const createFailedToParseError = ({
|
|
92
|
-
code = error.code || "PARSE_ERROR",
|
|
93
|
-
reason,
|
|
94
|
-
...details
|
|
95
|
-
}) => {
|
|
96
|
-
const parseError = new Error(
|
|
97
|
-
createDetailedMessage(`Failed to parse ${urlInfo.type}`, {
|
|
98
|
-
reason,
|
|
99
|
-
...details,
|
|
100
|
-
"url": urlInfo.url,
|
|
101
|
-
"url reference trace": reference.trace,
|
|
102
|
-
}),
|
|
103
|
-
)
|
|
104
|
-
parseError.name = "PARSE_ERROR"
|
|
105
|
-
parseError.code = code
|
|
106
|
-
parseError.reason = reason
|
|
107
|
-
return parseError
|
|
108
|
-
}
|
|
109
|
-
return createFailedToParseError({
|
|
110
|
-
reason: `An error occured while parsing content`,
|
|
82
|
+
return createFailedToFetchUrlContentError({
|
|
83
|
+
reason: `An error occured during "fetchUrlContent"`,
|
|
111
84
|
...detailsFromValueThrown(error),
|
|
112
85
|
})
|
|
113
86
|
}
|
|
114
87
|
|
|
115
|
-
export const
|
|
88
|
+
export const createTransformUrlContentError = ({
|
|
116
89
|
pluginController,
|
|
117
90
|
reference,
|
|
118
91
|
urlInfo,
|
|
119
92
|
error,
|
|
120
93
|
}) => {
|
|
121
94
|
const createFailedToTransformError = ({
|
|
122
|
-
code = error.code || "
|
|
95
|
+
code = error.code || "TRANSFORM_URL_CONTENT_ERROR",
|
|
123
96
|
reason,
|
|
124
97
|
...details
|
|
125
98
|
}) => {
|
|
126
99
|
const transformError = new Error(
|
|
127
|
-
createDetailedMessage(`Failed to transform ${urlInfo.type}`, {
|
|
100
|
+
createDetailedMessage(`Failed to transform ${urlInfo.type} url content`, {
|
|
128
101
|
reason,
|
|
129
102
|
...details,
|
|
130
103
|
"url": urlInfo.url,
|
|
@@ -132,17 +105,37 @@ export const createTransformError = ({
|
|
|
132
105
|
...detailsFromPluginController(pluginController),
|
|
133
106
|
}),
|
|
134
107
|
)
|
|
135
|
-
transformError.name = "
|
|
108
|
+
transformError.name = "TRANSFORM_URL_CONTENT_ERROR"
|
|
136
109
|
transformError.code = code
|
|
137
110
|
transformError.reason = reason
|
|
138
111
|
return transformError
|
|
139
112
|
}
|
|
140
113
|
return createFailedToTransformError({
|
|
141
|
-
reason: `An error occured during "
|
|
114
|
+
reason: `An error occured during "transformUrlContent"`,
|
|
142
115
|
...detailsFromValueThrown(error),
|
|
143
116
|
})
|
|
144
117
|
}
|
|
145
118
|
|
|
119
|
+
export const createFinalizeUrlContentError = ({
|
|
120
|
+
pluginController,
|
|
121
|
+
reference,
|
|
122
|
+
urlInfo,
|
|
123
|
+
error,
|
|
124
|
+
}) => {
|
|
125
|
+
const finalizeError = new Error(
|
|
126
|
+
createDetailedMessage(`Failed to finalize ${urlInfo.type} url content`, {
|
|
127
|
+
"reason": `An error occured during "finalizeUrlContent"`,
|
|
128
|
+
...detailsFromValueThrown(error),
|
|
129
|
+
"url": urlInfo.url,
|
|
130
|
+
"url reference trace": reference.trace,
|
|
131
|
+
...detailsFromPluginController(pluginController),
|
|
132
|
+
}),
|
|
133
|
+
)
|
|
134
|
+
finalizeError.name = "FINALIZE_URL_CONTENT_ERROR"
|
|
135
|
+
finalizeError.reason = `An error occured during "finalizeUrlContent"`
|
|
136
|
+
return finalizeError
|
|
137
|
+
}
|
|
138
|
+
|
|
146
139
|
const detailsFromPluginController = (pluginController) => {
|
|
147
140
|
const currentPlugin = pluginController.getCurrentPlugin()
|
|
148
141
|
if (!currentPlugin) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validateResponseIntegrity } from "@jsenv/integrity"
|
|
2
|
+
|
|
3
|
+
export const assertFetchedContentCompliance = ({ reference, urlInfo }) => {
|
|
4
|
+
const { expectedContentType } = reference
|
|
5
|
+
if (expectedContentType && urlInfo.contentType !== expectedContentType) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
`Unexpected content-type on url: got "${urlInfo.contentType}" instead of "${expectedContentType}"`,
|
|
8
|
+
)
|
|
9
|
+
}
|
|
10
|
+
const { expectedType } = reference
|
|
11
|
+
if (expectedType && urlInfo.type !== expectedType) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Unexpected type on url: got "${urlInfo.type}" instead of "${expectedType}"`,
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
const { integrity } = reference
|
|
17
|
+
if (integrity) {
|
|
18
|
+
validateResponseIntegrity({
|
|
19
|
+
url: urlInfo.url,
|
|
20
|
+
type: "basic",
|
|
21
|
+
dataRepresentation: urlInfo.content,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,59 +1,17 @@
|
|
|
1
1
|
import { fileSystemPathToUrl, urlToFileSystemPath } from "@jsenv/filesystem"
|
|
2
2
|
|
|
3
3
|
export const fileUrlConverter = {
|
|
4
|
-
asUrlWithoutSpecialParams: (fileUrl) => {
|
|
5
|
-
const urlObject = new URL(fileUrl)
|
|
6
|
-
let { origin, pathname, searchParams, hash } = urlObject
|
|
7
|
-
// origin is "null" for "file://" urls with Node.js
|
|
8
|
-
if (origin === "null" && urlObject.href.startsWith("file:")) {
|
|
9
|
-
origin = "file://"
|
|
10
|
-
}
|
|
11
|
-
if (searchParams.has("json_module")) {
|
|
12
|
-
searchParams.delete("json_module")
|
|
13
|
-
return `${origin}${pathname}.json_module${stringifyQuery(
|
|
14
|
-
searchParams,
|
|
15
|
-
)}${hash}`
|
|
16
|
-
}
|
|
17
|
-
if (searchParams.has("css_module")) {
|
|
18
|
-
searchParams.delete("css_module")
|
|
19
|
-
return `${origin}${pathname}.css_module${stringifyQuery(
|
|
20
|
-
searchParams,
|
|
21
|
-
)}${hash}`
|
|
22
|
-
}
|
|
23
|
-
if (searchParams.has("text_module")) {
|
|
24
|
-
searchParams.delete("text_module")
|
|
25
|
-
return `${origin}${pathname}.text_module${stringifyQuery(
|
|
26
|
-
searchParams,
|
|
27
|
-
)}${hash}`
|
|
28
|
-
}
|
|
29
|
-
return fileUrl
|
|
30
|
-
},
|
|
31
4
|
asFilePath: (fileUrl) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return filePath
|
|
5
|
+
const filePath = urlToFileSystemPath(fileUrl)
|
|
6
|
+
const urlObject = new URL(fileUrl)
|
|
7
|
+
const { searchParams } = urlObject
|
|
8
|
+
return `${filePath}${stringifyQuery(searchParams)}`
|
|
36
9
|
},
|
|
37
10
|
asFileUrl: (filePath) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return `${jsonFileUrl}?json_module`
|
|
43
|
-
}
|
|
44
|
-
if (filePath.endsWith(".css_module")) {
|
|
45
|
-
const cssFileUrl = fileSystemPathToUrl(
|
|
46
|
-
filePath.slice(0, -".css_module".length),
|
|
47
|
-
)
|
|
48
|
-
return `${cssFileUrl}?css_module`
|
|
49
|
-
}
|
|
50
|
-
if (filePath.endsWith(".text_module")) {
|
|
51
|
-
const textFileUrl = fileSystemPathToUrl(
|
|
52
|
-
filePath.slice(0, -".text_module".length),
|
|
53
|
-
)
|
|
54
|
-
return `${textFileUrl}?text_module`
|
|
55
|
-
}
|
|
56
|
-
return fileSystemPathToUrl(filePath)
|
|
11
|
+
return decodeURIComponent(fileSystemPathToUrl(filePath)).replace(
|
|
12
|
+
/[=](?=&|$)/g,
|
|
13
|
+
"",
|
|
14
|
+
)
|
|
57
15
|
},
|
|
58
16
|
}
|
|
59
17
|
|