@jsenv/core 30.3.1 → 30.3.2
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/main.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Readable, Stream, Writable } from "node:stream";
|
|
|
16
16
|
import { Http2ServerResponse } from "node:http2";
|
|
17
17
|
import { lookup } from "node:dns";
|
|
18
18
|
import { SOURCEMAP, generateSourcemapFileUrl, composeTwoSourcemaps, generateSourcemapDataUrl, createMagicSource, getOriginalPosition } from "@jsenv/sourcemap";
|
|
19
|
-
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition,
|
|
19
|
+
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, parseCssUrls, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, injectJsImport, analyzeLinkNode, injectHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
|
|
20
20
|
import { createRequire } from "node:module";
|
|
21
21
|
import babelParser from "@babel/parser";
|
|
22
22
|
import { bundleJsModules } from "@jsenv/plugin-bundling";
|
|
@@ -9668,21 +9668,22 @@ const parseAndTransformHtmlUrls = async (urlInfo, context) => {
|
|
|
9668
9668
|
url,
|
|
9669
9669
|
htmlAst
|
|
9670
9670
|
});
|
|
9671
|
-
const actions = [];
|
|
9672
9671
|
const mutations = [];
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9672
|
+
const actions = [];
|
|
9673
|
+
for (const mention of mentions) {
|
|
9674
|
+
const {
|
|
9675
|
+
type,
|
|
9676
|
+
subtype,
|
|
9677
|
+
expectedType,
|
|
9678
|
+
line,
|
|
9679
|
+
column,
|
|
9680
|
+
originalLine,
|
|
9681
|
+
originalColumn,
|
|
9682
|
+
node,
|
|
9683
|
+
attributeName,
|
|
9684
|
+
debug,
|
|
9685
|
+
specifier
|
|
9686
|
+
} = mention;
|
|
9686
9687
|
const {
|
|
9687
9688
|
crossorigin,
|
|
9688
9689
|
integrity
|
|
@@ -9704,13 +9705,13 @@ const parseAndTransformHtmlUrls = async (urlInfo, context) => {
|
|
|
9704
9705
|
});
|
|
9705
9706
|
actions.push(async () => {
|
|
9706
9707
|
await context.referenceUtils.readGeneratedSpecifier(reference);
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9708
|
+
mutations.push(() => {
|
|
9709
|
+
setHtmlNodeAttributes(node, {
|
|
9710
|
+
[attributeName]: reference.generatedSpecifier
|
|
9711
|
+
});
|
|
9711
9712
|
});
|
|
9712
9713
|
});
|
|
9713
|
-
}
|
|
9714
|
+
}
|
|
9714
9715
|
if (actions.length > 0) {
|
|
9715
9716
|
await Promise.all(actions.map(action => action()));
|
|
9716
9717
|
}
|
|
@@ -9958,40 +9959,33 @@ const decideLinkExpectedType = (linkMention, mentions) => {
|
|
|
9958
9959
|
* https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/css/src/CSSTransformer.js
|
|
9959
9960
|
*/
|
|
9960
9961
|
const parseAndTransformCssUrls = async (urlInfo, context) => {
|
|
9962
|
+
const cssUrls = await parseCssUrls({
|
|
9963
|
+
css: urlInfo.content,
|
|
9964
|
+
url: urlInfo.originalUrl
|
|
9965
|
+
});
|
|
9961
9966
|
const actions = [];
|
|
9962
9967
|
const magicSource = createMagicSource(urlInfo.content);
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
start: specifierStart,
|
|
9985
|
-
end: specifierEnd,
|
|
9986
|
-
replacement: await context.referenceUtils.readGeneratedSpecifier(reference)
|
|
9987
|
-
});
|
|
9988
|
-
});
|
|
9989
|
-
}
|
|
9990
|
-
})],
|
|
9991
|
-
url: urlInfo.originalUrl,
|
|
9992
|
-
content: urlInfo.content
|
|
9993
|
-
});
|
|
9994
|
-
await Promise.all(actions.map(action => action()));
|
|
9968
|
+
for (const cssUrl of cssUrls) {
|
|
9969
|
+
const [reference] = context.referenceUtils.found({
|
|
9970
|
+
type: cssUrl.type,
|
|
9971
|
+
specifier: cssUrl.specifier,
|
|
9972
|
+
specifierStart: cssUrl.start,
|
|
9973
|
+
specifierEnd: cssUrl.end,
|
|
9974
|
+
specifierLine: cssUrl.line,
|
|
9975
|
+
specifierColumn: cssUrl.column
|
|
9976
|
+
});
|
|
9977
|
+
actions.push(async () => {
|
|
9978
|
+
const replacement = await context.referenceUtils.readGeneratedSpecifier(reference);
|
|
9979
|
+
magicSource.replace({
|
|
9980
|
+
start: cssUrl.start,
|
|
9981
|
+
end: cssUrl.end,
|
|
9982
|
+
replacement
|
|
9983
|
+
});
|
|
9984
|
+
});
|
|
9985
|
+
}
|
|
9986
|
+
if (actions.length > 0) {
|
|
9987
|
+
await Promise.all(actions.map(action => action()));
|
|
9988
|
+
}
|
|
9995
9989
|
return magicSource.toContentAndSourcemap();
|
|
9996
9990
|
};
|
|
9997
9991
|
|
|
@@ -10004,7 +9998,7 @@ const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
10004
9998
|
});
|
|
10005
9999
|
const actions = [];
|
|
10006
10000
|
const magicSource = createMagicSource(urlInfo.content);
|
|
10007
|
-
|
|
10001
|
+
for (const jsMention of jsMentions) {
|
|
10008
10002
|
if (jsMention.subtype === "import_static" || jsMention.subtype === "import_dynamic") {
|
|
10009
10003
|
urlInfo.data.usesImport = true;
|
|
10010
10004
|
}
|
|
@@ -10015,10 +10009,10 @@ const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
10015
10009
|
expectedType: jsMention.expectedType,
|
|
10016
10010
|
expectedSubtype: jsMention.expectedSubtype || urlInfo.subtype,
|
|
10017
10011
|
specifier: jsMention.specifier,
|
|
10018
|
-
specifierStart: jsMention.
|
|
10019
|
-
specifierEnd: jsMention.
|
|
10020
|
-
specifierLine: jsMention.
|
|
10021
|
-
specifierColumn: jsMention.
|
|
10012
|
+
specifierStart: jsMention.start,
|
|
10013
|
+
specifierEnd: jsMention.end,
|
|
10014
|
+
specifierLine: jsMention.line,
|
|
10015
|
+
specifierColumn: jsMention.column,
|
|
10022
10016
|
data: jsMention.data,
|
|
10023
10017
|
baseUrl: {
|
|
10024
10018
|
"StringLiteral": jsMention.baseUrl,
|
|
@@ -10035,16 +10029,18 @@ const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
10035
10029
|
actions.push(async () => {
|
|
10036
10030
|
const replacement = await context.referenceUtils.readGeneratedSpecifier(reference);
|
|
10037
10031
|
magicSource.replace({
|
|
10038
|
-
start: jsMention.
|
|
10039
|
-
end: jsMention.
|
|
10032
|
+
start: jsMention.start,
|
|
10033
|
+
end: jsMention.end,
|
|
10040
10034
|
replacement
|
|
10041
10035
|
});
|
|
10042
10036
|
if (reference.mutation) {
|
|
10043
10037
|
reference.mutation(magicSource);
|
|
10044
10038
|
}
|
|
10045
10039
|
});
|
|
10046
|
-
}
|
|
10047
|
-
|
|
10040
|
+
}
|
|
10041
|
+
if (actions.length > 0) {
|
|
10042
|
+
await Promise.all(actions.map(action => action()));
|
|
10043
|
+
}
|
|
10048
10044
|
const {
|
|
10049
10045
|
content,
|
|
10050
10046
|
sourcemap
|
|
@@ -21735,6 +21731,9 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21735
21731
|
const getBuildRelativeUrl = url => {
|
|
21736
21732
|
const urlObject = new URL(url);
|
|
21737
21733
|
urlObject.searchParams.delete("as_js_classic");
|
|
21734
|
+
urlObject.searchParams.delete("as_css_module");
|
|
21735
|
+
urlObject.searchParams.delete("as_json_module");
|
|
21736
|
+
urlObject.searchParams.delete("as_text_module");
|
|
21738
21737
|
url = urlObject.href;
|
|
21739
21738
|
const buildRelativeUrl = urlToRelativeUrl(url, buildDirectoryUrl);
|
|
21740
21739
|
return buildRelativeUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "30.3.
|
|
3
|
+
"version": "30.3.2",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@c88/v8-coverage": "0.1.1",
|
|
68
68
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
69
69
|
"@jsenv/abort": "4.2.4",
|
|
70
|
-
"@jsenv/ast": "
|
|
70
|
+
"@jsenv/ast": "3.0.0",
|
|
71
71
|
"@jsenv/babel-plugins": "1.1.2",
|
|
72
72
|
"@jsenv/plugin-bundling": "1.1.1",
|
|
73
73
|
"@jsenv/filesystem": "4.1.9",
|
|
@@ -100,18 +100,18 @@
|
|
|
100
100
|
"@babel/plugin-syntax-import-assertions": "7.20.0",
|
|
101
101
|
"@jsenv/assert": "./packages/assert/",
|
|
102
102
|
"@jsenv/eslint-config": "./packages/eslint-config/",
|
|
103
|
-
"@jsenv/file-size-impact": "
|
|
104
|
-
"@jsenv/https-local": "3.0.
|
|
103
|
+
"@jsenv/file-size-impact": "14.0.0",
|
|
104
|
+
"@jsenv/https-local": "3.0.6",
|
|
105
105
|
"@jsenv/package-workspace": "0.5.1",
|
|
106
106
|
"@jsenv/plugin-minification": "./packages/jsenv-plugin-minification/",
|
|
107
107
|
"@jsenv/plugin-globals": "./packages/jsenv-plugin-globals/",
|
|
108
108
|
"@jsenv/plugin-placeholders": "./packages/jsenv-plugin-placeholders/",
|
|
109
109
|
"@jsenv/performance-impact": "4.1.0",
|
|
110
|
-
"eslint": "8.
|
|
110
|
+
"eslint": "8.32.0",
|
|
111
111
|
"eslint-plugin-html": "7.1.0",
|
|
112
|
-
"eslint-plugin-import": "2.
|
|
113
|
-
"eslint-plugin-react": "7.
|
|
112
|
+
"eslint-plugin-import": "2.27.5",
|
|
113
|
+
"eslint-plugin-react": "7.32.1",
|
|
114
114
|
"playwright": "1.29.2",
|
|
115
|
-
"prettier": "2.8.
|
|
115
|
+
"prettier": "2.8.3"
|
|
116
116
|
}
|
|
117
117
|
}
|
package/src/build/build.js
CHANGED
|
@@ -1539,6 +1539,9 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1539
1539
|
const getBuildRelativeUrl = (url) => {
|
|
1540
1540
|
const urlObject = new URL(url)
|
|
1541
1541
|
urlObject.searchParams.delete("as_js_classic")
|
|
1542
|
+
urlObject.searchParams.delete("as_css_module")
|
|
1543
|
+
urlObject.searchParams.delete("as_json_module")
|
|
1544
|
+
urlObject.searchParams.delete("as_text_module")
|
|
1542
1545
|
url = urlObject.href
|
|
1543
1546
|
const buildRelativeUrl = urlToRelativeUrl(url, buildDirectoryUrl)
|
|
1544
1547
|
return buildRelativeUrl
|
|
@@ -2,47 +2,38 @@
|
|
|
2
2
|
* https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/css/src/CSSTransformer.js
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { parseCssUrls } from "@jsenv/ast"
|
|
5
6
|
import { createMagicSource } from "@jsenv/sourcemap"
|
|
6
|
-
import { applyPostCss, postCssPluginUrlVisitor } from "@jsenv/ast"
|
|
7
7
|
|
|
8
8
|
export const parseAndTransformCssUrls = async (urlInfo, context) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
await applyPostCss({
|
|
12
|
-
sourcemaps: false,
|
|
13
|
-
plugins: [
|
|
14
|
-
postCssPluginUrlVisitor({
|
|
15
|
-
urlVisitor: ({
|
|
16
|
-
type,
|
|
17
|
-
specifier,
|
|
18
|
-
specifierStart,
|
|
19
|
-
specifierEnd,
|
|
20
|
-
specifierLine,
|
|
21
|
-
specifierColumn,
|
|
22
|
-
}) => {
|
|
23
|
-
const [reference] = context.referenceUtils.found({
|
|
24
|
-
type: `css_${type}`,
|
|
25
|
-
specifier,
|
|
26
|
-
specifierStart,
|
|
27
|
-
specifierEnd,
|
|
28
|
-
specifierLine,
|
|
29
|
-
specifierColumn,
|
|
30
|
-
})
|
|
31
|
-
actions.push(async () => {
|
|
32
|
-
magicSource.replace({
|
|
33
|
-
start: specifierStart,
|
|
34
|
-
end: specifierEnd,
|
|
35
|
-
replacement: await context.referenceUtils.readGeneratedSpecifier(
|
|
36
|
-
reference,
|
|
37
|
-
),
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
],
|
|
9
|
+
const cssUrls = await parseCssUrls({
|
|
10
|
+
css: urlInfo.content,
|
|
43
11
|
url: urlInfo.originalUrl,
|
|
44
|
-
content: urlInfo.content,
|
|
45
12
|
})
|
|
46
|
-
|
|
13
|
+
const actions = []
|
|
14
|
+
const magicSource = createMagicSource(urlInfo.content)
|
|
15
|
+
for (const cssUrl of cssUrls) {
|
|
16
|
+
const [reference] = context.referenceUtils.found({
|
|
17
|
+
type: cssUrl.type,
|
|
18
|
+
specifier: cssUrl.specifier,
|
|
19
|
+
specifierStart: cssUrl.start,
|
|
20
|
+
specifierEnd: cssUrl.end,
|
|
21
|
+
specifierLine: cssUrl.line,
|
|
22
|
+
specifierColumn: cssUrl.column,
|
|
23
|
+
})
|
|
24
|
+
actions.push(async () => {
|
|
25
|
+
const replacement = await context.referenceUtils.readGeneratedSpecifier(
|
|
26
|
+
reference,
|
|
27
|
+
)
|
|
28
|
+
magicSource.replace({
|
|
29
|
+
start: cssUrl.start,
|
|
30
|
+
end: cssUrl.end,
|
|
31
|
+
replacement,
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
if (actions.length > 0) {
|
|
36
|
+
await Promise.all(actions.map((action) => action()))
|
|
37
|
+
}
|
|
47
38
|
return magicSource.toContentAndSourcemap()
|
|
48
39
|
}
|
|
@@ -20,10 +20,10 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
|
|
|
20
20
|
url,
|
|
21
21
|
htmlAst,
|
|
22
22
|
})
|
|
23
|
-
const actions = []
|
|
24
23
|
const mutations = []
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const actions = []
|
|
25
|
+
for (const mention of mentions) {
|
|
26
|
+
const {
|
|
27
27
|
type,
|
|
28
28
|
subtype,
|
|
29
29
|
expectedType,
|
|
@@ -35,39 +35,38 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
|
|
|
35
35
|
attributeName,
|
|
36
36
|
debug,
|
|
37
37
|
specifier,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
38
|
+
} = mention
|
|
39
|
+
const { crossorigin, integrity } = readFetchMetas(node)
|
|
40
|
+
const isResourceHint = [
|
|
41
|
+
"preconnect",
|
|
42
|
+
"dns-prefetch",
|
|
43
|
+
"prefetch",
|
|
44
|
+
"preload",
|
|
45
|
+
"modulepreload",
|
|
46
|
+
].includes(subtype)
|
|
47
|
+
const [reference] = context.referenceUtils.found({
|
|
48
|
+
type,
|
|
49
|
+
subtype,
|
|
50
|
+
expectedType,
|
|
51
|
+
originalLine,
|
|
52
|
+
originalColumn,
|
|
53
|
+
specifier,
|
|
54
|
+
specifierLine: line,
|
|
55
|
+
specifierColumn: column,
|
|
56
|
+
isResourceHint,
|
|
57
|
+
crossorigin,
|
|
58
|
+
integrity,
|
|
59
|
+
debug,
|
|
60
|
+
})
|
|
61
|
+
actions.push(async () => {
|
|
62
|
+
await context.referenceUtils.readGeneratedSpecifier(reference)
|
|
64
63
|
mutations.push(() => {
|
|
65
64
|
setHtmlNodeAttributes(node, {
|
|
66
65
|
[attributeName]: reference.generatedSpecifier,
|
|
67
66
|
})
|
|
68
67
|
})
|
|
69
|
-
}
|
|
70
|
-
|
|
68
|
+
})
|
|
69
|
+
}
|
|
71
70
|
if (actions.length > 0) {
|
|
72
71
|
await Promise.all(actions.map((action) => action()))
|
|
73
72
|
}
|
|
@@ -12,7 +12,7 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
12
12
|
})
|
|
13
13
|
const actions = []
|
|
14
14
|
const magicSource = createMagicSource(urlInfo.content)
|
|
15
|
-
|
|
15
|
+
for (const jsMention of jsMentions) {
|
|
16
16
|
if (
|
|
17
17
|
jsMention.subtype === "import_static" ||
|
|
18
18
|
jsMention.subtype === "import_dynamic"
|
|
@@ -26,10 +26,10 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
26
26
|
expectedType: jsMention.expectedType,
|
|
27
27
|
expectedSubtype: jsMention.expectedSubtype || urlInfo.subtype,
|
|
28
28
|
specifier: jsMention.specifier,
|
|
29
|
-
specifierStart: jsMention.
|
|
30
|
-
specifierEnd: jsMention.
|
|
31
|
-
specifierLine: jsMention.
|
|
32
|
-
specifierColumn: jsMention.
|
|
29
|
+
specifierStart: jsMention.start,
|
|
30
|
+
specifierEnd: jsMention.end,
|
|
31
|
+
specifierLine: jsMention.line,
|
|
32
|
+
specifierColumn: jsMention.column,
|
|
33
33
|
data: jsMention.data,
|
|
34
34
|
baseUrl: {
|
|
35
35
|
"StringLiteral": jsMention.baseUrl,
|
|
@@ -48,16 +48,18 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
48
48
|
reference,
|
|
49
49
|
)
|
|
50
50
|
magicSource.replace({
|
|
51
|
-
start: jsMention.
|
|
52
|
-
end: jsMention.
|
|
51
|
+
start: jsMention.start,
|
|
52
|
+
end: jsMention.end,
|
|
53
53
|
replacement,
|
|
54
54
|
})
|
|
55
55
|
if (reference.mutation) {
|
|
56
56
|
reference.mutation(magicSource)
|
|
57
57
|
}
|
|
58
58
|
})
|
|
59
|
-
}
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
if (actions.length > 0) {
|
|
61
|
+
await Promise.all(actions.map((action) => action()))
|
|
62
|
+
}
|
|
61
63
|
const { content, sourcemap } = magicSource.toContentAndSourcemap()
|
|
62
64
|
return { content, sourcemap }
|
|
63
65
|
}
|