@jsenv/core 40.0.2 → 40.0.4
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/{js → client/autoreload}/autoreload.js +45 -2
- package/dist/{html → client/directory_listing}/directory_listing.html +2 -2
- package/dist/{js → client/directory_listing/js}/directory_listing.js +3 -3
- package/dist/js/build.js +319 -15321
- package/dist/js/start_build_server.js +8 -4
- package/dist/js/start_dev_server.js +29 -35
- package/dist/jsenv_core.js +13 -1
- package/dist/jsenv_core_packages.js +10061 -0
- package/dist/main.js +117 -0
- package/dist/plugins.js +7944 -0
- package/package.json +17 -17
- package/src/build/build.js +61 -60
- package/src/build/build_params.js +20 -0
- package/src/build/build_specifier_manager.js +10 -0
- package/src/build/build_urls_generator.js +5 -1
- package/src/build/jsenv_plugin_subbuilds.js +71 -0
- package/src/dev/start_dev_server.js +21 -7
- package/src/kitchen/fetched_content_compliance.js +7 -3
- package/src/kitchen/kitchen.js +3 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +1 -4
- package/src/plugins/html_syntax_error_fallback/jsenv_plugin_html_syntax_error_fallback.js +4 -3
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +2 -3
- package/src/plugins/protocol_file/jsenv_plugin_directory_listing.js +1 -2
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +2 -2
- package/dist/js/main.js +0 -994
- package/dist/js/process_teardown_events.js +0 -1848
- /package/dist/babel_helpers/{OverloadYield → overloadYield}/OverloadYield.js +0 -0
- /package/dist/{css → client/directory_listing/css}/directory_listing.css +0 -0
- /package/dist/{other → client/directory_listing/other}/dir.png +0 -0
- /package/dist/{other → client/directory_listing/other}/file.png +0 -0
- /package/dist/{other → client/directory_listing/other}/home.svg +0 -0
- /package/dist/{html → client/html_syntax_error}/html_syntax_error.html +0 -0
- /package/dist/{js → client/import_meta_hot}/import_meta_hot.js +0 -0
- /package/dist/{js → client/inline_content}/inline_content.js +0 -0
- /package/dist/{js → client/new_stylesheet}/new_stylesheet.js +0 -0
- /package/dist/{js → client/regenerator_runtime}/regenerator_runtime.js +0 -0
- /package/dist/{js → client/ribbon}/ribbon.js +0 -0
- /package/dist/{js → client/server_events_client}/server_events_client.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.0.
|
|
3
|
+
"version": "40.0.4",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -78,22 +78,22 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
80
80
|
"@jsenv/abort": "4.3.1",
|
|
81
|
-
"@jsenv/ast": "6.6.
|
|
82
|
-
"@jsenv/filesystem": "4.14.
|
|
81
|
+
"@jsenv/ast": "6.6.5",
|
|
82
|
+
"@jsenv/filesystem": "4.14.2",
|
|
83
83
|
"@jsenv/humanize": "1.3.1",
|
|
84
84
|
"@jsenv/importmap": "1.2.2",
|
|
85
85
|
"@jsenv/integrity": "0.0.2",
|
|
86
|
-
"@jsenv/js-module-fallback": "1.4.
|
|
86
|
+
"@jsenv/js-module-fallback": "1.4.3",
|
|
87
87
|
"@jsenv/node-esm-resolution": "1.1.0",
|
|
88
|
-
"@jsenv/plugin-bundling": "2.8.
|
|
89
|
-
"@jsenv/plugin-minification": "1.6.
|
|
90
|
-
"@jsenv/plugin-supervisor": "1.6.
|
|
91
|
-
"@jsenv/plugin-transpilation": "1.5.
|
|
88
|
+
"@jsenv/plugin-bundling": "2.8.2",
|
|
89
|
+
"@jsenv/plugin-minification": "1.6.2",
|
|
90
|
+
"@jsenv/plugin-supervisor": "1.6.10",
|
|
91
|
+
"@jsenv/plugin-transpilation": "1.5.6",
|
|
92
92
|
"@jsenv/runtime-compat": "1.3.4",
|
|
93
|
-
"@jsenv/server": "16.0.
|
|
94
|
-
"@jsenv/sourcemap": "1.3.
|
|
93
|
+
"@jsenv/server": "16.0.3",
|
|
94
|
+
"@jsenv/sourcemap": "1.3.2",
|
|
95
95
|
"@jsenv/url-meta": "8.5.4",
|
|
96
|
-
"@jsenv/urls": "2.6.
|
|
96
|
+
"@jsenv/urls": "2.6.3",
|
|
97
97
|
"@jsenv/utils": "2.2.1",
|
|
98
98
|
"string-width": "7.2.0"
|
|
99
99
|
},
|
|
@@ -113,14 +113,14 @@
|
|
|
113
113
|
"@jsenv/router": "workspace:*",
|
|
114
114
|
"@jsenv/snapshot": "workspace:*",
|
|
115
115
|
"@jsenv/test": "workspace:*",
|
|
116
|
-
"@playwright/browser-chromium": "1.
|
|
117
|
-
"@playwright/browser-firefox": "1.
|
|
118
|
-
"@playwright/browser-webkit": "1.
|
|
116
|
+
"@playwright/browser-chromium": "1.51.0",
|
|
117
|
+
"@playwright/browser-firefox": "1.51.0",
|
|
118
|
+
"@playwright/browser-webkit": "1.51.0",
|
|
119
119
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
120
|
-
"eslint": "9.
|
|
120
|
+
"eslint": "9.22.0",
|
|
121
121
|
"open": "10.1.0",
|
|
122
|
-
"playwright": "1.
|
|
123
|
-
"prettier": "3.5.
|
|
122
|
+
"playwright": "1.51.0",
|
|
123
|
+
"prettier": "3.5.3",
|
|
124
124
|
"prettier-plugin-organize-imports": "4.1.0",
|
|
125
125
|
"strip-ansi": "7.1.0"
|
|
126
126
|
}
|
package/src/build/build.js
CHANGED
|
@@ -20,6 +20,7 @@ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
|
|
|
20
20
|
import { parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
21
21
|
import {
|
|
22
22
|
assertAndNormalizeDirectoryUrl,
|
|
23
|
+
clearDirectorySync,
|
|
23
24
|
ensureEmptyDirectory,
|
|
24
25
|
lookupPackageDirectory,
|
|
25
26
|
writeFileSync,
|
|
@@ -42,60 +43,48 @@ import {
|
|
|
42
43
|
} from "../plugins/plugin_controller.js";
|
|
43
44
|
import { getCorePlugins } from "../plugins/plugins.js";
|
|
44
45
|
import { jsenvPluginReferenceAnalysis } from "../plugins/reference_analysis/jsenv_plugin_reference_analysis.js";
|
|
46
|
+
import {
|
|
47
|
+
defaultRuntimeCompat,
|
|
48
|
+
getDefaultBase,
|
|
49
|
+
logsDefault,
|
|
50
|
+
} from "./build_params.js";
|
|
45
51
|
import { createBuildSpecifierManager } from "./build_specifier_manager.js";
|
|
46
52
|
import { jsenvPluginLineBreakNormalization } from "./jsenv_plugin_line_break_normalization.js";
|
|
47
|
-
|
|
48
|
-
// default runtimeCompat corresponds to
|
|
49
|
-
// "we can keep <script type="module"> intact":
|
|
50
|
-
// so script_type_module + dynamic_import + import_meta
|
|
51
|
-
export const defaultRuntimeCompat = {
|
|
52
|
-
// android: "8",
|
|
53
|
-
chrome: "64",
|
|
54
|
-
edge: "79",
|
|
55
|
-
firefox: "67",
|
|
56
|
-
ios: "12",
|
|
57
|
-
opera: "51",
|
|
58
|
-
safari: "11.3",
|
|
59
|
-
samsung: "9.2",
|
|
60
|
-
};
|
|
61
|
-
const logsDefault = {
|
|
62
|
-
level: "info",
|
|
63
|
-
disabled: false,
|
|
64
|
-
animation: true,
|
|
65
|
-
};
|
|
53
|
+
import { jsenvPluginSubbuilds } from "./jsenv_plugin_subbuilds.js";
|
|
66
54
|
|
|
67
55
|
/**
|
|
68
|
-
* Generate an optimized version of source files into a directory
|
|
69
|
-
*
|
|
70
|
-
* @param {
|
|
56
|
+
* Generate an optimized version of source files into a directory.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} params
|
|
59
|
+
* @param {string|url} params.sourceDirectoryUrl
|
|
71
60
|
* Directory containing source files
|
|
72
|
-
* @param {string|url}
|
|
61
|
+
* @param {string|url} params.buildDirectoryUrl
|
|
73
62
|
* Directory where optimized files will be written
|
|
74
|
-
* @param {object}
|
|
63
|
+
* @param {object} params.entryPoints
|
|
75
64
|
* Object where keys are paths to source files and values are their future name in the build directory.
|
|
76
65
|
* Keys are relative to sourceDirectoryUrl
|
|
77
|
-
* @param {object}
|
|
66
|
+
* @param {object} params.runtimeCompat
|
|
78
67
|
* Code generated will be compatible with these runtimes
|
|
79
|
-
* @param {string} [
|
|
68
|
+
* @param {string} [params.assetsDirectory=""]
|
|
80
69
|
* Directory where asset files will be written
|
|
81
|
-
* @param {string|url} [
|
|
70
|
+
* @param {string|url} [params.base=""]
|
|
82
71
|
* Urls in build file contents will be prefixed with this string
|
|
83
|
-
* @param {boolean|object} [
|
|
72
|
+
* @param {boolean|object} [params.bundling=true]
|
|
84
73
|
* Reduce number of files written in the build directory
|
|
85
|
-
* @param {boolean|object} [
|
|
74
|
+
* @param {boolean|object} [params.minification=true]
|
|
86
75
|
* Minify the content of files written into the build directory
|
|
87
|
-
* @param {boolean} [
|
|
76
|
+
* @param {boolean} [params.versioning=true]
|
|
88
77
|
* Use versioning on files written in the build directory
|
|
89
|
-
* @param {('search_param'|'filename')} [
|
|
78
|
+
* @param {('search_param'|'filename')} [params.versioningMethod="search_param"]
|
|
90
79
|
* Controls how url are versioned in the build directory
|
|
91
|
-
* @param {('none'|'inline'|'file'|'programmatic')} [
|
|
80
|
+
* @param {('none'|'inline'|'file'|'programmatic')} [params.sourcemaps="none"]
|
|
92
81
|
* Generate sourcemaps in the build directory
|
|
93
|
-
* @param {('error'|'copy'|'preserve')|function} [
|
|
82
|
+
* @param {('error'|'copy'|'preserve')|function} [params.directoryReferenceEffect="error"]
|
|
94
83
|
* What to do when a reference leads to a directory on the filesystem
|
|
95
|
-
* @return {Object} buildReturnValue
|
|
96
|
-
* @return {Object} buildReturnValue.buildInlineContents
|
|
84
|
+
* @return {Promise<Object>} buildReturnValue
|
|
85
|
+
* @return {Promise<Object>} buildReturnValue.buildInlineContents
|
|
97
86
|
* Contains content that is inline into build files
|
|
98
|
-
* @return {Object} buildReturnValue.buildManifest
|
|
87
|
+
* @return {Promise<Object>} buildReturnValue.buildManifest
|
|
99
88
|
* Map build file paths without versioning to versioned file paths
|
|
100
89
|
*/
|
|
101
90
|
export const build = async ({
|
|
@@ -107,9 +96,10 @@ export const build = async ({
|
|
|
107
96
|
entryPoints = {},
|
|
108
97
|
assetsDirectory = "",
|
|
109
98
|
runtimeCompat = defaultRuntimeCompat,
|
|
110
|
-
base = runtimeCompat
|
|
99
|
+
base = getDefaultBase(runtimeCompat),
|
|
111
100
|
ignore,
|
|
112
101
|
|
|
102
|
+
subbuilds = [],
|
|
113
103
|
plugins = [],
|
|
114
104
|
referenceAnalysis = {},
|
|
115
105
|
nodeEsmResolution,
|
|
@@ -132,7 +122,9 @@ export const build = async ({
|
|
|
132
122
|
watch = false,
|
|
133
123
|
http = false,
|
|
134
124
|
|
|
135
|
-
|
|
125
|
+
buildDirectoryCleanPatterns = {
|
|
126
|
+
"**/*": true,
|
|
127
|
+
},
|
|
136
128
|
sourcemaps = "none",
|
|
137
129
|
sourcemapsSourcesContent,
|
|
138
130
|
writeOnFileSystem = true,
|
|
@@ -232,13 +224,6 @@ export const build = async ({
|
|
|
232
224
|
if (assetsDirectory && assetsDirectory[assetsDirectory.length - 1] !== "/") {
|
|
233
225
|
assetsDirectory = `${assetsDirectory}/`;
|
|
234
226
|
}
|
|
235
|
-
if (directoryToClean === undefined) {
|
|
236
|
-
if (assetsDirectory === undefined) {
|
|
237
|
-
directoryToClean = buildDirectoryUrl;
|
|
238
|
-
} else {
|
|
239
|
-
directoryToClean = new URL(assetsDirectory, buildDirectoryUrl).href;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
227
|
|
|
243
228
|
const operation = Abort.startOperation();
|
|
244
229
|
operation.addAbortSignal(signal);
|
|
@@ -284,7 +269,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
284
269
|
break;
|
|
285
270
|
}
|
|
286
271
|
}
|
|
287
|
-
const rawRedirections = new Map();
|
|
288
272
|
const entryUrls = [];
|
|
289
273
|
const contextSharedDuringBuild = {
|
|
290
274
|
buildStep: "craft",
|
|
@@ -310,21 +294,39 @@ build ${entryPointKeys.length} entry points`);
|
|
|
310
294
|
? new URL("craft/", outDirectoryUrl)
|
|
311
295
|
: undefined,
|
|
312
296
|
});
|
|
297
|
+
|
|
298
|
+
let subbuildResults = [];
|
|
299
|
+
|
|
313
300
|
const rawPluginStore = createPluginStore([
|
|
301
|
+
...jsenvPluginSubbuilds(subbuilds, {
|
|
302
|
+
parentBuildParams: {
|
|
303
|
+
sourceDirectoryUrl,
|
|
304
|
+
buildDirectoryUrl,
|
|
305
|
+
runtimeCompat,
|
|
306
|
+
bundling,
|
|
307
|
+
minification,
|
|
308
|
+
versioning,
|
|
309
|
+
versioningMethod,
|
|
310
|
+
},
|
|
311
|
+
onCustomBuildDirectory: (subBuildRelativeUrl) => {
|
|
312
|
+
buildDirectoryCleanPatterns = {
|
|
313
|
+
...buildDirectoryCleanPatterns,
|
|
314
|
+
[`${subBuildRelativeUrl}**/*`]: false,
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
buildStart: async (params, index) => {
|
|
318
|
+
const result = await build({
|
|
319
|
+
...params,
|
|
320
|
+
signal,
|
|
321
|
+
handleSIGINT: false,
|
|
322
|
+
});
|
|
323
|
+
subbuildResults[index] = result;
|
|
324
|
+
return result;
|
|
325
|
+
},
|
|
326
|
+
}),
|
|
314
327
|
...plugins,
|
|
315
328
|
...(bundling ? [jsenvPluginBundling(bundling)] : []),
|
|
316
329
|
...(minification ? [jsenvPluginMinification(minification)] : []),
|
|
317
|
-
{
|
|
318
|
-
appliesDuring: "build",
|
|
319
|
-
fetchUrlContent: (urlInfo) => {
|
|
320
|
-
if (urlInfo.firstReference.original) {
|
|
321
|
-
rawRedirections.set(
|
|
322
|
-
urlInfo.firstReference.original.url,
|
|
323
|
-
urlInfo.firstReference.url,
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
330
|
...getCorePlugins({
|
|
329
331
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
330
332
|
runtimeCompat,
|
|
@@ -694,9 +696,7 @@ build ${entryPointKeys.length} entry points`);
|
|
|
694
696
|
buildSpecifierManager.getBuildInfo();
|
|
695
697
|
if (writeOnFileSystem) {
|
|
696
698
|
const writingFiles = createBuildTask("write files in build directory");
|
|
697
|
-
|
|
698
|
-
await ensureEmptyDirectory(directoryToClean);
|
|
699
|
-
}
|
|
699
|
+
clearDirectorySync(buildDirectoryUrl, buildDirectoryCleanPatterns);
|
|
700
700
|
const buildRelativeUrls = Object.keys(buildFileContents);
|
|
701
701
|
buildRelativeUrls.forEach((buildRelativeUrl) => {
|
|
702
702
|
writeFileSync(
|
|
@@ -720,6 +720,7 @@ build ${entryPointKeys.length} entry points`);
|
|
|
720
720
|
return {
|
|
721
721
|
...(returnBuildInlineContents ? { buildInlineContents } : {}),
|
|
722
722
|
...(returnBuildManifest ? { buildManifest } : {}),
|
|
723
|
+
...(subbuilds.length ? { subbuilds: subbuildResults } : {}),
|
|
723
724
|
};
|
|
724
725
|
};
|
|
725
726
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// default runtimeCompat corresponds to
|
|
2
|
+
// "we can keep <script type="module"> intact":
|
|
3
|
+
// so script_type_module + dynamic_import + import_meta
|
|
4
|
+
export const defaultRuntimeCompat = {
|
|
5
|
+
// android: "8",
|
|
6
|
+
chrome: "64",
|
|
7
|
+
edge: "79",
|
|
8
|
+
firefox: "67",
|
|
9
|
+
ios: "12",
|
|
10
|
+
opera: "51",
|
|
11
|
+
safari: "11.3",
|
|
12
|
+
samsung: "9.2",
|
|
13
|
+
};
|
|
14
|
+
export const logsDefault = {
|
|
15
|
+
level: "info",
|
|
16
|
+
disabled: false,
|
|
17
|
+
animation: true,
|
|
18
|
+
};
|
|
19
|
+
export const getDefaultBase = (runtimeCompat) =>
|
|
20
|
+
runtimeCompat.node ? "./" : "/";
|
|
@@ -259,6 +259,10 @@ export const createBuildSpecifierManager = ({
|
|
|
259
259
|
return placeholder;
|
|
260
260
|
},
|
|
261
261
|
fetchUrlContent: async (finalUrlInfo) => {
|
|
262
|
+
// not need because it will be inherit from rawUrlInfo
|
|
263
|
+
// if (urlIsInsideOf(finalUrlInfo.url, buildDirectoryUrl)) {
|
|
264
|
+
// finalUrlInfo.type = "asset";
|
|
265
|
+
// }
|
|
262
266
|
let { firstReference } = finalUrlInfo;
|
|
263
267
|
if (
|
|
264
268
|
firstReference.isInline &&
|
|
@@ -1018,6 +1022,12 @@ export const createBuildSpecifierManager = ({
|
|
|
1018
1022
|
if (!buildUrl) {
|
|
1019
1023
|
return;
|
|
1020
1024
|
}
|
|
1025
|
+
if (
|
|
1026
|
+
urlInfo.type === "asset" &&
|
|
1027
|
+
urlIsInsideOf(urlInfo.url, buildDirectoryUrl)
|
|
1028
|
+
) {
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1021
1031
|
const buildSpecifier = buildUrlToBuildSpecifierMap.get(buildUrl);
|
|
1022
1032
|
const buildSpecifierVersioned = versioning
|
|
1023
1033
|
? buildSpecifierToBuildSpecifierVersionedMap.get(buildSpecifier)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ANSI } from "@jsenv/humanize";
|
|
2
|
-
import { urlToFilename, urlToRelativeUrl } from "@jsenv/urls";
|
|
2
|
+
import { urlIsInsideOf, urlToFilename, urlToRelativeUrl } from "@jsenv/urls";
|
|
3
3
|
|
|
4
4
|
export const createBuildUrlsGenerator = ({
|
|
5
5
|
logger,
|
|
@@ -33,6 +33,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
33
33
|
if (buildUrlFromCache) {
|
|
34
34
|
return buildUrlFromCache;
|
|
35
35
|
}
|
|
36
|
+
if (urlIsInsideOf(url, buildDirectoryUrl)) {
|
|
37
|
+
buildUrlCache.set(url, url);
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
36
40
|
if (
|
|
37
41
|
urlInfo.type === "directory" ||
|
|
38
42
|
(urlInfo.type === undefined && urlInfo.typeHint === "directory")
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { urlToRelativeUrl } from "@jsenv/urls";
|
|
2
|
+
import { defaultRuntimeCompat, getDefaultBase } from "./build_params.js";
|
|
3
|
+
|
|
4
|
+
export const jsenvPluginSubbuilds = (
|
|
5
|
+
subBuildParamsArray,
|
|
6
|
+
{ parentBuildParams, onCustomBuildDirectory, buildStart },
|
|
7
|
+
) => {
|
|
8
|
+
if (subBuildParamsArray.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return subBuildParamsArray.map((subBuildParams, index) => {
|
|
12
|
+
const defaultChildBuildParams = {};
|
|
13
|
+
const childBuildParams = {
|
|
14
|
+
...parentBuildParams,
|
|
15
|
+
logs: {
|
|
16
|
+
level: "warn",
|
|
17
|
+
disabled: true,
|
|
18
|
+
},
|
|
19
|
+
...defaultChildBuildParams,
|
|
20
|
+
...subBuildParams,
|
|
21
|
+
};
|
|
22
|
+
const subBuildDirectoryUrl = subBuildParams.buildDirectoryUrl;
|
|
23
|
+
if (subBuildDirectoryUrl) {
|
|
24
|
+
const subBuildRelativeUrl = urlToRelativeUrl(
|
|
25
|
+
subBuildDirectoryUrl,
|
|
26
|
+
parentBuildParams.buildDirectoryUrl,
|
|
27
|
+
);
|
|
28
|
+
const subbuildRuntimeCompat =
|
|
29
|
+
childBuildParams.runtimeCompat || defaultRuntimeCompat;
|
|
30
|
+
const subbuildBase =
|
|
31
|
+
subBuildParams.base || getDefaultBase(subbuildRuntimeCompat);
|
|
32
|
+
childBuildParams.base = `${subbuildBase}${subBuildRelativeUrl}`;
|
|
33
|
+
onCustomBuildDirectory(subBuildRelativeUrl);
|
|
34
|
+
}
|
|
35
|
+
const buildPromise = buildStart(childBuildParams, index);
|
|
36
|
+
const entryPointBuildUrlMap = new Map();
|
|
37
|
+
const entryPointSourceUrlSet = new Set();
|
|
38
|
+
const entryPointBuildUrlSet = new Set();
|
|
39
|
+
const childBuildEntryPoints = childBuildParams.entryPoints;
|
|
40
|
+
for (const key of Object.keys(childBuildEntryPoints)) {
|
|
41
|
+
const entryPointUrl = new URL(key, childBuildParams.sourceDirectoryUrl)
|
|
42
|
+
.href;
|
|
43
|
+
const entryPointBuildUrl = new URL(
|
|
44
|
+
childBuildEntryPoints[key],
|
|
45
|
+
childBuildParams.buildDirectoryUrl,
|
|
46
|
+
).href;
|
|
47
|
+
entryPointBuildUrlMap.set(entryPointUrl, entryPointBuildUrl);
|
|
48
|
+
entryPointSourceUrlSet.add(entryPointUrl);
|
|
49
|
+
entryPointBuildUrlSet.add(entryPointBuildUrl);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
name: `jsenv:subbuild_${index}`,
|
|
54
|
+
redirectReference: (reference) => {
|
|
55
|
+
const entryPointBuildUrl = entryPointBuildUrlMap.get(reference.url);
|
|
56
|
+
if (!entryPointBuildUrl) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return entryPointBuildUrl;
|
|
60
|
+
},
|
|
61
|
+
fetchUrlContent: async (urlInfo) => {
|
|
62
|
+
if (!entryPointBuildUrlSet.has(urlInfo.url)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
await buildPromise;
|
|
66
|
+
urlInfo.typeHint = "asset"; // this ensure the rest of jsenv do not scan or modify the content of this file
|
|
67
|
+
return null;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -16,7 +16,7 @@ import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/in
|
|
|
16
16
|
import { URL_META } from "@jsenv/url-meta";
|
|
17
17
|
import { urlIsInsideOf, urlToRelativeUrl } from "@jsenv/urls";
|
|
18
18
|
import { existsSync, readFileSync } from "node:fs";
|
|
19
|
-
import { defaultRuntimeCompat } from "../build/
|
|
19
|
+
import { defaultRuntimeCompat } from "../build/build_params.js";
|
|
20
20
|
import { createEventEmitter } from "../helpers/event_emitter.js";
|
|
21
21
|
import { watchSourceFiles } from "../helpers/watch_source_files.js";
|
|
22
22
|
import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
|
|
@@ -33,12 +33,26 @@ import { parseUserAgentHeader } from "./user_agent.js";
|
|
|
33
33
|
const EXECUTED_BY_TEST_PLAN = process.argv.includes("--jsenv-test");
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {string
|
|
41
|
-
* @
|
|
36
|
+
* Starts the development server.
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} [params={}] - Configuration params for the dev server.
|
|
39
|
+
* @param {number} [params.port=3456] - Port number the server should listen on.
|
|
40
|
+
* @param {string} [params.hostname="localhost"] - Hostname to bind the server to.
|
|
41
|
+
* @param {boolean} [params.https=false] - Whether to use HTTPS.
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<Object>} A promise that resolves to the server instance.
|
|
44
|
+
* @throws {Error} Will throw an error if the server fails to start or is called with unexpected params.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Start a basic dev server
|
|
48
|
+
* const server = await startDevServer();
|
|
49
|
+
* console.log(`Server started at ${server.origin}`);
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Start a server with custom params
|
|
53
|
+
* const server = await startDevServer({
|
|
54
|
+
* port: 8080,
|
|
55
|
+
* });
|
|
42
56
|
*/
|
|
43
57
|
export const startDevServer = async ({
|
|
44
58
|
sourceDirectoryUrl,
|
|
@@ -12,9 +12,13 @@ export const assertFetchedContentCompliance = ({ urlInfo, content }) => {
|
|
|
12
12
|
}
|
|
13
13
|
const { expectedType } = urlInfo.firstReference;
|
|
14
14
|
if (expectedType && urlInfo.type !== expectedType) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (urlInfo.type === "asset" && urlInfo.context.build) {
|
|
16
|
+
// asset is a valid type during build
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`type must be "${expectedType}", got "${urlInfo.type}" on ${urlInfo.url}`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
const { integrity } = urlInfo.firstReference;
|
|
20
24
|
if (integrity) {
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -681,6 +681,9 @@ const inferUrlInfoType = (urlInfo) => {
|
|
|
681
681
|
const { type, typeHint } = urlInfo;
|
|
682
682
|
const mediaType = CONTENT_TYPE.asMediaType(urlInfo.contentType);
|
|
683
683
|
const { expectedType } = urlInfo.firstReference;
|
|
684
|
+
if (typeHint === "asset") {
|
|
685
|
+
return "asset";
|
|
686
|
+
}
|
|
684
687
|
if (type === "sourcemap" || typeHint === "sourcemap") {
|
|
685
688
|
return "sourcemap";
|
|
686
689
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { injectJsenvScript, parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
2
2
|
|
|
3
3
|
export const jsenvPluginAutoreloadClient = () => {
|
|
4
|
-
const autoreloadClientFileUrl =
|
|
5
|
-
"./client/autoreload.js",
|
|
6
|
-
import.meta.url,
|
|
7
|
-
).href;
|
|
4
|
+
const autoreloadClientFileUrl = import.meta.resolve("./client/autoreload.js");
|
|
8
5
|
|
|
9
6
|
return {
|
|
10
7
|
name: "jsenv:autoreload_client",
|
|
@@ -5,9 +5,8 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
import { jsenvCoreDirectoryUrl } from "../../jsenv_core_directory_url.js";
|
|
6
6
|
|
|
7
7
|
export const jsenvPluginHtmlSyntaxErrorFallback = () => {
|
|
8
|
-
const htmlSyntaxErrorFileUrl =
|
|
8
|
+
const htmlSyntaxErrorFileUrl = import.meta.resolve(
|
|
9
9
|
"./client/html_syntax_error.html",
|
|
10
|
-
import.meta.url,
|
|
11
10
|
);
|
|
12
11
|
|
|
13
12
|
return {
|
|
@@ -55,7 +54,9 @@ const generateHtmlForSyntaxError = (
|
|
|
55
54
|
htmlSyntaxError,
|
|
56
55
|
{ htmlUrl, rootDirectoryUrl, htmlErrorContentFrame, htmlSyntaxErrorFileUrl },
|
|
57
56
|
) => {
|
|
58
|
-
const htmlForSyntaxError = String(
|
|
57
|
+
const htmlForSyntaxError = String(
|
|
58
|
+
readFileSync(new URL(htmlSyntaxErrorFileUrl)),
|
|
59
|
+
);
|
|
59
60
|
const htmlRelativeUrl = urlToRelativeUrl(htmlUrl, rootDirectoryUrl);
|
|
60
61
|
const { line, column } = htmlSyntaxError;
|
|
61
62
|
if (htmlUrl.startsWith(jsenvCoreDirectoryUrl.href)) {
|
|
@@ -5,10 +5,9 @@ import { babelPluginMetadataImportMetaHot } from "./babel_plugin_metadata_import
|
|
|
5
5
|
import { collectHotDataFromHtmlAst } from "./html_hot_dependencies.js";
|
|
6
6
|
|
|
7
7
|
export const jsenvPluginImportMetaHot = () => {
|
|
8
|
-
const importMetaHotClientFileUrl =
|
|
8
|
+
const importMetaHotClientFileUrl = import.meta.resolve(
|
|
9
9
|
"./client/import_meta_hot.js",
|
|
10
|
-
|
|
11
|
-
).href;
|
|
10
|
+
);
|
|
12
11
|
|
|
13
12
|
return {
|
|
14
13
|
name: "jsenv:import_meta_hot",
|
|
@@ -41,9 +41,8 @@ import { getDirectoryWatchPatterns } from "../../helpers/watch_source_files.js";
|
|
|
41
41
|
import { replacePlaceholders } from "../injections/jsenv_plugin_injections.js";
|
|
42
42
|
import { FILE_AND_SERVER_URLS_CONVERTER } from "./file_and_server_urls_converter.js";
|
|
43
43
|
|
|
44
|
-
const htmlFileUrlForDirectory =
|
|
44
|
+
const htmlFileUrlForDirectory = import.meta.resolve(
|
|
45
45
|
"./client/directory_listing.html",
|
|
46
|
-
import.meta.url,
|
|
47
46
|
);
|
|
48
47
|
|
|
49
48
|
export const jsenvPluginDirectoryListing = ({
|
|
@@ -6,7 +6,7 @@ export const jsenvPluginRibbon = ({
|
|
|
6
6
|
rootDirectoryUrl,
|
|
7
7
|
htmlInclude = "/**/*.html",
|
|
8
8
|
}) => {
|
|
9
|
-
const ribbonClientFileUrl =
|
|
9
|
+
const ribbonClientFileUrl = import.meta.resolve("./client/ribbon.js");
|
|
10
10
|
const associations = URL_META.resolveAssociations(
|
|
11
11
|
{
|
|
12
12
|
ribbon: {
|
|
@@ -45,7 +45,7 @@ export const jsenvPluginRibbon = ({
|
|
|
45
45
|
type: "script",
|
|
46
46
|
subtype: "js_module",
|
|
47
47
|
expectedType: "js_module",
|
|
48
|
-
specifier: ribbonClientFileUrl
|
|
48
|
+
specifier: ribbonClientFileUrl,
|
|
49
49
|
});
|
|
50
50
|
injectJsenvScript(htmlAst, {
|
|
51
51
|
type: "module",
|