@jsenv/core 27.0.0-alpha.63 → 27.0.0-alpha.66
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/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -0
- package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +78 -0
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/construct/construct.js +15 -0
- package/dist/babel_helpers/createClass/createClass.js +18 -0
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
- package/dist/babel_helpers/createSuper/createSuper.js +22 -0
- package/dist/babel_helpers/decorate/decorate.js +622 -0
- package/dist/babel_helpers/defaults/defaults.js +14 -0
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
- package/dist/babel_helpers/defineProperty/defineProperty.js +19 -0
- package/dist/babel_helpers/extends/extends.js +16 -0
- package/dist/babel_helpers/get/get.js +21 -0
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
- package/dist/babel_helpers/inherits/inherits.js +21 -0
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
- package/dist/babel_helpers/instanceof/instanceof.js +7 -0
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +3 -0
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
- package/dist/babel_helpers/jsx/jsx.js +49 -0
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
- package/dist/babel_helpers/objectSpread/objectSpread.js +22 -0
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +41 -0
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +4 -0
- package/dist/babel_helpers/readme.md +8 -0
- package/dist/babel_helpers/set/set.js +51 -0
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +5 -0
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
- package/dist/babel_helpers/superPropBase/superPropBase.js +10 -0
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
- package/dist/babel_helpers/tdz/tdz.js +4 -0
- package/dist/babel_helpers/temporalRef/temporalRef.js +5 -0
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
- package/dist/babel_helpers/toArray/toArray.js +5 -0
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +14 -0
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
- package/dist/babel_helpers/typeof/typeof.js +7 -0
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
- package/dist/html/explorer.html +557 -0
- package/dist/js/controllable_file.mjs +227 -0
- package/dist/{event_source_client.js → js/event_source_client.js} +19 -244
- package/dist/js/global_this.js +32 -0
- package/dist/js/html_supervisor_installer.js +522 -0
- package/dist/js/html_supervisor_setup.js +79 -0
- package/dist/{import_meta_hot.js → js/import_meta_hot.js} +1 -3
- package/dist/js/inline_content.js +8 -0
- package/dist/js/new_stylesheet.js +409 -0
- package/dist/js/regenerator_runtime.js +721 -0
- package/dist/js/s.js +429 -0
- package/dist/main.js +13383 -0
- package/dist/other/jsenv.png +0 -0
- package/main.js +1 -0
- package/package.json +18 -14
- package/src/build/build.js +175 -69
- package/src/build/build_urls_generator.js +18 -2
- package/src/build/inject_global_version_mappings.js +18 -5
- package/src/build/inject_service_worker_urls.js +1 -1
- package/src/build/resync_ressource_hints.js +56 -9
- package/src/build/start_build_server.js +38 -29
- package/src/dev/plugins/explorer/client/explorer.html +1 -1
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +1 -1
- package/src/dev/start_dev_server.js +18 -4
- package/src/execute/execute.js +3 -0
- package/src/execute/runtimes/browsers/from_playwright.js +10 -0
- package/src/execute/runtimes/node/node_process.js +8 -0
- package/src/omega/errors.js +10 -7
- package/src/omega/kitchen.js +251 -340
- package/src/omega/server/file_service.js +34 -17
- package/src/omega/url_graph/url_graph_load.js +10 -17
- package/src/omega/url_graph/url_graph_report.js +2 -2
- package/src/omega/url_graph/url_info_transformations.js +1 -4
- package/src/omega/url_graph.js +7 -3
- package/src/omega/url_specifier_encoding.js +59 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +5 -10
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +1 -3
- package/src/plugins/bundling/js_module/bundle_js_module.js +66 -24
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +178 -53
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +1 -1
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +9 -13
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +6 -6
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +5 -10
- package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -4
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +51 -42
- package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -4
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +3 -5
- package/src/plugins/inline/jsenv_plugin_inline_query_param.js +1 -4
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +1 -4
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +16 -2
- package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
- package/src/plugins/plugin_controller.js +17 -3
- package/src/plugins/plugins.js +15 -15
- package/src/plugins/transpilation/as_js_classic/client/s.js +362 -807
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +20 -10
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +302 -0
- package/src/plugins/transpilation/as_js_classic/{jsenv_plugin_workers_type_module_as_classic.js → jsenv_plugin_as_js_classic_workers.js} +2 -2
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +5 -2
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +1 -2
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +2 -0
- package/src/plugins/url_analysis/html/html_urls.js +3 -0
- package/src/plugins/url_analysis/js/js_urls.js +2 -1
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +94 -1
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +3 -0
- package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +0 -3
- package/src/test/execute_plan.js +34 -13
- package/src/test/execute_test_plan.js +2 -0
- package/src/test/logs_file_execution.js +47 -38
- package/dist/event_source_client.js.map +0 -188
- package/dist/html_supervisor_installer.js +0 -1236
- package/dist/html_supervisor_installer.js.map +0 -337
- package/dist/html_supervisor_setup.js +0 -95
- package/dist/html_supervisor_setup.js.map +0 -57
- package/dist/import_meta_hot.js.map +0 -42
- package/src/jsenv_root_directory_url.js +0 -1
- package/src/omega/compat/default_runtime_compat.js +0 -11
- package/src/plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -61
- package/src/plugins/transpilation/as_js_classic/client/s.js.md +0 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +0 -270
- package/src/plugins/transpilation/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
- package/src/plugins/transpilation/fetch_original_url_info.js +0 -30
|
@@ -44,24 +44,32 @@ export const createFileService = ({
|
|
|
44
44
|
if (responseFromPlugin) {
|
|
45
45
|
return responseFromPlugin
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
47
|
+
let reference
|
|
48
|
+
const parentUrl = inferParentFromRequest(request, rootDirectoryUrl)
|
|
49
|
+
if (parentUrl) {
|
|
50
|
+
reference = urlGraph.inferReference(request.ressource, parentUrl)
|
|
51
|
+
}
|
|
52
|
+
if (!reference) {
|
|
53
|
+
const entryPoint = kitchen.prepareEntryPoint({
|
|
54
|
+
trace: parentUrl || rootDirectoryUrl,
|
|
55
|
+
parentUrl: parentUrl || rootDirectoryUrl,
|
|
56
|
+
type: "entry_point",
|
|
57
|
+
specifier: request.ressource,
|
|
58
|
+
})
|
|
59
|
+
reference = entryPoint[0]
|
|
60
|
+
}
|
|
61
|
+
const urlInfo = urlGraph.reuseOrCreateUrlInfo(reference.url)
|
|
62
|
+
|
|
52
63
|
const ifNoneMatch = request.headers["if-none-match"]
|
|
53
64
|
if (ifNoneMatch && urlInfo.contentEtag === ifNoneMatch) {
|
|
54
65
|
return {
|
|
55
66
|
status: 304,
|
|
56
67
|
headers: {
|
|
57
68
|
"cache-control": `private,max-age=0,must-revalidate`,
|
|
69
|
+
...urlInfo.responseHeaders,
|
|
58
70
|
},
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
|
-
const referenceFromGraph = urlGraph.inferReference(
|
|
62
|
-
reference.url,
|
|
63
|
-
reference.parentUrl,
|
|
64
|
-
)
|
|
65
73
|
try {
|
|
66
74
|
// urlInfo objects are reused, they must be "reset" before cooking them again
|
|
67
75
|
if (
|
|
@@ -76,20 +84,21 @@ export const createFileService = ({
|
|
|
76
84
|
urlInfo.type = null
|
|
77
85
|
urlInfo.subtype = null
|
|
78
86
|
urlInfo.timing = {}
|
|
87
|
+
urlInfo.responseHeaders = {}
|
|
79
88
|
}
|
|
80
89
|
const { runtimeName, runtimeVersion } = parseUserAgentHeader(
|
|
81
90
|
request.headers["user-agent"],
|
|
82
91
|
)
|
|
83
|
-
await kitchen.cook({
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
await kitchen.cook(urlInfo, {
|
|
93
|
+
request,
|
|
94
|
+
reference,
|
|
95
|
+
clientRuntimeCompat: {
|
|
96
|
+
[runtimeName]: runtimeVersion,
|
|
97
|
+
},
|
|
86
98
|
outDirectoryUrl:
|
|
87
99
|
scenario === "dev"
|
|
88
100
|
? `${rootDirectoryUrl}.jsenv/${runtimeName}@${runtimeVersion}/`
|
|
89
101
|
: `${rootDirectoryUrl}.jsenv/${scenario}/${runtimeName}@${runtimeVersion}/`,
|
|
90
|
-
clientRuntimeCompat: {
|
|
91
|
-
[runtimeName]: runtimeVersion,
|
|
92
|
-
},
|
|
93
102
|
})
|
|
94
103
|
let { response, contentType, content, contentEtag } = urlInfo
|
|
95
104
|
if (response) {
|
|
@@ -103,6 +112,7 @@ export const createFileService = ({
|
|
|
103
112
|
"content-length": Buffer.byteLength(content),
|
|
104
113
|
"cache-control": `private,max-age=0,must-revalidate`,
|
|
105
114
|
"eTag": contentEtag,
|
|
115
|
+
...urlInfo.responseHeaders,
|
|
106
116
|
},
|
|
107
117
|
body: content,
|
|
108
118
|
timing: urlInfo.timing,
|
|
@@ -167,7 +177,6 @@ export const createFileService = ({
|
|
|
167
177
|
}
|
|
168
178
|
return async (request) => {
|
|
169
179
|
let response = await getResponse(request)
|
|
170
|
-
|
|
171
180
|
return response
|
|
172
181
|
}
|
|
173
182
|
}
|
|
@@ -175,7 +184,15 @@ export const createFileService = ({
|
|
|
175
184
|
const inferParentFromRequest = (request, rootDirectoryUrl) => {
|
|
176
185
|
const { referer } = request.headers
|
|
177
186
|
if (!referer) {
|
|
178
|
-
return
|
|
187
|
+
return null
|
|
188
|
+
}
|
|
189
|
+
const refererUrlObject = new URL(referer)
|
|
190
|
+
refererUrlObject.searchParams.delete("hmr")
|
|
191
|
+
refererUrlObject.searchParams.delete("v")
|
|
192
|
+
const { pathname, search } = refererUrlObject
|
|
193
|
+
if (pathname.startsWith("/@fs/")) {
|
|
194
|
+
const fsRootRelativeUrl = pathname.slice("/@fs/".length)
|
|
195
|
+
return `file:///${fsRootRelativeUrl}${search}`
|
|
179
196
|
}
|
|
180
197
|
return moveUrl({
|
|
181
198
|
url: referer,
|
|
@@ -5,32 +5,31 @@ export const loadUrlGraph = async ({
|
|
|
5
5
|
urlGraph,
|
|
6
6
|
kitchen,
|
|
7
7
|
startLoading,
|
|
8
|
+
writeGeneratedFiles,
|
|
8
9
|
outDirectoryUrl,
|
|
9
10
|
clientRuntimeCompat,
|
|
10
11
|
}) => {
|
|
11
|
-
if (outDirectoryUrl) {
|
|
12
|
+
if (writeGeneratedFiles && outDirectoryUrl) {
|
|
12
13
|
await ensureEmptyDirectory(outDirectoryUrl)
|
|
13
14
|
}
|
|
14
15
|
const promises = []
|
|
15
16
|
const promiseMap = new Map()
|
|
16
|
-
const cook = (
|
|
17
|
+
const cook = (urlInfo, context) => {
|
|
17
18
|
const promiseFromData = promiseMap.get(urlInfo)
|
|
18
19
|
if (promiseFromData) return promiseFromData
|
|
19
|
-
const promise = _cook({
|
|
20
|
-
urlInfo,
|
|
20
|
+
const promise = _cook(urlInfo, {
|
|
21
21
|
outDirectoryUrl,
|
|
22
22
|
clientRuntimeCompat,
|
|
23
|
-
...
|
|
23
|
+
...context,
|
|
24
24
|
})
|
|
25
25
|
promises.push(promise)
|
|
26
26
|
promiseMap.set(urlInfo, promise)
|
|
27
27
|
return promise
|
|
28
28
|
}
|
|
29
|
-
const _cook = async (
|
|
30
|
-
await kitchen.cook({
|
|
31
|
-
urlInfo,
|
|
29
|
+
const _cook = async (urlInfo, context) => {
|
|
30
|
+
await kitchen.cook(urlInfo, {
|
|
32
31
|
cookDuringCook: cook,
|
|
33
|
-
...
|
|
32
|
+
...context,
|
|
34
33
|
})
|
|
35
34
|
const { references } = urlInfo
|
|
36
35
|
references.forEach((reference) => {
|
|
@@ -46,10 +45,7 @@ export const loadUrlGraph = async ({
|
|
|
46
45
|
const referencedUrlInfo = urlGraph.reuseOrCreateUrlInfo(
|
|
47
46
|
reference.generatedUrl,
|
|
48
47
|
)
|
|
49
|
-
cook({
|
|
50
|
-
reference,
|
|
51
|
-
urlInfo: referencedUrlInfo,
|
|
52
|
-
})
|
|
48
|
+
cook(referencedUrlInfo, { reference })
|
|
53
49
|
})
|
|
54
50
|
}
|
|
55
51
|
startLoading(
|
|
@@ -61,10 +57,7 @@ export const loadUrlGraph = async ({
|
|
|
61
57
|
specifier,
|
|
62
58
|
})
|
|
63
59
|
entryUrlInfo.data.isEntryPoint = true
|
|
64
|
-
cook({
|
|
65
|
-
reference: entryReference,
|
|
66
|
-
urlInfo: entryUrlInfo,
|
|
67
|
-
})
|
|
60
|
+
cook(entryUrlInfo, { reference: entryReference })
|
|
68
61
|
return [entryReference, entryUrlInfo]
|
|
69
62
|
},
|
|
70
63
|
)
|
|
@@ -37,8 +37,8 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
37
37
|
const urlInfo = urlInfos[url]
|
|
38
38
|
// ignore:
|
|
39
39
|
// - inline files: they are already taken into account in the file where they appear
|
|
40
|
-
// -
|
|
41
|
-
if (urlInfo.isInline || urlInfo.
|
|
40
|
+
// - ignored files: we don't know their content
|
|
41
|
+
if (urlInfo.isInline || !urlInfo.shouldHandle) {
|
|
42
42
|
return
|
|
43
43
|
}
|
|
44
44
|
// file loaded via import assertion are already inside the graph
|
|
@@ -91,10 +91,7 @@ export const createUrlInfoTransformer = ({
|
|
|
91
91
|
specifierColumn: column,
|
|
92
92
|
})
|
|
93
93
|
try {
|
|
94
|
-
await context.cook({
|
|
95
|
-
reference: sourcemapReference,
|
|
96
|
-
urlInfo: sourcemapUrlInfo,
|
|
97
|
-
})
|
|
94
|
+
await context.cook(sourcemapUrlInfo, { reference: sourcemapReference })
|
|
98
95
|
const sourcemap = JSON.parse(sourcemapUrlInfo.content)
|
|
99
96
|
urlInfo.sourcemap = normalizeSourcemap(urlInfo, sourcemap)
|
|
100
97
|
} catch (e) {
|
package/src/omega/url_graph.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
|
+
import { urlSpecifierEncoding } from "./url_specifier_encoding.js"
|
|
2
3
|
|
|
3
4
|
export const createUrlGraph = ({
|
|
4
5
|
clientFileChangeCallbackList,
|
|
@@ -23,13 +24,15 @@ export const createUrlGraph = ({
|
|
|
23
24
|
urlInfos[url] = urlInfo
|
|
24
25
|
return urlInfo
|
|
25
26
|
}
|
|
26
|
-
const inferReference = (
|
|
27
|
+
const inferReference = (specifier, parentUrl) => {
|
|
27
28
|
const parentUrlInfo = urlInfos[parentUrl]
|
|
28
29
|
if (!parentUrlInfo) {
|
|
29
30
|
return null
|
|
30
31
|
}
|
|
31
32
|
const firstReferenceOnThatUrl = parentUrlInfo.references.find(
|
|
32
|
-
(reference) =>
|
|
33
|
+
(reference) => {
|
|
34
|
+
return urlSpecifierEncoding.decode(reference) === specifier
|
|
35
|
+
},
|
|
33
36
|
)
|
|
34
37
|
return firstReferenceOnThatUrl
|
|
35
38
|
}
|
|
@@ -185,12 +188,13 @@ const createUrlInfo = (url) => {
|
|
|
185
188
|
generatedUrl: null,
|
|
186
189
|
isInline: false,
|
|
187
190
|
inlineUrlSite: null,
|
|
188
|
-
|
|
191
|
+
shouldHandle: undefined,
|
|
189
192
|
originalContent: undefined,
|
|
190
193
|
content: undefined,
|
|
191
194
|
contentEtag: null,
|
|
192
195
|
sourcemap: null,
|
|
193
196
|
sourcemapReference: null,
|
|
194
197
|
timing: {},
|
|
198
|
+
responseHeaders: {},
|
|
195
199
|
}
|
|
196
200
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const urlSpecifierEncoding = {
|
|
2
|
+
encode: (reference) => {
|
|
3
|
+
const { generatedSpecifier } = reference
|
|
4
|
+
if (generatedSpecifier.then) {
|
|
5
|
+
return generatedSpecifier.then((value) => {
|
|
6
|
+
reference.generatedSpecifier = value
|
|
7
|
+
return urlSpecifierEncoding.encode(reference)
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
// allow plugin to return a function to bypas default formatting
|
|
11
|
+
// (which is to use JSON.stringify when url is referenced inside js)
|
|
12
|
+
if (typeof generatedSpecifier === "function") {
|
|
13
|
+
return generatedSpecifier()
|
|
14
|
+
}
|
|
15
|
+
const formatter = formatters[reference.type]
|
|
16
|
+
const value = formatter
|
|
17
|
+
? formatter.encode(generatedSpecifier)
|
|
18
|
+
: generatedSpecifier
|
|
19
|
+
if (reference.escape) {
|
|
20
|
+
return reference.escape(value)
|
|
21
|
+
}
|
|
22
|
+
return value
|
|
23
|
+
},
|
|
24
|
+
decode: (reference) => {
|
|
25
|
+
const formatter = formatters[reference.type]
|
|
26
|
+
return formatter
|
|
27
|
+
? formatter.decode(reference.generatedSpecifier)
|
|
28
|
+
: reference.generatedSpecifier
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
const formatters = {
|
|
32
|
+
"js_import_export": { encode: JSON.stringify, decode: JSON.parse },
|
|
33
|
+
"js_url_specifier": { encode: JSON.stringify, decode: JSON.parse },
|
|
34
|
+
"css_@import": { encode: JSON.stringify, code: JSON.stringify },
|
|
35
|
+
// https://github.com/webpack-contrib/css-loader/pull/627/files
|
|
36
|
+
"css_url": {
|
|
37
|
+
encode: (url) => {
|
|
38
|
+
// If url is already wrapped in quotes, remove them
|
|
39
|
+
url = formatters.css_url.decode(url)
|
|
40
|
+
// Should url be wrapped?
|
|
41
|
+
// See https://drafts.csswg.org/css-values-3/#urls
|
|
42
|
+
if (/["'() \t\n]/.test(url)) {
|
|
43
|
+
return `"${url.replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`
|
|
44
|
+
}
|
|
45
|
+
return url
|
|
46
|
+
},
|
|
47
|
+
decode: (url) => {
|
|
48
|
+
const firstChar = url[0]
|
|
49
|
+
const lastChar = url[url.length - 1]
|
|
50
|
+
if (firstChar === `"` && lastChar === `"`) {
|
|
51
|
+
return url.slice(1, -1)
|
|
52
|
+
}
|
|
53
|
+
if (firstChar === `'` && lastChar === `'`) {
|
|
54
|
+
return url.slice(1, -1)
|
|
55
|
+
}
|
|
56
|
+
return url
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { urlIsInsideOf } from "@jsenv/filesystem"
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
parseHtmlString,
|
|
5
3
|
stringifyHtmlAst,
|
|
6
4
|
injectScriptAsEarlyAsPossible,
|
|
7
5
|
createHtmlNode,
|
|
8
6
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
9
|
-
import { jsenvRootDirectoryUrl } from "@jsenv/core/src/jsenv_root_directory_url.js"
|
|
10
7
|
|
|
11
|
-
export const jsenvPluginDevSSEClient = (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
? new URL("./client/event_source_client.js", import.meta.url).href
|
|
17
|
-
: new URL("./dist/event_source_client.js", jsenvRootDirectoryUrl).href
|
|
8
|
+
export const jsenvPluginDevSSEClient = () => {
|
|
9
|
+
const eventSourceClientFileUrl = new URL(
|
|
10
|
+
"./client/event_source_client.js",
|
|
11
|
+
import.meta.url,
|
|
12
|
+
).href
|
|
18
13
|
|
|
19
14
|
return {
|
|
20
15
|
name: "jsenv:dev_sse_client",
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url"
|
|
1
2
|
import {
|
|
2
3
|
isFileSystemPath,
|
|
3
4
|
normalizeStructuredMetaMap,
|
|
4
|
-
urlIsInsideOf,
|
|
5
5
|
urlToMeta,
|
|
6
6
|
} from "@jsenv/filesystem"
|
|
7
7
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
8
8
|
|
|
9
|
+
import { babelHelperNameFromUrl } from "@jsenv/babel-plugins"
|
|
9
10
|
import { applyRollupPlugins } from "@jsenv/utils/js_ast/apply_rollup_plugins.js"
|
|
10
11
|
import { sourcemapConverter } from "@jsenv/utils/sourcemap/sourcemap_converter.js"
|
|
11
12
|
import { fileUrlConverter } from "@jsenv/core/src/omega/file_url_converter.js"
|
|
12
|
-
import { babelHelperNameFromUrl } from "@jsenv/babel-plugins"
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
"../../transpilation/babel/",
|
|
14
|
+
const globalThisClientFileUrl = new URL(
|
|
15
|
+
"../../transpilation/babel/global_this/client/global_this.js",
|
|
16
|
+
import.meta.url,
|
|
17
|
+
).href
|
|
18
|
+
const newStylesheetClientFileUrl = new URL(
|
|
19
|
+
"../../transpilation/babel/new_stylesheet/client/new_stylesheet.js",
|
|
20
|
+
import.meta.url,
|
|
21
|
+
).href
|
|
22
|
+
const regeneratorRuntimeClientFileUrl = new URL(
|
|
23
|
+
"../../transpilation/babel/regenerator_runtime/client/regenerator_runtime.js",
|
|
16
24
|
import.meta.url,
|
|
17
25
|
).href
|
|
18
26
|
|
|
@@ -30,6 +38,7 @@ export const bundleJsModule = async ({
|
|
|
30
38
|
runtimeCompat,
|
|
31
39
|
sourcemaps,
|
|
32
40
|
} = context
|
|
41
|
+
const { babelHelpersChunk = true, include } = options
|
|
33
42
|
const { jsModuleBundleUrlInfos } = await buildWithRollup({
|
|
34
43
|
signal,
|
|
35
44
|
logger,
|
|
@@ -40,7 +49,9 @@ export const bundleJsModule = async ({
|
|
|
40
49
|
|
|
41
50
|
runtimeCompat,
|
|
42
51
|
sourcemaps,
|
|
43
|
-
|
|
52
|
+
|
|
53
|
+
include,
|
|
54
|
+
babelHelpersChunk,
|
|
44
55
|
})
|
|
45
56
|
return jsModuleBundleUrlInfos
|
|
46
57
|
}
|
|
@@ -55,7 +66,9 @@ export const buildWithRollup = async ({
|
|
|
55
66
|
|
|
56
67
|
runtimeCompat,
|
|
57
68
|
sourcemaps,
|
|
58
|
-
|
|
69
|
+
|
|
70
|
+
include,
|
|
71
|
+
babelHelpersChunk,
|
|
59
72
|
}) => {
|
|
60
73
|
const resultRef = { current: null }
|
|
61
74
|
try {
|
|
@@ -71,7 +84,8 @@ export const buildWithRollup = async ({
|
|
|
71
84
|
|
|
72
85
|
runtimeCompat,
|
|
73
86
|
sourcemaps,
|
|
74
|
-
|
|
87
|
+
include,
|
|
88
|
+
babelHelpersChunk,
|
|
75
89
|
resultRef,
|
|
76
90
|
}),
|
|
77
91
|
],
|
|
@@ -81,6 +95,16 @@ export const buildWithRollup = async ({
|
|
|
81
95
|
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
82
96
|
return
|
|
83
97
|
}
|
|
98
|
+
if (
|
|
99
|
+
warning.code === "THIS_IS_UNDEFINED" &&
|
|
100
|
+
pathToFileURL(warning.id).href === globalThisClientFileUrl
|
|
101
|
+
) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (warning.code === "EVAL") {
|
|
105
|
+
// ideally we should disable only for jsenv files
|
|
106
|
+
return
|
|
107
|
+
}
|
|
84
108
|
logger.warn(String(warning))
|
|
85
109
|
},
|
|
86
110
|
},
|
|
@@ -104,7 +128,9 @@ const rollupPluginJsenv = ({
|
|
|
104
128
|
urlGraph,
|
|
105
129
|
jsModuleUrlInfos,
|
|
106
130
|
sourcemaps,
|
|
107
|
-
|
|
131
|
+
|
|
132
|
+
include,
|
|
133
|
+
babelHelpersChunk,
|
|
108
134
|
|
|
109
135
|
resultRef,
|
|
110
136
|
}) => {
|
|
@@ -118,10 +144,10 @@ const rollupPluginJsenv = ({
|
|
|
118
144
|
})
|
|
119
145
|
}
|
|
120
146
|
let importCanBeBundled = () => true
|
|
121
|
-
if (
|
|
147
|
+
if (include) {
|
|
122
148
|
const bundleIncludeConfig = normalizeStructuredMetaMap(
|
|
123
149
|
{
|
|
124
|
-
bundle:
|
|
150
|
+
bundle: include,
|
|
125
151
|
},
|
|
126
152
|
rootDirectoryUrl,
|
|
127
153
|
)
|
|
@@ -152,7 +178,7 @@ const rollupPluginJsenv = ({
|
|
|
152
178
|
implicitlyLoadedAfterOneOf: previousNonEntryPointModuleId
|
|
153
179
|
? [previousNonEntryPointModuleId]
|
|
154
180
|
: null,
|
|
155
|
-
preserveSignature: "allow-extension",
|
|
181
|
+
// preserveSignature: "allow-extension",
|
|
156
182
|
})
|
|
157
183
|
previousNonEntryPointModuleId = id
|
|
158
184
|
})
|
|
@@ -224,19 +250,27 @@ const rollupPluginJsenv = ({
|
|
|
224
250
|
return insideJs ? `js/${name}` : `${name}`
|
|
225
251
|
},
|
|
226
252
|
manualChunks: (id) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
253
|
+
if (babelHelpersChunk) {
|
|
254
|
+
const fileUrl = fileUrlConverter.asFileUrl(id)
|
|
255
|
+
if (
|
|
256
|
+
fileUrl.endsWith(
|
|
257
|
+
"babel-plugin-transform-async-to-promises/helpers.mjs",
|
|
258
|
+
)
|
|
259
|
+
) {
|
|
260
|
+
return "babel_helpers"
|
|
261
|
+
}
|
|
262
|
+
if (babelHelperNameFromUrl(fileUrl)) {
|
|
263
|
+
return "babel_helpers"
|
|
264
|
+
}
|
|
265
|
+
if (fileUrl === globalThisClientFileUrl) {
|
|
266
|
+
return "babel_helpers"
|
|
267
|
+
}
|
|
268
|
+
if (fileUrl === newStylesheetClientFileUrl) {
|
|
269
|
+
return "babel_helpers"
|
|
270
|
+
}
|
|
271
|
+
if (fileUrl === regeneratorRuntimeClientFileUrl) {
|
|
272
|
+
return "babel_helpers"
|
|
273
|
+
}
|
|
240
274
|
}
|
|
241
275
|
return null
|
|
242
276
|
},
|
|
@@ -261,6 +295,14 @@ const rollupPluginJsenv = ({
|
|
|
261
295
|
if (!importCanBeBundled(url)) {
|
|
262
296
|
return { id: url, external: true }
|
|
263
297
|
}
|
|
298
|
+
const urlInfo = urlGraph.getUrlInfo(url)
|
|
299
|
+
if (!urlInfo) {
|
|
300
|
+
// happen when excluded by urlAnalysis.include
|
|
301
|
+
return { id: url, external: true }
|
|
302
|
+
}
|
|
303
|
+
if (!urlInfo.shouldHandle) {
|
|
304
|
+
return { id: url, external: true }
|
|
305
|
+
}
|
|
264
306
|
const filePath = fileUrlConverter.asFilePath(url)
|
|
265
307
|
return filePath
|
|
266
308
|
},
|