@jsenv/core 25.0.0-alpha.0 → 25.0.0-alpha.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/browser_runtime/asset-manifest.json +2 -2
- package/dist/browser_runtime/{browser_runtime_a8097085.js → browser_runtime_91c5a3b8.js} +137 -26
- package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +1089 -0
- package/dist/build_manifest.js +6 -6
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/{compile_proxy_e16d7de8.html → compile_proxy_7ad5faa6.html} +119 -26
- package/dist/compile_proxy/{compile_proxy_e3b0c442_9e168143.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +6 -6
- package/dist/event_source_client/asset-manifest.json +2 -2
- package/dist/event_source_client/{event_source_client_620fbc2c.js → event_source_client_80644aee.js} +2 -2
- package/dist/event_source_client/{event_source_client_620fbc2c.js.map → event_source_client_80644aee.js.map} +4 -3
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/{redirector_e3b0c442_3a34a156.js.map → redirector_e3b0c442_e391410e.js.map} +6 -6
- package/dist/redirector/{redirector_2e0c8abe.html → redirector_eb92e8a7.html} +119 -26
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/{toolbar.main_a5ef2c60.js.map → toolbar.main_6c1b3d82.js.map} +8 -8
- package/dist/toolbar/{toolbar_412abb83.html → toolbar_f7b8a263.html} +127 -32
- package/dist/toolbar_injector/asset-manifest.json +3 -3
- package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js → toolbar_injector_49e4756e.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js.map → toolbar_injector_49e4756e.js.map} +2 -2
- package/package.json +5 -4
- package/readme.md +22 -89
- package/src/buildProject.js +37 -15
- package/src/dev_server.js +8 -2
- package/src/execute.js +7 -1
- package/src/executeTestPlan.js +17 -0
- package/src/internal/browser_feature_detection/browser_feature_detection.js +18 -25
- package/src/internal/browser_runtime/browser_runtime.js +2 -2
- package/src/internal/browser_runtime/createBrowserRuntime.js +1 -1
- package/src/internal/browser_runtime/displayErrorInDocument.js +2 -0
- package/src/internal/browser_runtime/displayErrorNotification.js +1 -1
- package/src/internal/building/buildUsingRollup.js +3 -8
- package/src/internal/building/ressource_builder.js +35 -42
- package/src/internal/building/rollup_plugin_jsenv.js +226 -206
- package/src/internal/building/url_versioning.js +54 -42
- package/src/internal/compiling/createCompiledFileService.js +28 -40
- package/src/internal/compiling/html_source_file_service.js +66 -51
- package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +23 -0
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -12
- package/src/internal/compiling/js-compilation-service/transformJs.js +2 -0
- package/src/internal/compiling/jsenvCompilerForHtml.js +43 -44
- package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +9 -0
- package/src/internal/compiling/startCompileServer.js +29 -5
- package/src/internal/dev_server/event_source_client/livereload_preference.js +1 -1
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -9
- package/src/internal/executing/executePlan.js +6 -0
- package/src/internal/generateGroupMap/{jsenvBabelPluginCompatMap.js → babel_plugins_compatibility.js} +0 -0
- package/src/internal/generateGroupMap/{featuresCompatMap.js → features_compatibility.js} +9 -1
- package/src/internal/generateGroupMap/generateGroupMap.js +6 -35
- package/src/internal/generateGroupMap/one_runtime_compat.js +9 -12
- package/src/internal/generateGroupMap/runtime_compat.js +10 -15
- package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -2
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +21 -0
- package/src/internal/import-resolution/importmap_default.js +52 -0
- package/src/internal/node_feature_detection/node_feature_detection.js +25 -19
- package/src/internal/runtime/s.js +101 -6
- package/src/internal/unevalException.js +1 -1
- package/src/jsenvServiceWorkerFinalizer.js +6 -10
- package/dist/browser_runtime/browser_runtime_a8097085.js.map +0 -1067
- package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
- package/src/internal/import-resolution/importmap-default.js +0 -34
package/src/buildProject.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
|
2
2
|
import { resolveDirectoryUrl } from "@jsenv/filesystem"
|
|
3
3
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
4
4
|
|
|
5
|
+
import { shakeBabelPluginMap } from "@jsenv/core/src/internal/generateGroupMap/shake_babel_plugin_map.js"
|
|
5
6
|
import { COMPILE_ID_BEST } from "./internal/CONSTANTS.js"
|
|
6
7
|
import {
|
|
7
8
|
assertProjectDirectoryUrl,
|
|
@@ -14,6 +15,15 @@ import {
|
|
|
14
15
|
jsenvNodeRuntimeSupport,
|
|
15
16
|
} from "./internal/generateGroupMap/jsenvRuntimeSupport.js"
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Generate optimized version of source files into a directory
|
|
20
|
+
* @param {string|url} projectDirectoryUrl Root directory of the project
|
|
21
|
+
* @param {string|url} buildDirectoryRelativeUrl Directory where optimized files are written
|
|
22
|
+
* @param {object} entryPoints Describe entry point paths and control their names in the build directory
|
|
23
|
+
* @param {"esmodule" | "systemjs" | "commonjs" | "global"} format Code generated will use this module format
|
|
24
|
+
* @param {object} runtimeSupport Code generated will be compatible with these runtimes
|
|
25
|
+
* @param {boolean} [minify=false] Minify file content in the build directory (HTML, CSS, JS, JSON, SVG)
|
|
26
|
+
*/
|
|
17
27
|
export const buildProject = async ({
|
|
18
28
|
signal = new AbortController().signal,
|
|
19
29
|
handleSIGINT = true,
|
|
@@ -23,6 +33,12 @@ export const buildProject = async ({
|
|
|
23
33
|
|
|
24
34
|
projectDirectoryUrl,
|
|
25
35
|
entryPoints,
|
|
36
|
+
workers = [],
|
|
37
|
+
serviceWorkers = [],
|
|
38
|
+
serviceWorkerFinalizer,
|
|
39
|
+
classicWorkers = [],
|
|
40
|
+
classicServiceWorkers = [],
|
|
41
|
+
importMapInWebWorkers = false,
|
|
26
42
|
buildDirectoryRelativeUrl,
|
|
27
43
|
buildDirectoryClean = true,
|
|
28
44
|
assetManifestFile = false,
|
|
@@ -77,12 +93,6 @@ export const buildProject = async ({
|
|
|
77
93
|
// https://github.com/cssnano/cssnano/tree/master/packages/cssnano-preset-default
|
|
78
94
|
minifyCssOptions,
|
|
79
95
|
|
|
80
|
-
workers = {},
|
|
81
|
-
serviceWorkers = {},
|
|
82
|
-
serviceWorkerFinalizer,
|
|
83
|
-
classicWorkers = {},
|
|
84
|
-
classicServiceWorkers = {},
|
|
85
|
-
|
|
86
96
|
env = {},
|
|
87
97
|
protocol,
|
|
88
98
|
privateKey,
|
|
@@ -114,6 +124,11 @@ export const buildProject = async ({
|
|
|
114
124
|
`runtimeSupport must be an object, got ${runtimeSupport}`,
|
|
115
125
|
)
|
|
116
126
|
}
|
|
127
|
+
if (format !== "systemjs" && importMapInWebWorkers) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`format must be "systemjs" when importMapInWebWorkers is enabled`,
|
|
130
|
+
)
|
|
131
|
+
}
|
|
117
132
|
|
|
118
133
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
119
134
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
@@ -166,6 +181,7 @@ export const buildProject = async ({
|
|
|
166
181
|
moduleOutFormat: "esmodule", // rollup will transform into the right format
|
|
167
182
|
importMetaFormat: "esmodule", // rollup will transform into the right format
|
|
168
183
|
topLevelAwait: "ignore", // rollup will transform if needed
|
|
184
|
+
prependSystemJs: false,
|
|
169
185
|
|
|
170
186
|
protocol,
|
|
171
187
|
privateKey,
|
|
@@ -174,9 +190,10 @@ export const buildProject = async ({
|
|
|
174
190
|
port,
|
|
175
191
|
env,
|
|
176
192
|
babelPluginMap,
|
|
177
|
-
|
|
193
|
+
workers,
|
|
194
|
+
serviceWorkers,
|
|
178
195
|
runtimeSupport,
|
|
179
|
-
|
|
196
|
+
customCompilers,
|
|
180
197
|
compileServerCanReadFromFilesystem: filesystemCache,
|
|
181
198
|
compileServerCanWriteOnFilesystem: filesystemCache,
|
|
182
199
|
// keep source html untouched
|
|
@@ -219,8 +236,19 @@ export const buildProject = async ({
|
|
|
219
236
|
systemJsUrl,
|
|
220
237
|
globalName,
|
|
221
238
|
globals,
|
|
222
|
-
babelPluginMap:
|
|
239
|
+
babelPluginMap: shakeBabelPluginMap({
|
|
240
|
+
babelPluginMap: compileServer.babelPluginMap,
|
|
241
|
+
missingFeatureNames:
|
|
242
|
+
compileServer.compileServerGroupMap[COMPILE_ID_BEST]
|
|
243
|
+
.missingFeatureNames,
|
|
244
|
+
}),
|
|
223
245
|
runtimeSupport,
|
|
246
|
+
workers,
|
|
247
|
+
serviceWorkers,
|
|
248
|
+
serviceWorkerFinalizer,
|
|
249
|
+
classicWorkers,
|
|
250
|
+
classicServiceWorkers,
|
|
251
|
+
importMapInWebWorkers,
|
|
224
252
|
|
|
225
253
|
urlVersioning,
|
|
226
254
|
lineBreakNormalization,
|
|
@@ -235,12 +263,6 @@ export const buildProject = async ({
|
|
|
235
263
|
minifyJsOptions,
|
|
236
264
|
minifyCssOptions,
|
|
237
265
|
|
|
238
|
-
workers,
|
|
239
|
-
serviceWorkers,
|
|
240
|
-
serviceWorkerFinalizer,
|
|
241
|
-
classicWorkers,
|
|
242
|
-
classicServiceWorkers,
|
|
243
|
-
|
|
244
266
|
writeOnFileSystem,
|
|
245
267
|
sourcemapExcludeSources,
|
|
246
268
|
})
|
package/src/dev_server.js
CHANGED
|
@@ -45,17 +45,20 @@ export const startDevServer = async ({
|
|
|
45
45
|
keepProcessAlive = true,
|
|
46
46
|
|
|
47
47
|
babelPluginMap,
|
|
48
|
+
workers,
|
|
49
|
+
serviceWorkers,
|
|
50
|
+
importMapInWebWorkers,
|
|
51
|
+
customCompilers,
|
|
48
52
|
runtimeSupportDuringDev = {
|
|
49
53
|
// this allows to compile nothing or almost nothing when opening files
|
|
50
54
|
// with a recent chrome. Without this we would compile all the things not yet unsupported
|
|
51
55
|
// by Firefox and Safari such as top level await, importmap, etc
|
|
52
|
-
chrome: "
|
|
56
|
+
chrome: "96",
|
|
53
57
|
},
|
|
54
58
|
logLevel,
|
|
55
59
|
compileServerCanReadFromFilesystem,
|
|
56
60
|
compileServerCanWriteOnFilesystem,
|
|
57
61
|
sourcemapMethod,
|
|
58
|
-
customCompilers,
|
|
59
62
|
livereloadWatchConfig,
|
|
60
63
|
livereloadLogLevel,
|
|
61
64
|
jsenvDirectoryClean,
|
|
@@ -124,6 +127,9 @@ export const startDevServer = async ({
|
|
|
124
127
|
customCompilers,
|
|
125
128
|
sourcemapMethod,
|
|
126
129
|
babelPluginMap,
|
|
130
|
+
workers,
|
|
131
|
+
serviceWorkers,
|
|
132
|
+
importMapInWebWorkers,
|
|
127
133
|
runtimeSupport: runtimeSupportDuringDev,
|
|
128
134
|
livereloadWatchConfig,
|
|
129
135
|
livereloadLogLevel,
|
package/src/execute.js
CHANGED
|
@@ -46,6 +46,9 @@ export const execute = async ({
|
|
|
46
46
|
port,
|
|
47
47
|
babelPluginMap,
|
|
48
48
|
customCompilers,
|
|
49
|
+
workers,
|
|
50
|
+
serviceWorkers,
|
|
51
|
+
importMapInWebWorkers,
|
|
49
52
|
compileServerCanReadFromFilesystem,
|
|
50
53
|
compileServerCanWriteOnFilesystem,
|
|
51
54
|
|
|
@@ -105,10 +108,13 @@ export const execute = async ({
|
|
|
105
108
|
ip,
|
|
106
109
|
port,
|
|
107
110
|
babelPluginMap,
|
|
108
|
-
customCompilers,
|
|
109
111
|
runtimeSupport: normalizeRuntimeSupport({
|
|
110
112
|
[runtime.name]: runtime.version,
|
|
111
113
|
}),
|
|
114
|
+
customCompilers,
|
|
115
|
+
workers,
|
|
116
|
+
serviceWorkers,
|
|
117
|
+
importMapInWebWorkers,
|
|
112
118
|
compileServerCanReadFromFilesystem,
|
|
113
119
|
compileServerCanWriteOnFilesystem,
|
|
114
120
|
})
|
package/src/executeTestPlan.js
CHANGED
|
@@ -19,6 +19,17 @@ import { generateCoverageHtmlDirectory } from "./internal/executing/coverage_rep
|
|
|
19
19
|
import { generateCoverageTextLog } from "./internal/executing/coverage_reporter/coverage_reporter_text_log.js"
|
|
20
20
|
import { jsenvCoverageConfig } from "./jsenvCoverageConfig.js"
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Execute a list of files and log how it goes
|
|
24
|
+
* @param {object} testPlan Configure files to execute and their runtimes (browsers/node)
|
|
25
|
+
* @param {string|url} projectDirectoryUrl Root directory of the project
|
|
26
|
+
* @param {number} [maxExecutionsInParallel=1] Maximum amount of execution in parallel
|
|
27
|
+
* @param {number} [defaultMsAllocatedPerExecution=30000] Milliseconds after which execution is aborted and considered as failed by timeout
|
|
28
|
+
* @param {number} [cooldownBetweenExecutions=0] Millisecond to wait between each execution
|
|
29
|
+
* @param {boolean} [logMemoryHeapUsage=false] Add memory heap usage during logs
|
|
30
|
+
* @param {boolean} [coverage=false] Controls if coverage is collected during files executions
|
|
31
|
+
* @param {boolean} [coverageV8ConflictWarning=true] Warn when coverage from 2 executions cannot be merged
|
|
32
|
+
*/
|
|
22
33
|
export const executeTestPlan = async ({
|
|
23
34
|
signal = new AbortController().signal,
|
|
24
35
|
handleSIGINT = true,
|
|
@@ -79,6 +90,9 @@ export const executeTestPlan = async ({
|
|
|
79
90
|
compileServerCanWriteOnFilesystem,
|
|
80
91
|
babelPluginMap,
|
|
81
92
|
babelConfigFileUrl,
|
|
93
|
+
workers,
|
|
94
|
+
serviceWorkers,
|
|
95
|
+
importMapInWebWorkers,
|
|
82
96
|
customCompilers,
|
|
83
97
|
jsenvDirectoryClean,
|
|
84
98
|
}) => {
|
|
@@ -179,6 +193,9 @@ export const executeTestPlan = async ({
|
|
|
179
193
|
compileServerCanWriteOnFilesystem,
|
|
180
194
|
babelPluginMap,
|
|
181
195
|
babelConfigFileUrl,
|
|
196
|
+
workers,
|
|
197
|
+
serviceWorkers,
|
|
198
|
+
importMapInWebWorkers,
|
|
182
199
|
customCompilers,
|
|
183
200
|
})
|
|
184
201
|
|
|
@@ -36,17 +36,14 @@ export const scanBrowserRuntimeFeatures = async ({
|
|
|
36
36
|
failFastOnFeatureDetection,
|
|
37
37
|
inlineImportMapIntoHTML,
|
|
38
38
|
})
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
coverageHandledFromOutside,
|
|
44
|
-
},
|
|
45
|
-
)
|
|
39
|
+
const missingFeatureNames = await adjustMissingFeatureNames(groupInfo, {
|
|
40
|
+
featuresReport,
|
|
41
|
+
coverageHandledFromOutside,
|
|
42
|
+
})
|
|
46
43
|
|
|
47
44
|
const canAvoidCompilation =
|
|
48
45
|
customCompilerPatterns.length === 0 &&
|
|
49
|
-
|
|
46
|
+
missingFeatureNames.length === 0 &&
|
|
50
47
|
featuresReport.importmap &&
|
|
51
48
|
featuresReport.dynamicImport &&
|
|
52
49
|
featuresReport.topLevelAwait
|
|
@@ -55,7 +52,7 @@ export const scanBrowserRuntimeFeatures = async ({
|
|
|
55
52
|
canAvoidCompilation,
|
|
56
53
|
featuresReport,
|
|
57
54
|
customCompilerPatterns,
|
|
58
|
-
|
|
55
|
+
missingFeatureNames,
|
|
59
56
|
inlineImportMapIntoHTML,
|
|
60
57
|
outDirectoryRelativeUrl,
|
|
61
58
|
compileId,
|
|
@@ -63,27 +60,25 @@ export const scanBrowserRuntimeFeatures = async ({
|
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
const
|
|
63
|
+
const adjustMissingFeatureNames = async (
|
|
67
64
|
groupInfo,
|
|
68
65
|
{ featuresReport, coverageHandledFromOutside },
|
|
69
66
|
) => {
|
|
70
|
-
const {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const index =
|
|
67
|
+
const { missingFeatureNames } = groupInfo
|
|
68
|
+
const missingFeatureNamesCopy = missingFeatureNames.slice()
|
|
69
|
+
const markAsSupported = (name) => {
|
|
70
|
+
const index = missingFeatureNamesCopy.indexOf(name)
|
|
74
71
|
if (index > -1) {
|
|
75
|
-
|
|
72
|
+
missingFeatureNamesCopy.splice(index, 1)
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
|
|
79
75
|
// When instrumentation CAN be handed by playwright
|
|
80
76
|
// https://playwright.dev/docs/api/class-chromiumcoverage#chromiumcoveragestartjscoverageoptions
|
|
81
77
|
// coverageHandledFromOutside is true and "transform-instrument" becomes non mandatory
|
|
82
78
|
if (coverageHandledFromOutside) {
|
|
83
|
-
|
|
79
|
+
markAsSupported("transform-instrument")
|
|
84
80
|
}
|
|
85
|
-
|
|
86
|
-
if (pluginRequiredNameArray.includes("transform-import-assertions")) {
|
|
81
|
+
if (missingFeatureNames.includes("transform-import-assertions")) {
|
|
87
82
|
const jsonImportAssertions = await supportsJsonImportAssertions()
|
|
88
83
|
featuresReport.jsonImportAssertions = jsonImportAssertions
|
|
89
84
|
|
|
@@ -91,17 +86,15 @@ const pluginRequiredNamesFromGroupInfo = async (
|
|
|
91
86
|
featuresReport.cssImportAssertions = cssImportAssertions
|
|
92
87
|
|
|
93
88
|
if (jsonImportAssertions && cssImportAssertions) {
|
|
94
|
-
|
|
89
|
+
markAsSupported("transform-import-assertions")
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
|
-
|
|
98
|
-
if (pluginRequiredNameArray.includes("new-stylesheet-as-jsenv-import")) {
|
|
92
|
+
if (missingFeatureNames.includes("new-stylesheet-as-jsenv-import")) {
|
|
99
93
|
const newStylesheet = supportsNewStylesheet()
|
|
100
94
|
featuresReport.newStylesheet = newStylesheet
|
|
101
|
-
|
|
95
|
+
markAsSupported("new-stylesheet-as-jsenv-import")
|
|
102
96
|
}
|
|
103
|
-
|
|
104
|
-
return requiredPluginNames
|
|
97
|
+
return missingFeatureNamesCopy
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
const detectSupportedFeatures = async ({
|
|
@@ -127,12 +127,12 @@ const onExecutionError = (
|
|
|
127
127
|
},
|
|
128
128
|
) => {
|
|
129
129
|
const error = executionResult.error
|
|
130
|
-
if (error.code === "NETWORK_FAILURE") {
|
|
130
|
+
if (error && error.code === "NETWORK_FAILURE") {
|
|
131
131
|
if (currentScript) {
|
|
132
132
|
const errorEvent = new Event("error")
|
|
133
133
|
currentScript.dispatchEvent(errorEvent)
|
|
134
134
|
}
|
|
135
|
-
} else {
|
|
135
|
+
} else if (typeof error === "object") {
|
|
136
136
|
const { parsingError } = error
|
|
137
137
|
const globalErrorEvent = new Event("error")
|
|
138
138
|
if (parsingError) {
|
|
@@ -40,7 +40,7 @@ export const createBrowserRuntime = async ({
|
|
|
40
40
|
// if there is an importmap in the document we use it instead of fetching.
|
|
41
41
|
// systemjs style with systemjs-importmap
|
|
42
42
|
const importmapScript = document.querySelector(
|
|
43
|
-
`script[type="
|
|
43
|
+
`script[type="systemjs-importmap"]`,
|
|
44
44
|
)
|
|
45
45
|
let importMap
|
|
46
46
|
let importMapUrl
|
|
@@ -7,7 +7,7 @@ const displayErrorNotificationImplementation = (error, { icon } = {}) => {
|
|
|
7
7
|
if (Notification.permission === "granted") {
|
|
8
8
|
const notification = new Notification("An error occured", {
|
|
9
9
|
lang: "en",
|
|
10
|
-
body: error.stack,
|
|
10
|
+
body: error ? error.stack : "undefined",
|
|
11
11
|
icon,
|
|
12
12
|
})
|
|
13
13
|
notification.onclick = () => {
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
isNodePartOfSupportedRuntimes,
|
|
14
14
|
isBrowserPartOfSupportedRuntimes,
|
|
15
15
|
} from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
|
|
16
|
-
import { featuresCompatMap } from "@jsenv/core/src/internal/generateGroupMap/featuresCompatMap.js"
|
|
17
16
|
import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
|
|
18
17
|
import { createRollupPlugins } from "./rollup_plugin_jsenv.js"
|
|
19
18
|
|
|
@@ -70,21 +69,17 @@ export const buildUsingRollup = async ({
|
|
|
70
69
|
|
|
71
70
|
const runtimeCompatMap = createRuntimeCompat({
|
|
72
71
|
runtimeSupport,
|
|
73
|
-
|
|
74
|
-
import_assertion_type_json: true,
|
|
75
|
-
import_assertion_type_css: true,
|
|
76
|
-
},
|
|
77
|
-
pluginCompatMap: featuresCompatMap,
|
|
72
|
+
featureNames: ["import_assertion_type_json", "import_assertion_type_css"],
|
|
78
73
|
})
|
|
79
74
|
const importAssertionsSupport = {
|
|
80
75
|
json:
|
|
81
76
|
format === "esmodule" &&
|
|
82
|
-
!runtimeCompatMap.
|
|
77
|
+
!runtimeCompatMap.missingFeatureNames.includes(
|
|
83
78
|
"import_assertion_type_json",
|
|
84
79
|
),
|
|
85
80
|
css:
|
|
86
81
|
format === "esmodule" &&
|
|
87
|
-
!runtimeCompatMap.
|
|
82
|
+
!runtimeCompatMap.missingFeatureNames.includes(
|
|
88
83
|
"import_assertion_type_json",
|
|
89
84
|
),
|
|
90
85
|
}
|
|
@@ -114,6 +114,7 @@ export const createRessourceBuilder = (
|
|
|
114
114
|
jsLine,
|
|
115
115
|
jsColumn,
|
|
116
116
|
isImportAssertion,
|
|
117
|
+
isJsModule,
|
|
117
118
|
|
|
118
119
|
contentTypeExpected,
|
|
119
120
|
ressourceSpecifier,
|
|
@@ -131,6 +132,7 @@ export const createRessourceBuilder = (
|
|
|
131
132
|
|
|
132
133
|
contentType,
|
|
133
134
|
bufferBeforeBuild,
|
|
135
|
+
isJsModule,
|
|
134
136
|
})
|
|
135
137
|
return reference
|
|
136
138
|
}
|
|
@@ -772,64 +774,55 @@ export const createRessourceBuilder = (
|
|
|
772
774
|
}
|
|
773
775
|
|
|
774
776
|
const rollupBuildEnd = ({
|
|
775
|
-
|
|
776
|
-
rollupAssetFileInfos,
|
|
777
|
+
rollupResult,
|
|
777
778
|
useImportMapToMaximizeCacheReuse,
|
|
778
779
|
}) => {
|
|
779
780
|
const jsRessources = {}
|
|
781
|
+
|
|
780
782
|
Object.keys(ressourceMap).forEach((ressourceUrl) => {
|
|
781
783
|
const ressource = ressourceMap[ressourceUrl]
|
|
782
|
-
const
|
|
783
|
-
const rollupFileInfo =
|
|
784
|
-
return
|
|
784
|
+
const rollupFileName = Object.keys(rollupResult).find((key) => {
|
|
785
|
+
const rollupFileInfo = rollupResult[key]
|
|
786
|
+
return (
|
|
787
|
+
rollupFileInfo.url === ressourceUrl ||
|
|
788
|
+
// asset
|
|
789
|
+
ressource.fileName === key ||
|
|
790
|
+
ressource.relativeUrl === key
|
|
791
|
+
)
|
|
785
792
|
})
|
|
786
|
-
if (
|
|
787
|
-
const rollupFileInfo =
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
793
|
+
if (rollupFileName) {
|
|
794
|
+
const rollupFileInfo = rollupResult[rollupFileName]
|
|
795
|
+
if (rollupFileInfo.type === "asset") {
|
|
796
|
+
ressource.fileName = rollupFileName
|
|
797
|
+
return
|
|
798
|
+
}
|
|
799
|
+
if (rollupFileInfo.type === "chunk") {
|
|
800
|
+
applyBuildEndEffects(ressource, {
|
|
801
|
+
rollupFileInfo,
|
|
802
|
+
rollupResult,
|
|
803
|
+
useImportMapToMaximizeCacheReuse,
|
|
804
|
+
})
|
|
805
|
+
const { rollupBuildDoneCallbacks } = ressource
|
|
806
|
+
rollupBuildDoneCallbacks.forEach((rollupBuildDoneCallback) => {
|
|
807
|
+
rollupBuildDoneCallback()
|
|
808
|
+
})
|
|
809
|
+
if (rollupFileInfo.type === "chunk") {
|
|
810
|
+
jsRessources[ressourceUrl] = ressource
|
|
802
811
|
}
|
|
803
|
-
|
|
804
|
-
`${shortenUrl(ressource.url)} cannot be found in the build info`,
|
|
805
|
-
)
|
|
812
|
+
return
|
|
806
813
|
}
|
|
807
|
-
applyBuildEndEffects(ressource, {
|
|
808
|
-
rollupFileInfo,
|
|
809
|
-
rollupAssetFileInfos,
|
|
810
|
-
useImportMapToMaximizeCacheReuse,
|
|
811
|
-
})
|
|
812
|
-
const { rollupBuildDoneCallbacks } = ressource
|
|
813
|
-
rollupBuildDoneCallbacks.forEach((rollupBuildDoneCallback) => {
|
|
814
|
-
rollupBuildDoneCallback()
|
|
815
|
-
})
|
|
816
|
-
jsRessources[ressourceUrl] = ressource
|
|
817
|
-
return
|
|
818
814
|
}
|
|
819
815
|
})
|
|
820
|
-
|
|
821
816
|
return { jsRessources }
|
|
822
817
|
}
|
|
823
818
|
|
|
824
819
|
const applyBuildEndEffects = (
|
|
825
820
|
ressource,
|
|
826
|
-
{ rollupFileInfo,
|
|
821
|
+
{ rollupFileInfo, rollupResult, useImportMapToMaximizeCacheReuse },
|
|
827
822
|
) => {
|
|
828
823
|
const fileName = rollupFileInfo.fileName
|
|
829
824
|
let code = rollupFileInfo.code
|
|
830
|
-
|
|
831
|
-
ressource.contentType = "application/javascript"
|
|
832
|
-
}
|
|
825
|
+
ressource.contentType = "application/javascript"
|
|
833
826
|
|
|
834
827
|
if (useImportMapToMaximizeCacheReuse) {
|
|
835
828
|
ressource.fileName = fileName
|
|
@@ -842,8 +835,7 @@ export const createRessourceBuilder = (
|
|
|
842
835
|
const map = rollupFileInfo.map
|
|
843
836
|
if (map) {
|
|
844
837
|
const sourcemapBuildRelativeUrl = `${ressource.buildRelativeUrl}.map`
|
|
845
|
-
const sourcemapRollupFileInfo =
|
|
846
|
-
rollupAssetFileInfos[sourcemapBuildRelativeUrl]
|
|
838
|
+
const sourcemapRollupFileInfo = rollupResult[sourcemapBuildRelativeUrl]
|
|
847
839
|
if (!sourcemapRollupFileInfo) {
|
|
848
840
|
const ressourceBuildUrl = resolveUrl(
|
|
849
841
|
ressource.buildRelativeUrl,
|
|
@@ -873,6 +865,7 @@ export const createRessourceBuilder = (
|
|
|
873
865
|
// ${"//#"} is to avoid a parser thinking there is a sourceMappingUrl for this file
|
|
874
866
|
referenceColumn: `${"//#"} sourceMappingURL=`.length + 1,
|
|
875
867
|
isSourcemap: true,
|
|
868
|
+
isPlaceholder: true,
|
|
876
869
|
})
|
|
877
870
|
sourcemapReference.ressource.buildEnd(
|
|
878
871
|
sourcemapAsString,
|