@jsenv/core 38.3.2 → 38.3.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/README.md +1 -1
- package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +2 -2
- package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +2 -2
- package/dist/jsenv_core.js +74 -39
- package/package.json +13 -13
- package/src/build/build.js +4 -2
- package/src/build/build_specifier_manager.js +7 -3
- package/src/build/version_mappings_injection.js +4 -2
- package/src/dev/file_service.js +3 -0
- package/src/kitchen/kitchen.js +11 -10
- package/src/kitchen/prepend_content.js +5 -2
- package/src/kitchen/url_graph/url_info_transformations.js +5 -5
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +5 -2
- package/src/plugins/clean_html/jsenv_plugin_clean_html.js +5 -2
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +5 -2
- package/src/plugins/injections/internal/inject_globals.js +5 -3
- package/src/plugins/inlining/jsenv_plugin_inlining_into_html.js +5 -2
- package/src/plugins/plugin_controller.js +5 -2
- package/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js +5 -3
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +5 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The pillars of jsenv are:
|
|
|
9
9
|
3. A build server serving build files
|
|
10
10
|
4. A test runner executing test files in web browser(s)
|
|
11
11
|
|
|
12
|
-
Jsenv cares a lot about the developer experience.
|
|
12
|
+
Jsenv cares a lot about the developer experience.
|
|
13
13
|
As a result it can be enjoyed by people without much experience in tooling or seeking for a simple tool without hidden complexities.
|
|
14
14
|
|
|
15
15
|
[Link to documentation](<https://github.com/jsenv/core/wiki/A)-directory-structure>)
|
|
@@ -136,8 +136,8 @@ function applyDecs2301Factory() {
|
|
|
136
136
|
get && set
|
|
137
137
|
? { get: get, set: set, has: has }
|
|
138
138
|
: get
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
? { get: get, has: has }
|
|
140
|
+
: { set: set, has: has };
|
|
141
141
|
|
|
142
142
|
try {
|
|
143
143
|
return dec(value, ctx);
|
|
@@ -137,8 +137,8 @@ function memberDec(
|
|
|
137
137
|
get && set
|
|
138
138
|
? { get: get, set: set, has: has }
|
|
139
139
|
: get
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
? { get: get, has: has }
|
|
141
|
+
: { set: set, has: has };
|
|
142
142
|
|
|
143
143
|
try {
|
|
144
144
|
return dec.call(thisArg, value, ctx);
|
package/dist/jsenv_core.js
CHANGED
|
@@ -13,7 +13,7 @@ import http from "node:http";
|
|
|
13
13
|
import { Readable, Stream, Writable } from "node:stream";
|
|
14
14
|
import { Http2ServerResponse } from "node:http2";
|
|
15
15
|
import { lookup } from "node:dns";
|
|
16
|
-
import { injectJsImport, visitJsAstUntil, applyBabelPlugins,
|
|
16
|
+
import { injectJsImport, visitJsAstUntil, applyBabelPlugins, parseHtml, visitHtmlNodes, getHtmlNodeAttribute, analyzeScriptNode, getHtmlNodeText, stringifyHtmlAst, setHtmlNodeAttributes, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, generateUrlForInlineContent, parseJsWithAcorn, getHtmlNodePosition, getUrlForContentInsideHtml, getHtmlNodeAttributePosition, parseSrcSet, removeHtmlNodeText, setHtmlNodeText, removeHtmlNode, parseCssUrls, parseJsUrls, getUrlForContentInsideJs, analyzeLinkNode, findHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
|
|
17
17
|
import { sourcemapConverter, createMagicSource, composeTwoSourcemaps, SOURCEMAP, generateSourcemapFileUrl, generateSourcemapDataUrl } from "@jsenv/sourcemap";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { systemJsClientFileUrlDefault, convertJsModuleToJsClassic } from "@jsenv/js-module-fallback";
|
|
@@ -5015,11 +5015,11 @@ const applyRedirectionToRequest = (
|
|
|
5015
5015
|
baseUrl: request.url,
|
|
5016
5016
|
})
|
|
5017
5017
|
: pathname
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5018
|
+
? getPropertiesFromPathname({
|
|
5019
|
+
pathname,
|
|
5020
|
+
baseUrl: request.url,
|
|
5021
|
+
})
|
|
5022
|
+
: {}),
|
|
5023
5023
|
...rest,
|
|
5024
5024
|
};
|
|
5025
5025
|
};
|
|
@@ -5602,13 +5602,13 @@ const applyCompositionForcingLowerCase = (
|
|
|
5602
5602
|
firstKey: keyExistsIn(keyLowercased, firstObject)
|
|
5603
5603
|
? keyLowercased
|
|
5604
5604
|
: keyExistsIn(key, firstObject)
|
|
5605
|
-
|
|
5606
|
-
|
|
5605
|
+
? key
|
|
5606
|
+
: null,
|
|
5607
5607
|
secondKey: keyExistsIn(keyLowercased, secondObject)
|
|
5608
5608
|
? keyLowercased
|
|
5609
5609
|
: keyExistsIn(key, secondObject)
|
|
5610
|
-
|
|
5611
|
-
|
|
5610
|
+
? key
|
|
5611
|
+
: null,
|
|
5612
5612
|
});
|
|
5613
5613
|
});
|
|
5614
5614
|
return composed;
|
|
@@ -10474,7 +10474,7 @@ const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
|
10474
10474
|
},
|
|
10475
10475
|
finalizeUrlContent: {
|
|
10476
10476
|
html: async (urlInfo) => {
|
|
10477
|
-
const htmlAst =
|
|
10477
|
+
const htmlAst = parseHtml({ html: urlInfo.content, url: urlInfo.url });
|
|
10478
10478
|
const mutations = [];
|
|
10479
10479
|
visitHtmlNodes(htmlAst, {
|
|
10480
10480
|
link: (node) => {
|
|
@@ -11368,7 +11368,10 @@ const prependContent = async (
|
|
|
11368
11368
|
};
|
|
11369
11369
|
|
|
11370
11370
|
const prependJsClassicInHtml = (htmlUrlInfo, urlInfoToPrepend) => {
|
|
11371
|
-
const htmlAst =
|
|
11371
|
+
const htmlAst = parseHtml({
|
|
11372
|
+
html: htmlUrlInfo.content,
|
|
11373
|
+
url: htmlUrlInfo.url,
|
|
11374
|
+
});
|
|
11372
11375
|
injectHtmlNodeAsEarlyAsPossible(
|
|
11373
11376
|
htmlAst,
|
|
11374
11377
|
createHtmlNode({
|
|
@@ -12978,7 +12981,10 @@ const returnValueAssertions = [
|
|
|
12978
12981
|
];
|
|
12979
12982
|
|
|
12980
12983
|
const applyScriptInjections = (htmlUrlInfo, scriptInjections, hook) => {
|
|
12981
|
-
const htmlAst =
|
|
12984
|
+
const htmlAst = parseHtml({
|
|
12985
|
+
html: htmlUrlInfo.content,
|
|
12986
|
+
url: htmlUrlInfo.url,
|
|
12987
|
+
});
|
|
12982
12988
|
|
|
12983
12989
|
scriptInjections.reverse().forEach((scriptInjection) => {
|
|
12984
12990
|
const { setup } = scriptInjection;
|
|
@@ -13150,11 +13156,11 @@ const createUrlInfoTransformer = ({
|
|
|
13150
13156
|
return sourcemapsSources(source, urlInfo);
|
|
13151
13157
|
}
|
|
13152
13158
|
: sourcemapsSources === "relative"
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13159
|
+
? (source, urlInfo) => {
|
|
13160
|
+
const sourceRelative = urlToRelativeUrl(source, urlInfo.url);
|
|
13161
|
+
return sourceRelative || ".";
|
|
13162
|
+
}
|
|
13163
|
+
: null;
|
|
13158
13164
|
|
|
13159
13165
|
const normalizeSourcemap = (urlInfo, sourcemap) => {
|
|
13160
13166
|
let { sources } = sourcemap;
|
|
@@ -14393,24 +14399,25 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
14393
14399
|
});
|
|
14394
14400
|
} catch (e) {
|
|
14395
14401
|
urlInfo.error = e;
|
|
14396
|
-
if (
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
// the HTML in itself it still valid
|
|
14402
|
-
// keep the syntax error and continue with the HTML
|
|
14402
|
+
if (
|
|
14403
|
+
urlInfo.isInline &&
|
|
14404
|
+
e.code !== "DIRECTORY_REFERENCE_NOT_ALLOWED" &&
|
|
14405
|
+
errorOnInlineContentCanSkipThrow(urlInfo)
|
|
14406
|
+
) {
|
|
14403
14407
|
const errorInfo =
|
|
14404
14408
|
e.code === "PARSE_ERROR" && e.cause
|
|
14405
14409
|
? `${e.cause.reasonCode}\n${e.traceMessage}`
|
|
14406
14410
|
: e.stack;
|
|
14411
|
+
// When something like <style> or <script> contains syntax error
|
|
14412
|
+
// the HTML in itself it still valid
|
|
14413
|
+
// keep the syntax error and continue with the HTML
|
|
14407
14414
|
logger.error(
|
|
14408
|
-
`Error while
|
|
14415
|
+
`Error while cooking ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
|
|
14409
14416
|
${errorInfo}`,
|
|
14410
14417
|
);
|
|
14411
|
-
|
|
14412
|
-
throw e;
|
|
14418
|
+
return;
|
|
14413
14419
|
}
|
|
14420
|
+
throw e;
|
|
14414
14421
|
}
|
|
14415
14422
|
}
|
|
14416
14423
|
|
|
@@ -15842,8 +15849,10 @@ const jsenvPluginHtmlReferenceAnalysis = ({
|
|
|
15842
15849
|
let importmapFound = false;
|
|
15843
15850
|
const importmapLoaded = startLoadingImportmap(urlInfo);
|
|
15844
15851
|
|
|
15845
|
-
const
|
|
15846
|
-
|
|
15852
|
+
const htmlAst = parseHtml({
|
|
15853
|
+
html: urlInfo.content,
|
|
15854
|
+
url: urlInfo.url,
|
|
15855
|
+
});
|
|
15847
15856
|
|
|
15848
15857
|
const mutations = [];
|
|
15849
15858
|
const actions = [];
|
|
@@ -18409,7 +18418,10 @@ const jsenvPluginInliningIntoHtml = () => {
|
|
|
18409
18418
|
appliesDuring: "*",
|
|
18410
18419
|
transformUrlContent: {
|
|
18411
18420
|
html: async (urlInfo) => {
|
|
18412
|
-
const htmlAst =
|
|
18421
|
+
const htmlAst = parseHtml({
|
|
18422
|
+
html: urlInfo.content,
|
|
18423
|
+
url: urlInfo.url,
|
|
18424
|
+
});
|
|
18413
18425
|
const mutations = [];
|
|
18414
18426
|
const actions = [];
|
|
18415
18427
|
|
|
@@ -19145,7 +19157,10 @@ const jsenvPluginImportMetaHot = () => {
|
|
|
19145
19157
|
if (htmlUrlInfo.context.build) {
|
|
19146
19158
|
return;
|
|
19147
19159
|
}
|
|
19148
|
-
const htmlAst =
|
|
19160
|
+
const htmlAst = parseHtml({
|
|
19161
|
+
html: htmlUrlInfo.content,
|
|
19162
|
+
url: htmlUrlInfo.url,
|
|
19163
|
+
});
|
|
19149
19164
|
const hotReferences = collectHotDataFromHtmlAst(htmlAst);
|
|
19150
19165
|
htmlUrlInfo.data.hotDecline = false;
|
|
19151
19166
|
htmlUrlInfo.data.hotAcceptSelf = false;
|
|
@@ -19332,7 +19347,10 @@ const jsenvPluginAutoreloadClient = () => {
|
|
|
19332
19347
|
appliesDuring: "dev",
|
|
19333
19348
|
transformUrlContent: {
|
|
19334
19349
|
html: (htmlUrlInfo) => {
|
|
19335
|
-
const htmlAst =
|
|
19350
|
+
const htmlAst = parseHtml({
|
|
19351
|
+
html: htmlUrlInfo.content,
|
|
19352
|
+
url: htmlUrlInfo.url,
|
|
19353
|
+
});
|
|
19336
19354
|
const autoreloadClientReference = htmlUrlInfo.dependencies.inject({
|
|
19337
19355
|
type: "script",
|
|
19338
19356
|
subtype: "js_module",
|
|
@@ -19769,7 +19787,10 @@ const jsenvPluginRibbon = ({
|
|
|
19769
19787
|
if (!ribbon) {
|
|
19770
19788
|
return null;
|
|
19771
19789
|
}
|
|
19772
|
-
const htmlAst =
|
|
19790
|
+
const htmlAst = parseHtml({
|
|
19791
|
+
html: urlInfo.content,
|
|
19792
|
+
url: urlInfo.url,
|
|
19793
|
+
});
|
|
19773
19794
|
const ribbonClientFileReference = urlInfo.dependencies.inject({
|
|
19774
19795
|
type: "script",
|
|
19775
19796
|
subtype: "js_module",
|
|
@@ -19804,7 +19825,10 @@ const jsenvPluginCleanHTML = () => {
|
|
|
19804
19825
|
appliesDuring: "dev",
|
|
19805
19826
|
finalizeUrlContent: {
|
|
19806
19827
|
html: (urlInfo) => {
|
|
19807
|
-
const htmlAst =
|
|
19828
|
+
const htmlAst = parseHtml({
|
|
19829
|
+
html: urlInfo.content,
|
|
19830
|
+
url: urlInfo.url,
|
|
19831
|
+
});
|
|
19808
19832
|
return stringifyHtmlAst(htmlAst, {
|
|
19809
19833
|
cleanupPositionAttributes: true,
|
|
19810
19834
|
});
|
|
@@ -20163,7 +20187,9 @@ const generateClientCodeForVersionMappings = (
|
|
|
20163
20187
|
};
|
|
20164
20188
|
|
|
20165
20189
|
const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
|
|
20166
|
-
const htmlAst =
|
|
20190
|
+
const htmlAst = parseHtml({
|
|
20191
|
+
html: urlInfo.content,
|
|
20192
|
+
url: urlInfo.url,
|
|
20167
20193
|
storeOriginalPositions: false,
|
|
20168
20194
|
});
|
|
20169
20195
|
// jsenv_plugin_importmap.js is removing importmap during build
|
|
@@ -20680,7 +20706,9 @@ const createBuildSpecifierManager = ({
|
|
|
20680
20706
|
let content = urlInfo.content;
|
|
20681
20707
|
if (urlInfo.type === "html") {
|
|
20682
20708
|
content = stringifyHtmlAst(
|
|
20683
|
-
|
|
20709
|
+
parseHtml({
|
|
20710
|
+
html: urlInfo.content,
|
|
20711
|
+
url: urlInfo.url,
|
|
20684
20712
|
storeOriginalPositions: false,
|
|
20685
20713
|
}),
|
|
20686
20714
|
{
|
|
@@ -20933,7 +20961,9 @@ const createBuildSpecifierManager = ({
|
|
|
20933
20961
|
if (urlInfo.type !== "html") {
|
|
20934
20962
|
return;
|
|
20935
20963
|
}
|
|
20936
|
-
const htmlAst =
|
|
20964
|
+
const htmlAst = parseHtml({
|
|
20965
|
+
html: urlInfo.content,
|
|
20966
|
+
url: urlInfo.url,
|
|
20937
20967
|
storeOriginalPositions: false,
|
|
20938
20968
|
});
|
|
20939
20969
|
const mutations = [];
|
|
@@ -21930,7 +21960,9 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21930
21960
|
return;
|
|
21931
21961
|
}
|
|
21932
21962
|
if (urlInfo.type === "html") {
|
|
21933
|
-
const htmlAst =
|
|
21963
|
+
const htmlAst = parseHtml({
|
|
21964
|
+
html: urlInfo.content,
|
|
21965
|
+
url: urlInfo.url,
|
|
21934
21966
|
storeOriginalPositions: false,
|
|
21935
21967
|
});
|
|
21936
21968
|
urlInfo.content = stringifyHtmlAst(htmlAst, {
|
|
@@ -22509,6 +22541,9 @@ const createFileService = ({
|
|
|
22509
22541
|
// it's not possible to do that when url info content is not available
|
|
22510
22542
|
// (happens for js_module_fallback for instance)
|
|
22511
22543
|
if (urlInfo.content !== undefined) {
|
|
22544
|
+
kitchen.context.logger.error(`Error while handling ${request.url}:
|
|
22545
|
+
${originalError.reasonCode || originalError.code}
|
|
22546
|
+
${e.traceMessage}`);
|
|
22512
22547
|
return {
|
|
22513
22548
|
url: reference.url,
|
|
22514
22549
|
status: 200,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "38.3.
|
|
3
|
+
"version": "38.3.4",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
|
|
45
45
|
"dev": "node --conditions=development ./scripts/dev/dev.mjs",
|
|
46
46
|
"test": "node --conditions=development ./scripts/test/test.mjs",
|
|
47
|
+
"test:workspace": "npm run test --workspaces --if-present -- --workspace",
|
|
47
48
|
"snapshots:core": "npm run test -- --no-snapshot-assertion",
|
|
48
49
|
"snapshots:packages": "npm run test --workspaces --if-present -- --workspace --no-snapshot-assertion",
|
|
49
50
|
"snapshots:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/generate_snapshot_files.mjs",
|
|
50
|
-
"workspace:test": "npm run test --workspaces --if-present -- --workspace",
|
|
51
51
|
"build": "node --conditions=development ./scripts/build/build.mjs",
|
|
52
52
|
"build:file_size": "node ./scripts/build/build_file_size.mjs --log",
|
|
53
|
-
"workspace
|
|
53
|
+
"build:workspace": "npm run build --workspaces --if-present --conditions=developement",
|
|
54
54
|
"monorepo:upgrade_versions": "node ./scripts/monorepo/upgrade_external_versions.mjs",
|
|
55
55
|
"monorepo:sync_packages_versions": "node ./scripts/monorepo/sync_packages_versions.mjs",
|
|
56
56
|
"monorepo:publish": "node ./scripts/monorepo/publish_packages.mjs",
|
|
@@ -63,17 +63,17 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
65
65
|
"@jsenv/abort": "4.2.4",
|
|
66
|
-
"@jsenv/ast": "
|
|
66
|
+
"@jsenv/ast": "6.0.1",
|
|
67
67
|
"@jsenv/filesystem": "4.3.2",
|
|
68
68
|
"@jsenv/importmap": "1.2.1",
|
|
69
69
|
"@jsenv/integrity": "0.0.1",
|
|
70
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
70
|
+
"@jsenv/js-module-fallback": "1.3.9",
|
|
71
71
|
"@jsenv/log": "3.4.2",
|
|
72
72
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
73
73
|
"@jsenv/plugin-bundling": "2.5.8",
|
|
74
74
|
"@jsenv/plugin-minification": "1.5.4",
|
|
75
|
-
"@jsenv/plugin-supervisor": "1.3.
|
|
76
|
-
"@jsenv/plugin-transpilation": "1.3.
|
|
75
|
+
"@jsenv/plugin-supervisor": "1.3.9",
|
|
76
|
+
"@jsenv/plugin-transpilation": "1.3.8",
|
|
77
77
|
"@jsenv/runtime-compat": "1.2.0",
|
|
78
78
|
"@jsenv/server": "15.1.5",
|
|
79
79
|
"@jsenv/sourcemap": "1.2.4",
|
|
@@ -82,15 +82,15 @@
|
|
|
82
82
|
"@jsenv/utils": "2.0.1"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@babel/eslint-parser": "7.
|
|
86
|
-
"@babel/plugin-syntax-import-assertions": "7.
|
|
85
|
+
"@babel/eslint-parser": "7.23.3",
|
|
86
|
+
"@babel/plugin-syntax-import-assertions": "7.23.3",
|
|
87
87
|
"@jsenv/assert": "./packages/independent/assert/",
|
|
88
88
|
"@jsenv/core": "./",
|
|
89
89
|
"@jsenv/eslint-config": "./packages/independent/eslint-config/",
|
|
90
|
-
"@jsenv/file-size-impact": "14.1.
|
|
90
|
+
"@jsenv/file-size-impact": "14.1.4",
|
|
91
91
|
"@jsenv/https-local": "3.0.7",
|
|
92
|
-
"@jsenv/monorepo": "0.0.
|
|
93
|
-
"@jsenv/performance-impact": "4.1.
|
|
92
|
+
"@jsenv/monorepo": "0.0.4",
|
|
93
|
+
"@jsenv/performance-impact": "4.1.4",
|
|
94
94
|
"@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
|
|
95
95
|
"@jsenv/test": "./packages/related/test/",
|
|
96
96
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
@@ -100,6 +100,6 @@
|
|
|
100
100
|
"eslint-plugin-react": "7.33.2",
|
|
101
101
|
"open": "9.1.0",
|
|
102
102
|
"playwright": "1.39.0",
|
|
103
|
-
"prettier": "3.0
|
|
103
|
+
"prettier": "3.1.0"
|
|
104
104
|
}
|
|
105
105
|
}
|
package/src/build/build.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "@jsenv/filesystem";
|
|
24
24
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
|
|
25
25
|
import { createLogger, createTaskLog } from "@jsenv/log";
|
|
26
|
-
import {
|
|
26
|
+
import { parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
27
27
|
import { jsenvPluginBundling } from "@jsenv/plugin-bundling";
|
|
28
28
|
import { jsenvPluginMinification } from "@jsenv/plugin-minification";
|
|
29
29
|
import { jsenvPluginJsModuleFallback } from "@jsenv/plugin-transpilation";
|
|
@@ -587,7 +587,9 @@ build ${entryPointKeys.length} entry points`);
|
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
589
|
if (urlInfo.type === "html") {
|
|
590
|
-
const htmlAst =
|
|
590
|
+
const htmlAst = parseHtml({
|
|
591
|
+
html: urlInfo.content,
|
|
592
|
+
url: urlInfo.url,
|
|
591
593
|
storeOriginalPositions: false,
|
|
592
594
|
});
|
|
593
595
|
urlInfo.content = stringifyHtmlAst(htmlAst, {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
renderUrlOrRelativeUrlFilename,
|
|
10
10
|
} from "@jsenv/urls";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
parseHtml,
|
|
13
13
|
stringifyHtmlAst,
|
|
14
14
|
visitHtmlNodes,
|
|
15
15
|
getHtmlNodeAttribute,
|
|
@@ -510,7 +510,9 @@ export const createBuildSpecifierManager = ({
|
|
|
510
510
|
let content = urlInfo.content;
|
|
511
511
|
if (urlInfo.type === "html") {
|
|
512
512
|
content = stringifyHtmlAst(
|
|
513
|
-
|
|
513
|
+
parseHtml({
|
|
514
|
+
html: urlInfo.content,
|
|
515
|
+
url: urlInfo.url,
|
|
514
516
|
storeOriginalPositions: false,
|
|
515
517
|
}),
|
|
516
518
|
{
|
|
@@ -763,7 +765,9 @@ export const createBuildSpecifierManager = ({
|
|
|
763
765
|
if (urlInfo.type !== "html") {
|
|
764
766
|
return;
|
|
765
767
|
}
|
|
766
|
-
const htmlAst =
|
|
768
|
+
const htmlAst = parseHtml({
|
|
769
|
+
html: urlInfo.content,
|
|
770
|
+
url: urlInfo.url,
|
|
767
771
|
storeOriginalPositions: false,
|
|
768
772
|
});
|
|
769
773
|
const mutations = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://bundlers.tooling.report/hashing/avoid-cascade/
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
parseHtml,
|
|
5
5
|
injectHtmlNodeAsEarlyAsPossible,
|
|
6
6
|
createHtmlNode,
|
|
7
7
|
stringifyHtmlAst,
|
|
@@ -58,7 +58,9 @@ const generateClientCodeForVersionMappings = (
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
export const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
|
|
61
|
-
const htmlAst =
|
|
61
|
+
const htmlAst = parseHtml({
|
|
62
|
+
html: urlInfo.content,
|
|
63
|
+
url: urlInfo.url,
|
|
62
64
|
storeOriginalPositions: false,
|
|
63
65
|
});
|
|
64
66
|
// jsenv_plugin_importmap.js is removing importmap during build
|
package/src/dev/file_service.js
CHANGED
|
@@ -349,6 +349,9 @@ export const createFileService = ({
|
|
|
349
349
|
// it's not possible to do that when url info content is not available
|
|
350
350
|
// (happens for js_module_fallback for instance)
|
|
351
351
|
if (urlInfo.content !== undefined) {
|
|
352
|
+
kitchen.context.logger.error(`Error while handling ${request.url}:
|
|
353
|
+
${originalError.reasonCode || originalError.code}
|
|
354
|
+
${e.traceMessage}`);
|
|
352
355
|
return {
|
|
353
356
|
url: reference.url,
|
|
354
357
|
status: 200,
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -480,24 +480,25 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
480
480
|
});
|
|
481
481
|
} catch (e) {
|
|
482
482
|
urlInfo.error = e;
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
// the HTML in itself it still valid
|
|
489
|
-
// keep the syntax error and continue with the HTML
|
|
483
|
+
if (
|
|
484
|
+
urlInfo.isInline &&
|
|
485
|
+
e.code !== "DIRECTORY_REFERENCE_NOT_ALLOWED" &&
|
|
486
|
+
errorOnInlineContentCanSkipThrow(urlInfo)
|
|
487
|
+
) {
|
|
490
488
|
const errorInfo =
|
|
491
489
|
e.code === "PARSE_ERROR" && e.cause
|
|
492
490
|
? `${e.cause.reasonCode}\n${e.traceMessage}`
|
|
493
491
|
: e.stack;
|
|
492
|
+
// When something like <style> or <script> contains syntax error
|
|
493
|
+
// the HTML in itself it still valid
|
|
494
|
+
// keep the syntax error and continue with the HTML
|
|
494
495
|
logger.error(
|
|
495
|
-
`Error while
|
|
496
|
+
`Error while cooking ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
|
|
496
497
|
${errorInfo}`,
|
|
497
498
|
);
|
|
498
|
-
|
|
499
|
-
throw e;
|
|
499
|
+
return;
|
|
500
500
|
}
|
|
501
|
+
throw e;
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMagicSource, composeTwoSourcemaps } from "@jsenv/sourcemap";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
parseHtml,
|
|
4
4
|
stringifyHtmlAst,
|
|
5
5
|
createHtmlNode,
|
|
6
6
|
injectHtmlNodeAsEarlyAsPossible,
|
|
@@ -44,7 +44,10 @@ export const prependContent = async (
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const prependJsClassicInHtml = (htmlUrlInfo, urlInfoToPrepend) => {
|
|
47
|
-
const htmlAst =
|
|
47
|
+
const htmlAst = parseHtml({
|
|
48
|
+
html: htmlUrlInfo.content,
|
|
49
|
+
url: htmlUrlInfo.url,
|
|
50
|
+
});
|
|
48
51
|
injectHtmlNodeAsEarlyAsPossible(
|
|
49
52
|
htmlAst,
|
|
50
53
|
createHtmlNode({
|
|
@@ -28,11 +28,11 @@ export const createUrlInfoTransformer = ({
|
|
|
28
28
|
return sourcemapsSources(source, urlInfo);
|
|
29
29
|
}
|
|
30
30
|
: sourcemapsSources === "relative"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
? (source, urlInfo) => {
|
|
32
|
+
const sourceRelative = urlToRelativeUrl(source, urlInfo.url);
|
|
33
|
+
return sourceRelative || ".";
|
|
34
|
+
}
|
|
35
|
+
: null;
|
|
36
36
|
|
|
37
37
|
const normalizeSourcemap = (urlInfo, sourcemap) => {
|
|
38
38
|
let { sources } = sourcemap;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
parseHtml,
|
|
3
3
|
stringifyHtmlAst,
|
|
4
4
|
injectHtmlNodeAsEarlyAsPossible,
|
|
5
5
|
createHtmlNode,
|
|
@@ -16,7 +16,10 @@ export const jsenvPluginAutoreloadClient = () => {
|
|
|
16
16
|
appliesDuring: "dev",
|
|
17
17
|
transformUrlContent: {
|
|
18
18
|
html: (htmlUrlInfo) => {
|
|
19
|
-
const htmlAst =
|
|
19
|
+
const htmlAst = parseHtml({
|
|
20
|
+
html: htmlUrlInfo.content,
|
|
21
|
+
url: htmlUrlInfo.url,
|
|
22
|
+
});
|
|
20
23
|
const autoreloadClientReference = htmlUrlInfo.dependencies.inject({
|
|
21
24
|
type: "script",
|
|
22
25
|
subtype: "js_module",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
2
2
|
|
|
3
3
|
export const jsenvPluginCleanHTML = () => {
|
|
4
4
|
return {
|
|
@@ -6,7 +6,10 @@ export const jsenvPluginCleanHTML = () => {
|
|
|
6
6
|
appliesDuring: "dev",
|
|
7
7
|
finalizeUrlContent: {
|
|
8
8
|
html: (urlInfo) => {
|
|
9
|
-
const htmlAst =
|
|
9
|
+
const htmlAst = parseHtml({
|
|
10
|
+
html: urlInfo.content,
|
|
11
|
+
url: urlInfo.url,
|
|
12
|
+
});
|
|
10
13
|
return stringifyHtmlAst(htmlAst, {
|
|
11
14
|
cleanupPositionAttributes: true,
|
|
12
15
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMagicSource } from "@jsenv/sourcemap";
|
|
2
|
-
import {
|
|
2
|
+
import { parseHtml, applyBabelPlugins } from "@jsenv/ast";
|
|
3
3
|
|
|
4
4
|
import { collectHotDataFromHtmlAst } from "./html_hot_dependencies.js";
|
|
5
5
|
import { babelPluginMetadataImportMetaHot } from "./babel_plugin_metadata_import_meta_hot.js";
|
|
@@ -19,7 +19,10 @@ export const jsenvPluginImportMetaHot = () => {
|
|
|
19
19
|
if (htmlUrlInfo.context.build) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const htmlAst =
|
|
22
|
+
const htmlAst = parseHtml({
|
|
23
|
+
html: htmlUrlInfo.content,
|
|
24
|
+
url: htmlUrlInfo.url,
|
|
25
|
+
});
|
|
23
26
|
const hotReferences = collectHotDataFromHtmlAst(htmlAst);
|
|
24
27
|
htmlUrlInfo.data.hotDecline = false;
|
|
25
28
|
htmlUrlInfo.data.hotAcceptSelf = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMagicSource } from "@jsenv/sourcemap";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
parseHtml,
|
|
4
4
|
injectHtmlNodeAsEarlyAsPossible,
|
|
5
5
|
createHtmlNode,
|
|
6
6
|
stringifyHtmlAst,
|
|
@@ -16,11 +16,13 @@ export const injectGlobals = (content, globals, urlInfo) => {
|
|
|
16
16
|
throw new Error(`cannot inject globals into "${urlInfo.type}"`);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const globalInjectorOnHtml = (content, globals) => {
|
|
19
|
+
const globalInjectorOnHtml = (content, globals, urlInfo) => {
|
|
20
20
|
// ideally we would inject an importmap but browser support is too low
|
|
21
21
|
// (even worse for worker/service worker)
|
|
22
22
|
// so for now we inject code into entry points
|
|
23
|
-
const htmlAst =
|
|
23
|
+
const htmlAst = parseHtml({
|
|
24
|
+
html: content,
|
|
25
|
+
url: urlInfo.url,
|
|
24
26
|
storeOriginalPositions: false,
|
|
25
27
|
});
|
|
26
28
|
const clientCode = generateClientCodeForGlobals(globals, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
parseHtml,
|
|
3
3
|
stringifyHtmlAst,
|
|
4
4
|
visitHtmlNodes,
|
|
5
5
|
getHtmlNodeText,
|
|
@@ -17,7 +17,10 @@ export const jsenvPluginInliningIntoHtml = () => {
|
|
|
17
17
|
appliesDuring: "*",
|
|
18
18
|
transformUrlContent: {
|
|
19
19
|
html: async (urlInfo) => {
|
|
20
|
-
const htmlAst =
|
|
20
|
+
const htmlAst = parseHtml({
|
|
21
|
+
html: urlInfo.content,
|
|
22
|
+
url: urlInfo.url,
|
|
23
|
+
});
|
|
21
24
|
const mutations = [];
|
|
22
25
|
const actions = [];
|
|
23
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
parseHtml,
|
|
4
4
|
stringifyHtmlAst,
|
|
5
5
|
injectHtmlNodeAsEarlyAsPossible,
|
|
6
6
|
createHtmlNode,
|
|
@@ -388,7 +388,10 @@ const returnValueAssertions = [
|
|
|
388
388
|
];
|
|
389
389
|
|
|
390
390
|
const applyScriptInjections = (htmlUrlInfo, scriptInjections, hook) => {
|
|
391
|
-
const htmlAst =
|
|
391
|
+
const htmlAst = parseHtml({
|
|
392
|
+
html: htmlUrlInfo.content,
|
|
393
|
+
url: htmlUrlInfo.url,
|
|
394
|
+
});
|
|
392
395
|
|
|
393
396
|
scriptInjections.reverse().forEach((scriptInjection) => {
|
|
394
397
|
const { setup } = scriptInjection;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
parseHtml,
|
|
3
3
|
visitHtmlNodes,
|
|
4
4
|
getHtmlNodeText,
|
|
5
5
|
setHtmlNodeText,
|
|
@@ -129,8 +129,10 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
|
|
|
129
129
|
let importmapFound = false;
|
|
130
130
|
const importmapLoaded = startLoadingImportmap(urlInfo);
|
|
131
131
|
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const htmlAst = parseHtml({
|
|
133
|
+
html: urlInfo.content,
|
|
134
|
+
url: urlInfo.url,
|
|
135
|
+
});
|
|
134
136
|
|
|
135
137
|
const mutations = [];
|
|
136
138
|
const actions = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
parseHtml,
|
|
3
3
|
stringifyHtmlAst,
|
|
4
4
|
createHtmlNode,
|
|
5
5
|
injectHtmlNodeAsEarlyAsPossible,
|
|
@@ -42,7 +42,10 @@ export const jsenvPluginRibbon = ({
|
|
|
42
42
|
if (!ribbon) {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
const htmlAst =
|
|
45
|
+
const htmlAst = parseHtml({
|
|
46
|
+
html: urlInfo.content,
|
|
47
|
+
url: urlInfo.url,
|
|
48
|
+
});
|
|
46
49
|
const ribbonClientFileReference = urlInfo.dependencies.inject({
|
|
47
50
|
type: "script",
|
|
48
51
|
subtype: "js_module",
|