@jsenv/core 38.3.1 → 38.3.3
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 +2 -1
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +26 -18
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +9 -4
- package/dist/jsenv_core.js +61 -27
- package/package.json +19 -17
- 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/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,8 @@ 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
|
+
As a result it can be enjoyed by people without much experience in tooling or seeking for a simple tool without hidden complexities.
|
|
13
14
|
|
|
14
15
|
[Link to documentation](<https://github.com/jsenv/core/wiki/A)-directory-structure>)
|
|
15
16
|
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
function _getRequireWildcardCache(nodeInterop) {
|
|
2
|
-
if (typeof WeakMap !== "function") return null
|
|
3
|
-
|
|
4
|
-
var
|
|
2
|
+
if (typeof WeakMap !== "function") return null;
|
|
3
|
+
|
|
4
|
+
var cacheBabelInterop = new WeakMap();
|
|
5
|
+
var cacheNodeInterop = new WeakMap();
|
|
5
6
|
return (_getRequireWildcardCache = function (nodeInterop) {
|
|
6
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop
|
|
7
|
-
})(nodeInterop)
|
|
7
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
8
|
+
})(nodeInterop);
|
|
8
9
|
}
|
|
10
|
+
|
|
9
11
|
export default function _interopRequireWildcard(obj, nodeInterop) {
|
|
10
12
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
11
|
-
return obj
|
|
13
|
+
return obj;
|
|
12
14
|
}
|
|
15
|
+
|
|
13
16
|
if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
|
|
14
|
-
return { default: obj }
|
|
17
|
+
return { default: obj };
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
|
|
20
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
17
21
|
if (cache && cache.has(obj)) {
|
|
18
|
-
return cache.get(obj)
|
|
22
|
+
return cache.get(obj);
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
var
|
|
24
|
+
|
|
25
|
+
var newObj = { __proto__: null };
|
|
26
|
+
var hasPropertyDescriptor =
|
|
27
|
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
22
28
|
for (var key in obj) {
|
|
23
29
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
24
|
-
var desc = hasPropertyDescriptor
|
|
30
|
+
var desc = hasPropertyDescriptor
|
|
31
|
+
? Object.getOwnPropertyDescriptor(obj, key)
|
|
32
|
+
: null;
|
|
25
33
|
if (desc && (desc.get || desc.set)) {
|
|
26
|
-
Object.defineProperty(newObj, key, desc)
|
|
34
|
+
Object.defineProperty(newObj, key, desc);
|
|
27
35
|
} else {
|
|
28
|
-
newObj[key] = obj[key]
|
|
36
|
+
newObj[key] = obj[key];
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
|
-
newObj.default = obj
|
|
40
|
+
newObj.default = obj;
|
|
33
41
|
if (cache) {
|
|
34
|
-
cache.set(obj, newObj)
|
|
42
|
+
cache.set(obj, newObj);
|
|
35
43
|
}
|
|
36
|
-
return newObj
|
|
37
|
-
}
|
|
44
|
+
return newObj;
|
|
45
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export default function _isNativeFunction(fn) {
|
|
2
|
+
// Note: This function returns "true" for core-js functions.
|
|
3
|
+
try {
|
|
4
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
5
|
+
} catch (e) {
|
|
6
|
+
// Firefox 31 throws when "toString" is applied to an HTMLElement
|
|
7
|
+
return typeof fn === "function";
|
|
8
|
+
}
|
|
9
|
+
}
|
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";
|
|
@@ -3245,8 +3245,7 @@ function isUnicodeSupported() {
|
|
|
3245
3245
|
return process$1.env.TERM !== 'linux'; // Linux console (kernel)
|
|
3246
3246
|
}
|
|
3247
3247
|
|
|
3248
|
-
return Boolean(process$1.env.
|
|
3249
|
-
|| Boolean(process$1.env.WT_SESSION) // Windows Terminal
|
|
3248
|
+
return Boolean(process$1.env.WT_SESSION) // Windows Terminal
|
|
3250
3249
|
|| Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
3251
3250
|
|| process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
3252
3251
|
|| process$1.env.TERM_PROGRAM === 'Terminus-Sublime'
|
|
@@ -10475,7 +10474,7 @@ const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
|
10475
10474
|
},
|
|
10476
10475
|
finalizeUrlContent: {
|
|
10477
10476
|
html: async (urlInfo) => {
|
|
10478
|
-
const htmlAst =
|
|
10477
|
+
const htmlAst = parseHtml({ html: urlInfo.content, url: urlInfo.url });
|
|
10479
10478
|
const mutations = [];
|
|
10480
10479
|
visitHtmlNodes(htmlAst, {
|
|
10481
10480
|
link: (node) => {
|
|
@@ -11369,7 +11368,10 @@ const prependContent = async (
|
|
|
11369
11368
|
};
|
|
11370
11369
|
|
|
11371
11370
|
const prependJsClassicInHtml = (htmlUrlInfo, urlInfoToPrepend) => {
|
|
11372
|
-
const htmlAst =
|
|
11371
|
+
const htmlAst = parseHtml({
|
|
11372
|
+
html: htmlUrlInfo.content,
|
|
11373
|
+
url: htmlUrlInfo.url,
|
|
11374
|
+
});
|
|
11373
11375
|
injectHtmlNodeAsEarlyAsPossible(
|
|
11374
11376
|
htmlAst,
|
|
11375
11377
|
createHtmlNode({
|
|
@@ -12979,7 +12981,10 @@ const returnValueAssertions = [
|
|
|
12979
12981
|
];
|
|
12980
12982
|
|
|
12981
12983
|
const applyScriptInjections = (htmlUrlInfo, scriptInjections, hook) => {
|
|
12982
|
-
const htmlAst =
|
|
12984
|
+
const htmlAst = parseHtml({
|
|
12985
|
+
html: htmlUrlInfo.content,
|
|
12986
|
+
url: htmlUrlInfo.url,
|
|
12987
|
+
});
|
|
12983
12988
|
|
|
12984
12989
|
scriptInjections.reverse().forEach((scriptInjection) => {
|
|
12985
12990
|
const { setup } = scriptInjection;
|
|
@@ -14394,24 +14399,25 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
14394
14399
|
});
|
|
14395
14400
|
} catch (e) {
|
|
14396
14401
|
urlInfo.error = e;
|
|
14397
|
-
if (
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
// the HTML in itself it still valid
|
|
14403
|
-
// 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
|
+
) {
|
|
14404
14407
|
const errorInfo =
|
|
14405
14408
|
e.code === "PARSE_ERROR" && e.cause
|
|
14406
14409
|
? `${e.cause.reasonCode}\n${e.traceMessage}`
|
|
14407
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
|
|
14408
14414
|
logger.error(
|
|
14409
|
-
`Error while
|
|
14415
|
+
`Error while cooking ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
|
|
14410
14416
|
${errorInfo}`,
|
|
14411
14417
|
);
|
|
14412
|
-
|
|
14413
|
-
throw e;
|
|
14418
|
+
return;
|
|
14414
14419
|
}
|
|
14420
|
+
throw e;
|
|
14415
14421
|
}
|
|
14416
14422
|
}
|
|
14417
14423
|
|
|
@@ -15843,8 +15849,10 @@ const jsenvPluginHtmlReferenceAnalysis = ({
|
|
|
15843
15849
|
let importmapFound = false;
|
|
15844
15850
|
const importmapLoaded = startLoadingImportmap(urlInfo);
|
|
15845
15851
|
|
|
15846
|
-
const
|
|
15847
|
-
|
|
15852
|
+
const htmlAst = parseHtml({
|
|
15853
|
+
html: urlInfo.content,
|
|
15854
|
+
url: urlInfo.url,
|
|
15855
|
+
});
|
|
15848
15856
|
|
|
15849
15857
|
const mutations = [];
|
|
15850
15858
|
const actions = [];
|
|
@@ -18410,7 +18418,10 @@ const jsenvPluginInliningIntoHtml = () => {
|
|
|
18410
18418
|
appliesDuring: "*",
|
|
18411
18419
|
transformUrlContent: {
|
|
18412
18420
|
html: async (urlInfo) => {
|
|
18413
|
-
const htmlAst =
|
|
18421
|
+
const htmlAst = parseHtml({
|
|
18422
|
+
html: urlInfo.content,
|
|
18423
|
+
url: urlInfo.url,
|
|
18424
|
+
});
|
|
18414
18425
|
const mutations = [];
|
|
18415
18426
|
const actions = [];
|
|
18416
18427
|
|
|
@@ -19146,7 +19157,10 @@ const jsenvPluginImportMetaHot = () => {
|
|
|
19146
19157
|
if (htmlUrlInfo.context.build) {
|
|
19147
19158
|
return;
|
|
19148
19159
|
}
|
|
19149
|
-
const htmlAst =
|
|
19160
|
+
const htmlAst = parseHtml({
|
|
19161
|
+
html: htmlUrlInfo.content,
|
|
19162
|
+
url: htmlUrlInfo.url,
|
|
19163
|
+
});
|
|
19150
19164
|
const hotReferences = collectHotDataFromHtmlAst(htmlAst);
|
|
19151
19165
|
htmlUrlInfo.data.hotDecline = false;
|
|
19152
19166
|
htmlUrlInfo.data.hotAcceptSelf = false;
|
|
@@ -19333,7 +19347,10 @@ const jsenvPluginAutoreloadClient = () => {
|
|
|
19333
19347
|
appliesDuring: "dev",
|
|
19334
19348
|
transformUrlContent: {
|
|
19335
19349
|
html: (htmlUrlInfo) => {
|
|
19336
|
-
const htmlAst =
|
|
19350
|
+
const htmlAst = parseHtml({
|
|
19351
|
+
html: htmlUrlInfo.content,
|
|
19352
|
+
url: htmlUrlInfo.url,
|
|
19353
|
+
});
|
|
19337
19354
|
const autoreloadClientReference = htmlUrlInfo.dependencies.inject({
|
|
19338
19355
|
type: "script",
|
|
19339
19356
|
subtype: "js_module",
|
|
@@ -19770,7 +19787,10 @@ const jsenvPluginRibbon = ({
|
|
|
19770
19787
|
if (!ribbon) {
|
|
19771
19788
|
return null;
|
|
19772
19789
|
}
|
|
19773
|
-
const htmlAst =
|
|
19790
|
+
const htmlAst = parseHtml({
|
|
19791
|
+
html: urlInfo.content,
|
|
19792
|
+
url: urlInfo.url,
|
|
19793
|
+
});
|
|
19774
19794
|
const ribbonClientFileReference = urlInfo.dependencies.inject({
|
|
19775
19795
|
type: "script",
|
|
19776
19796
|
subtype: "js_module",
|
|
@@ -19805,7 +19825,10 @@ const jsenvPluginCleanHTML = () => {
|
|
|
19805
19825
|
appliesDuring: "dev",
|
|
19806
19826
|
finalizeUrlContent: {
|
|
19807
19827
|
html: (urlInfo) => {
|
|
19808
|
-
const htmlAst =
|
|
19828
|
+
const htmlAst = parseHtml({
|
|
19829
|
+
html: urlInfo.content,
|
|
19830
|
+
url: urlInfo.url,
|
|
19831
|
+
});
|
|
19809
19832
|
return stringifyHtmlAst(htmlAst, {
|
|
19810
19833
|
cleanupPositionAttributes: true,
|
|
19811
19834
|
});
|
|
@@ -20164,7 +20187,9 @@ const generateClientCodeForVersionMappings = (
|
|
|
20164
20187
|
};
|
|
20165
20188
|
|
|
20166
20189
|
const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
|
|
20167
|
-
const htmlAst =
|
|
20190
|
+
const htmlAst = parseHtml({
|
|
20191
|
+
html: urlInfo.content,
|
|
20192
|
+
url: urlInfo.url,
|
|
20168
20193
|
storeOriginalPositions: false,
|
|
20169
20194
|
});
|
|
20170
20195
|
// jsenv_plugin_importmap.js is removing importmap during build
|
|
@@ -20681,7 +20706,9 @@ const createBuildSpecifierManager = ({
|
|
|
20681
20706
|
let content = urlInfo.content;
|
|
20682
20707
|
if (urlInfo.type === "html") {
|
|
20683
20708
|
content = stringifyHtmlAst(
|
|
20684
|
-
|
|
20709
|
+
parseHtml({
|
|
20710
|
+
html: urlInfo.content,
|
|
20711
|
+
url: urlInfo.url,
|
|
20685
20712
|
storeOriginalPositions: false,
|
|
20686
20713
|
}),
|
|
20687
20714
|
{
|
|
@@ -20934,7 +20961,9 @@ const createBuildSpecifierManager = ({
|
|
|
20934
20961
|
if (urlInfo.type !== "html") {
|
|
20935
20962
|
return;
|
|
20936
20963
|
}
|
|
20937
|
-
const htmlAst =
|
|
20964
|
+
const htmlAst = parseHtml({
|
|
20965
|
+
html: urlInfo.content,
|
|
20966
|
+
url: urlInfo.url,
|
|
20938
20967
|
storeOriginalPositions: false,
|
|
20939
20968
|
});
|
|
20940
20969
|
const mutations = [];
|
|
@@ -21931,7 +21960,9 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21931
21960
|
return;
|
|
21932
21961
|
}
|
|
21933
21962
|
if (urlInfo.type === "html") {
|
|
21934
|
-
const htmlAst =
|
|
21963
|
+
const htmlAst = parseHtml({
|
|
21964
|
+
html: urlInfo.content,
|
|
21965
|
+
url: urlInfo.url,
|
|
21935
21966
|
storeOriginalPositions: false,
|
|
21936
21967
|
});
|
|
21937
21968
|
urlInfo.content = stringifyHtmlAst(htmlAst, {
|
|
@@ -22510,6 +22541,9 @@ const createFileService = ({
|
|
|
22510
22541
|
// it's not possible to do that when url info content is not available
|
|
22511
22542
|
// (happens for js_module_fallback for instance)
|
|
22512
22543
|
if (urlInfo.content !== undefined) {
|
|
22544
|
+
kitchen.context.logger.error(`Error while handling ${request.url}:
|
|
22545
|
+
${originalError.reasonCode || originalError.code}
|
|
22546
|
+
${e.traceMessage}`);
|
|
22513
22547
|
return {
|
|
22514
22548
|
url: reference.url,
|
|
22515
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.3",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -44,14 +44,16 @@
|
|
|
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:
|
|
47
|
+
"test:workspace": "npm run test --workspaces --if-present -- --workspace",
|
|
48
48
|
"snapshots:core": "npm run test -- --no-snapshot-assertion",
|
|
49
49
|
"snapshots:packages": "npm run test --workspaces --if-present -- --workspace --no-snapshot-assertion",
|
|
50
50
|
"snapshots:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/generate_snapshot_files.mjs",
|
|
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
|
|
54
|
-
"
|
|
53
|
+
"build:workspace": "npm run build --workspaces --if-present --conditions=developement",
|
|
54
|
+
"monorepo:upgrade_versions": "node ./scripts/monorepo/upgrade_external_versions.mjs",
|
|
55
|
+
"monorepo:sync_packages_versions": "node ./scripts/monorepo/sync_packages_versions.mjs",
|
|
56
|
+
"monorepo:publish": "node ./scripts/monorepo/publish_packages.mjs",
|
|
55
57
|
"performances": "node --expose-gc ./scripts/performance/generate_performance_report.mjs --log --once",
|
|
56
58
|
"prettier": "prettier --write .",
|
|
57
59
|
"playwright:install": "npx playwright install-deps && npx playwright install",
|
|
@@ -61,20 +63,20 @@
|
|
|
61
63
|
"dependencies": {
|
|
62
64
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
63
65
|
"@jsenv/abort": "4.2.4",
|
|
64
|
-
"@jsenv/ast": "
|
|
66
|
+
"@jsenv/ast": "6.0.0",
|
|
65
67
|
"@jsenv/filesystem": "4.3.2",
|
|
66
68
|
"@jsenv/importmap": "1.2.1",
|
|
67
69
|
"@jsenv/integrity": "0.0.1",
|
|
68
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
69
|
-
"@jsenv/log": "3.4.
|
|
70
|
+
"@jsenv/js-module-fallback": "1.3.8",
|
|
71
|
+
"@jsenv/log": "3.4.2",
|
|
70
72
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
71
|
-
"@jsenv/plugin-bundling": "2.5.
|
|
72
|
-
"@jsenv/plugin-minification": "1.5.
|
|
73
|
-
"@jsenv/plugin-supervisor": "1.3.
|
|
74
|
-
"@jsenv/plugin-transpilation": "1.3.
|
|
73
|
+
"@jsenv/plugin-bundling": "2.5.8",
|
|
74
|
+
"@jsenv/plugin-minification": "1.5.4",
|
|
75
|
+
"@jsenv/plugin-supervisor": "1.3.8",
|
|
76
|
+
"@jsenv/plugin-transpilation": "1.3.7",
|
|
75
77
|
"@jsenv/runtime-compat": "1.2.0",
|
|
76
|
-
"@jsenv/server": "15.1.
|
|
77
|
-
"@jsenv/sourcemap": "1.2.
|
|
78
|
+
"@jsenv/server": "15.1.5",
|
|
79
|
+
"@jsenv/sourcemap": "1.2.4",
|
|
78
80
|
"@jsenv/url-meta": "8.1.0",
|
|
79
81
|
"@jsenv/urls": "2.2.1",
|
|
80
82
|
"@jsenv/utils": "2.0.1"
|
|
@@ -85,14 +87,14 @@
|
|
|
85
87
|
"@jsenv/assert": "./packages/independent/assert/",
|
|
86
88
|
"@jsenv/core": "./",
|
|
87
89
|
"@jsenv/eslint-config": "./packages/independent/eslint-config/",
|
|
88
|
-
"@jsenv/file-size-impact": "14.1.
|
|
90
|
+
"@jsenv/file-size-impact": "14.1.4",
|
|
89
91
|
"@jsenv/https-local": "3.0.7",
|
|
90
|
-
"@jsenv/
|
|
91
|
-
"@jsenv/performance-impact": "4.1.
|
|
92
|
+
"@jsenv/monorepo": "0.0.4",
|
|
93
|
+
"@jsenv/performance-impact": "4.1.4",
|
|
92
94
|
"@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
|
|
93
95
|
"@jsenv/test": "./packages/related/test/",
|
|
94
96
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
95
|
-
"eslint": "8.
|
|
97
|
+
"eslint": "8.53.0",
|
|
96
98
|
"eslint-plugin-html": "7.1.0",
|
|
97
99
|
"eslint-plugin-import": "2.29.0",
|
|
98
100
|
"eslint-plugin-react": "7.33.2",
|
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({
|
|
@@ -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",
|