@jsenv/core 27.0.0-alpha.25 → 27.0.0-alpha.26
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/package.json +1 -1
- package/src/omega/url_graph/url_graph_report.js +10 -10
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +10 -7
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_workers_type_module_as_classic.js +8 -2
- package/src/plugins/url_references/js/js_urls.js +7 -14
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
22
22
|
html: 0,
|
|
23
23
|
css: 0,
|
|
24
24
|
js: 0,
|
|
25
|
-
|
|
25
|
+
other: 0,
|
|
26
26
|
sourcemaps: 0,
|
|
27
27
|
total: 0,
|
|
28
28
|
}
|
|
@@ -31,7 +31,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
31
31
|
css: 0,
|
|
32
32
|
js: 0,
|
|
33
33
|
sourcemaps: 0,
|
|
34
|
-
|
|
34
|
+
other: 0,
|
|
35
35
|
total: 0,
|
|
36
36
|
}
|
|
37
37
|
Object.keys(urlInfos).forEach((url) => {
|
|
@@ -81,8 +81,8 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
81
81
|
sizeGroups.js += urlContentSize
|
|
82
82
|
return
|
|
83
83
|
}
|
|
84
|
-
countGroups.
|
|
85
|
-
sizeGroups.
|
|
84
|
+
countGroups.other++
|
|
85
|
+
sizeGroups.other += urlContentSize
|
|
86
86
|
return
|
|
87
87
|
})
|
|
88
88
|
return {
|
|
@@ -90,7 +90,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
90
90
|
css: { count: countGroups.css, size: sizeGroups.css },
|
|
91
91
|
js: { count: countGroups.js, size: sizeGroups.js },
|
|
92
92
|
sourcemaps: { count: countGroups.sourcemaps, size: sizeGroups.sourcemaps },
|
|
93
|
-
|
|
93
|
+
other: { count: countGroups.other, size: sizeGroups.other },
|
|
94
94
|
total: { count: countGroups.total, size: sizeGroups.total },
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -108,10 +108,10 @@ const determineCategory = (urlInfo) => {
|
|
|
108
108
|
if (urlInfo.type === "js_module" || urlInfo.type === "js_classic") {
|
|
109
109
|
return "js"
|
|
110
110
|
}
|
|
111
|
-
return "
|
|
111
|
+
return "other"
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const createRepartitionMessage = ({ html, css, js,
|
|
114
|
+
const createRepartitionMessage = ({ html, css, js, other }) => {
|
|
115
115
|
const parts = []
|
|
116
116
|
if (html.count) {
|
|
117
117
|
parts.push(
|
|
@@ -141,10 +141,10 @@ const createRepartitionMessage = ({ html, css, js, assets }) => {
|
|
|
141
141
|
// } (${byteAsFileSize(sourcemaps.size)})`,
|
|
142
142
|
// )
|
|
143
143
|
// }
|
|
144
|
-
if (
|
|
144
|
+
if (other.count) {
|
|
145
145
|
parts.push(
|
|
146
|
-
`${ANSI.color(`
|
|
147
|
-
|
|
146
|
+
`${ANSI.color(`other:`, ANSI.GREY)} ${other.count} (${byteAsFileSize(
|
|
147
|
+
other.size,
|
|
148
148
|
)})`,
|
|
149
149
|
)
|
|
150
150
|
}
|
|
@@ -49,13 +49,16 @@ const asJsClassic = ({ systemJsInjection, systemJsClientFileUrl }) => {
|
|
|
49
49
|
appliesDuring: "*",
|
|
50
50
|
// forward ?as_js_classic to referenced urls
|
|
51
51
|
normalizeUrl: (reference, context) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
// We want to propagate transformation of js module to js classic
|
|
53
|
+
// but only for import specifier (static/dynamic import + re-export)
|
|
54
|
+
// All other references won't get the ?as_js_classic
|
|
55
|
+
// otherwise we could try to transform inline ressources, specifiers inside new URL(). ...
|
|
56
|
+
if (
|
|
57
|
+
reference.type !== "js_import_export" &&
|
|
58
|
+
reference.subtype !== "system_register_arg" &&
|
|
59
|
+
reference.subtype !== "system_import_arg"
|
|
60
|
+
) {
|
|
61
|
+
return null
|
|
59
62
|
}
|
|
60
63
|
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
|
|
61
64
|
if (
|
package/src/plugins/transpilation/as_js_classic/jsenv_plugin_workers_type_module_as_classic.js
CHANGED
|
@@ -25,6 +25,7 @@ export const jsenvPluginWorkersTypeModuleAsClassic = ({
|
|
|
25
25
|
babelPluginMetadataWorkerMentions,
|
|
26
26
|
{
|
|
27
27
|
workersToTranspile,
|
|
28
|
+
isJsModule: urlInfo.type === "js_module",
|
|
28
29
|
},
|
|
29
30
|
],
|
|
30
31
|
],
|
|
@@ -101,7 +102,10 @@ const getWorkersToTranspile = (urlInfo, context) => {
|
|
|
101
102
|
return { worker, serviceWorker, sharedWorker }
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
const babelPluginMetadataWorkerMentions = (
|
|
105
|
+
const babelPluginMetadataWorkerMentions = (
|
|
106
|
+
_,
|
|
107
|
+
{ workersToTranspile, isJsModule },
|
|
108
|
+
) => {
|
|
105
109
|
return {
|
|
106
110
|
name: "metadata-worker-mentions",
|
|
107
111
|
visitor: {
|
|
@@ -110,7 +114,9 @@ const babelPluginMetadataWorkerMentions = (_, { workersToTranspile }) => {
|
|
|
110
114
|
const visitors = {
|
|
111
115
|
NewExpression: (path) => {
|
|
112
116
|
if (workersToTranspile.worker || workersToTranspile.sharedWorker) {
|
|
113
|
-
const mentions = analyzeNewWorkerOrNewSharedWorker(path
|
|
117
|
+
const mentions = analyzeNewWorkerOrNewSharedWorker(path, {
|
|
118
|
+
isJsModule,
|
|
119
|
+
})
|
|
114
120
|
if (mentions) {
|
|
115
121
|
workerMentions.push(...mentions)
|
|
116
122
|
}
|
|
@@ -18,10 +18,7 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
18
18
|
const isWebWorker = isWebWorkerUrlInfo(urlInfo)
|
|
19
19
|
const { metadata } = await applyBabelPlugins({
|
|
20
20
|
babelPlugins: [
|
|
21
|
-
[
|
|
22
|
-
babelPluginMetadataJsUrlMentions,
|
|
23
|
-
{ isJsModule, isWebWorker, searchSystemJs: !isJsModule },
|
|
24
|
-
],
|
|
21
|
+
[babelPluginMetadataJsUrlMentions, { isJsModule, isWebWorker }],
|
|
25
22
|
],
|
|
26
23
|
urlInfo,
|
|
27
24
|
})
|
|
@@ -67,10 +64,7 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
67
64
|
* https://github.com/mjackson/babel-plugin-import-visitor
|
|
68
65
|
*
|
|
69
66
|
*/
|
|
70
|
-
const babelPluginMetadataJsUrlMentions = (
|
|
71
|
-
_,
|
|
72
|
-
{ isJsModule, isWebWorker, searchSystemJs },
|
|
73
|
-
) => {
|
|
67
|
+
const babelPluginMetadataJsUrlMentions = (_, { isJsModule, isWebWorker }) => {
|
|
74
68
|
return {
|
|
75
69
|
name: "metadata-js-mentions",
|
|
76
70
|
visitor: {
|
|
@@ -112,17 +106,16 @@ const babelPluginMetadataJsUrlMentions = (
|
|
|
112
106
|
},
|
|
113
107
|
NewExpression: (path) => {
|
|
114
108
|
callStaticAnalyzers(path, [
|
|
115
|
-
analyzeNewWorkerOrNewSharedWorker,
|
|
116
|
-
analyzeNewUrlCall,
|
|
109
|
+
(path) => analyzeNewWorkerOrNewSharedWorker(path, { isJsModule }),
|
|
110
|
+
(path) => analyzeNewUrlCall(path, { isJsModule }),
|
|
117
111
|
])
|
|
118
112
|
},
|
|
119
113
|
}
|
|
120
114
|
const callExpressionStaticAnalysers = [
|
|
121
|
-
...(isJsModule
|
|
115
|
+
...(isJsModule
|
|
116
|
+
? [analyzeImportCall]
|
|
117
|
+
: [analyzeSystemRegisterCall, analyzeSystemImportCall]),
|
|
122
118
|
...(isWebWorker ? [analyzeImportScriptCalls] : []),
|
|
123
|
-
...(searchSystemJs
|
|
124
|
-
? [analyzeSystemRegisterCall, analyzeSystemImportCall]
|
|
125
|
-
: []),
|
|
126
119
|
analyzeServiceWorkerRegisterCall,
|
|
127
120
|
]
|
|
128
121
|
visitors.CallExpression = (path) => {
|