@jsenv/core 24.6.3 → 25.0.0-alpha.1
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 -1
- package/dist/browser_runtime/{browser_runtime-c7288751.js → browser_runtime_91c5a3b8.js} +213 -109
- 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 -1
- package/dist/compile_proxy/{compile_proxy-28148b58.html → compile_proxy_7ad5faa6.html} +133 -40
- package/dist/compile_proxy/{compile_proxy.html__inline__20-4887fb1d.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +7 -7
- package/dist/event_source_client/asset-manifest.json +2 -1
- package/dist/event_source_client/{event_source_client-9f14c8b9.js → event_source_client_620fbc2c.js} +6 -12
- package/dist/event_source_client/{event_source_client-9f14c8b9.js.map → event_source_client_620fbc2c.js.map} +2 -2
- package/dist/redirector/asset-manifest.json +2 -1
- package/dist/redirector/{redirector.html__inline__15-19e529b9.js.map → redirector_e3b0c442_e391410e.js.map} +7 -7
- package/dist/redirector/{redirector-3c05dbb2.html → redirector_eb92e8a7.html} +133 -40
- package/dist/toolbar/asset-manifest.json +11 -10
- package/dist/toolbar/assets/{compilation.css-209d68b4.map → compilation.css_e37c747b.map} +1 -1
- package/dist/toolbar/assets/{eventsource.css-38cd0a36.map → eventsource.css_c0c71e7b.map} +1 -1
- package/dist/toolbar/assets/{execution.css-0ebe522f.map → execution.css_f3377c10.map} +1 -1
- package/dist/toolbar/assets/{focus.css-3f9c156d.map → focus.css_896f3e45.map} +1 -1
- package/dist/toolbar/assets/{light-theme.css-78b19a80.map → light-theme.css_72a60fa3.map} +1 -1
- package/dist/toolbar/assets/{overflow-menu.css-d9688a1c.map → overflow-menu.css_2859d519.map} +1 -1
- package/dist/toolbar/assets/{settings.css-2b81b245.map → settings.css_61548139.map} +1 -1
- package/dist/toolbar/assets/{toolbar.main.css-846920e9.map → toolbar.main.css_269d7ce2.map} +9 -9
- package/dist/toolbar/assets/{tooltip.css-03395ee6.map → tooltip.css_a94a8bdd.map} +1 -1
- package/dist/toolbar/{toolbar.main-eb8acf83.js.map → toolbar.main2_6c1b3d82.js.map} +9 -9
- package/dist/toolbar/{toolbar-bab473ea.html → toolbar_04ba410c.html} +155 -62
- package/dist/toolbar_injector/asset-manifest.json +3 -2
- package/dist/toolbar_injector/assets/{jsenv-logo-188b9ca6.svg → jsenv-logo_188b9ca6.svg} +0 -0
- package/dist/toolbar_injector/{toolbar_injector-5e32f96a.js → toolbar_injector_4a48bc53.js} +25 -26
- package/dist/toolbar_injector/{toolbar_injector-5e32f96a.js.map → toolbar_injector_4a48bc53.js.map} +4 -5
- package/package.json +6 -5
- package/readme.md +34 -111
- package/src/buildProject.js +45 -32
- package/src/dev_server.js +13 -3
- package/src/execute.js +7 -1
- package/src/executeTestPlan.js +6 -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 +12 -17
- package/src/internal/building/build_logs.js +2 -2
- package/src/internal/building/build_stats.js +11 -1
- package/src/internal/building/html/parseHtmlRessource.js +2 -26
- package/src/internal/building/js/parseJsRessource.js +3 -2
- package/src/internal/building/json_module.js +11 -0
- package/src/internal/building/parseRessource.js +1 -1
- package/src/internal/building/ressource_builder.js +210 -216
- package/src/internal/building/rollup_plugin_jsenv.js +536 -371
- package/src/internal/building/url_loader.js +8 -142
- package/src/internal/building/url_versioning.js +220 -0
- package/src/internal/compiling/compileHtml.js +8 -1
- package/src/internal/compiling/createCompiledFileService.js +32 -44
- 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 +21 -63
- package/src/internal/compiling/js-compilation-service/transformJs.js +4 -4
- package/src/internal/compiling/jsenvCompilerForHtml.js +47 -48
- package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +11 -2
- package/src/internal/compiling/startCompileServer.js +31 -7
- 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 +10 -9
- package/dist/browser_runtime/browser_runtime-c7288751.js.map +0 -1069
- package/src/internal/building/asset_url_versioning.js +0 -50
- package/src/internal/building/rollup_build_sourcemap.js +0 -54
- package/src/internal/building/url-versioning.js +0 -96
- package/src/internal/compiling/js-compilation-service/findAsyncPluginNameInBabelPluginMap.js +0 -9
- package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
- package/src/internal/import-resolution/importmap-default.js +0 -34
- package/src/internal/renderNamePattern.js +0 -6
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
|
@@ -79,6 +79,9 @@ export const executeTestPlan = async ({
|
|
|
79
79
|
compileServerCanWriteOnFilesystem,
|
|
80
80
|
babelPluginMap,
|
|
81
81
|
babelConfigFileUrl,
|
|
82
|
+
workers,
|
|
83
|
+
serviceWorkers,
|
|
84
|
+
importMapInWebWorkers,
|
|
82
85
|
customCompilers,
|
|
83
86
|
jsenvDirectoryClean,
|
|
84
87
|
}) => {
|
|
@@ -179,6 +182,9 @@ export const executeTestPlan = async ({
|
|
|
179
182
|
compileServerCanWriteOnFilesystem,
|
|
180
183
|
babelPluginMap,
|
|
181
184
|
babelConfigFileUrl,
|
|
185
|
+
workers,
|
|
186
|
+
serviceWorkers,
|
|
187
|
+
importMapInWebWorkers,
|
|
182
188
|
customCompilers,
|
|
183
189
|
})
|
|
184
190
|
|
|
@@ -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
|
|
|
@@ -22,7 +21,7 @@ export const buildUsingRollup = async ({
|
|
|
22
21
|
logger,
|
|
23
22
|
|
|
24
23
|
projectDirectoryUrl,
|
|
25
|
-
|
|
24
|
+
entryPoints,
|
|
26
25
|
compileServerOrigin,
|
|
27
26
|
compileDirectoryRelativeUrl,
|
|
28
27
|
buildDirectoryUrl,
|
|
@@ -38,7 +37,6 @@ export const buildUsingRollup = async ({
|
|
|
38
37
|
globals,
|
|
39
38
|
babelPluginMap,
|
|
40
39
|
runtimeSupport,
|
|
41
|
-
transformTopLevelAwait,
|
|
42
40
|
|
|
43
41
|
urlMappings,
|
|
44
42
|
importResolutionMethod,
|
|
@@ -50,9 +48,10 @@ export const buildUsingRollup = async ({
|
|
|
50
48
|
workers,
|
|
51
49
|
serviceWorkers,
|
|
52
50
|
serviceWorkerFinalizer,
|
|
51
|
+
classicWorkers,
|
|
52
|
+
classicServiceWorkers,
|
|
53
53
|
|
|
54
54
|
urlVersioning,
|
|
55
|
-
urlVersionningForEntryPoints,
|
|
56
55
|
lineBreakNormalization,
|
|
57
56
|
jsConcatenation,
|
|
58
57
|
cssConcatenation,
|
|
@@ -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
|
}
|
|
@@ -100,7 +95,7 @@ export const buildUsingRollup = async ({
|
|
|
100
95
|
logger,
|
|
101
96
|
|
|
102
97
|
projectDirectoryUrl,
|
|
103
|
-
|
|
98
|
+
entryPoints,
|
|
104
99
|
compileServerOrigin,
|
|
105
100
|
compileDirectoryRelativeUrl,
|
|
106
101
|
buildDirectoryUrl,
|
|
@@ -108,7 +103,6 @@ export const buildUsingRollup = async ({
|
|
|
108
103
|
format,
|
|
109
104
|
systemJsUrl,
|
|
110
105
|
babelPluginMap,
|
|
111
|
-
transformTopLevelAwait,
|
|
112
106
|
node,
|
|
113
107
|
browser,
|
|
114
108
|
importAssertionsSupport,
|
|
@@ -123,9 +117,10 @@ export const buildUsingRollup = async ({
|
|
|
123
117
|
workers,
|
|
124
118
|
serviceWorkers,
|
|
125
119
|
serviceWorkerFinalizer,
|
|
120
|
+
classicWorkers,
|
|
121
|
+
classicServiceWorkers,
|
|
126
122
|
|
|
127
123
|
urlVersioning,
|
|
128
|
-
urlVersionningForEntryPoints,
|
|
129
124
|
lineBreakNormalization,
|
|
130
125
|
jsConcatenation,
|
|
131
126
|
cssConcatenation,
|
|
@@ -206,7 +201,7 @@ export const buildUsingRollup = async ({
|
|
|
206
201
|
buildFileContents,
|
|
207
202
|
buildInlineFileContents,
|
|
208
203
|
buildStats,
|
|
209
|
-
} = getResult()
|
|
204
|
+
} = await getResult()
|
|
210
205
|
|
|
211
206
|
if (writeOnFileSystem) {
|
|
212
207
|
if (buildDirectoryClean) {
|
|
@@ -266,7 +261,7 @@ const useRollup = async ({
|
|
|
266
261
|
|
|
267
262
|
const rollupInputOptions = {
|
|
268
263
|
// about cache here, we should/could reuse previous rollup call
|
|
269
|
-
// to get the cache from the
|
|
264
|
+
// to get the cache from the entryPoints
|
|
270
265
|
// as shown here: https://rollupjs.org/guide/en#cache
|
|
271
266
|
// it could be passed in arguments to this function
|
|
272
267
|
// however parallelism and having different rollup options per
|
|
@@ -309,7 +304,7 @@ const useRollup = async ({
|
|
|
309
304
|
logger.warn(String(warning))
|
|
310
305
|
},
|
|
311
306
|
// on passe input: [] car c'est le plugin jsenv qui se chargera d'emit des chunks
|
|
312
|
-
// en fonction de
|
|
307
|
+
// en fonction de entryPoints
|
|
313
308
|
// on fait cela car sinon rollup est pénible si on passe un input de type html
|
|
314
309
|
input: [],
|
|
315
310
|
preserveEntrySignatures,
|
|
@@ -5,8 +5,8 @@ import { byteAsFileSize } from "../logs/byteAsFileSize.js"
|
|
|
5
5
|
import { msAsDuration } from "../logs/msAsDuration.js"
|
|
6
6
|
import { stringifyUrlSite } from "./url_trace.js"
|
|
7
7
|
|
|
8
|
-
export const formatBuildStartLog = ({
|
|
9
|
-
const entryFileRelativeUrls = Object.keys(
|
|
8
|
+
export const formatBuildStartLog = ({ entryPoints }) => {
|
|
9
|
+
const entryFileRelativeUrls = Object.keys(entryPoints)
|
|
10
10
|
if (entryFileRelativeUrls.length === 1) {
|
|
11
11
|
return `
|
|
12
12
|
building ${entryFileRelativeUrls[0]}...`
|
|
@@ -59,7 +59,13 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
59
59
|
|
|
60
60
|
Object.keys(ressourceMap).forEach((url) => {
|
|
61
61
|
const ressource = ressourceMap[url]
|
|
62
|
-
const {
|
|
62
|
+
const {
|
|
63
|
+
isInline,
|
|
64
|
+
isExternal,
|
|
65
|
+
isPlaceholder,
|
|
66
|
+
isSourcemap,
|
|
67
|
+
bufferBeforeBuild,
|
|
68
|
+
} = ressource
|
|
63
69
|
if (isInline) {
|
|
64
70
|
// inline ressources are not files
|
|
65
71
|
return
|
|
@@ -80,6 +86,10 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
80
86
|
// to generate it in the build
|
|
81
87
|
return
|
|
82
88
|
}
|
|
89
|
+
if (isSourcemap && !bufferBeforeBuild) {
|
|
90
|
+
// sourcemap generated by rollup do not have bufferBeforeBuild
|
|
91
|
+
return
|
|
92
|
+
}
|
|
83
93
|
projectFileContents[url] = bufferBeforeBuild
|
|
84
94
|
})
|
|
85
95
|
return projectFileContents
|
|
@@ -16,12 +16,7 @@ Or be sure to also reference this url somewhere in the html file like
|
|
|
16
16
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
urlToFilename,
|
|
21
|
-
urlToRelativeUrl,
|
|
22
|
-
resolveUrl,
|
|
23
|
-
urlToParentUrl,
|
|
24
|
-
} from "@jsenv/filesystem"
|
|
19
|
+
import { urlToFilename, urlToRelativeUrl, resolveUrl } from "@jsenv/filesystem"
|
|
25
20
|
|
|
26
21
|
import {
|
|
27
22
|
parseHtmlString,
|
|
@@ -255,7 +250,7 @@ const regularScriptTextNodeVisitor = (
|
|
|
255
250
|
})
|
|
256
251
|
return () => {
|
|
257
252
|
const { bufferAfterBuild } = jsReference.ressource
|
|
258
|
-
textNode.value = bufferAfterBuild
|
|
253
|
+
textNode.value = String(bufferAfterBuild)
|
|
259
254
|
}
|
|
260
255
|
}
|
|
261
256
|
|
|
@@ -359,8 +354,6 @@ const moduleScriptTextNodeVisitor = (
|
|
|
359
354
|
}
|
|
360
355
|
const { bufferAfterBuild } = jsReference.ressource
|
|
361
356
|
const jsText = String(bufferAfterBuild)
|
|
362
|
-
// ici on voudrait pouvoir ajouter le commentaire de la sourcemap
|
|
363
|
-
// sauf que cela se produit un poil plus tard je crois?
|
|
364
357
|
textNode.value = jsText
|
|
365
358
|
}
|
|
366
359
|
}
|
|
@@ -386,23 +379,6 @@ const importmapScriptSrcVisitor = (
|
|
|
386
379
|
contentTypeExpected: "application/importmap+json",
|
|
387
380
|
ressourceSpecifier: srcAttribute.value,
|
|
388
381
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
389
|
-
// here we want to force the fileName for the importmap
|
|
390
|
-
// so that we don't have to rewrite its content
|
|
391
|
-
// the goal is to put the importmap at the same relative path
|
|
392
|
-
// than in the project
|
|
393
|
-
fileNamePattern: () => {
|
|
394
|
-
const importmapReferenceUrl = importmapReference.referenceUrl
|
|
395
|
-
const importmapRessourceUrl = importmapReference.ressource.url
|
|
396
|
-
const importmapUrlRelativeToImporter = urlToRelativeUrl(
|
|
397
|
-
importmapRessourceUrl,
|
|
398
|
-
importmapReferenceUrl,
|
|
399
|
-
)
|
|
400
|
-
const importmapParentRelativeUrl = urlToRelativeUrl(
|
|
401
|
-
urlToParentUrl(resolveUrl(importmapUrlRelativeToImporter, "file://")),
|
|
402
|
-
"file://",
|
|
403
|
-
)
|
|
404
|
-
return `${importmapParentRelativeUrl}[name]-[hash][extname]`
|
|
405
|
-
},
|
|
406
382
|
})
|
|
407
383
|
return ({ getUrlRelativeToImporter }) => {
|
|
408
384
|
const { ressource } = importmapReference
|
|
@@ -103,9 +103,10 @@ export const parseJsRessource = async (
|
|
|
103
103
|
map.file = urlToFilename(jsBuildUrl)
|
|
104
104
|
if (map.sources) {
|
|
105
105
|
map.sources = map.sources.map((source) => {
|
|
106
|
-
const sourceUrl = resolveUrl(source,
|
|
106
|
+
const sourceUrl = resolveUrl(source, jsUrl)
|
|
107
|
+
const sourceOriginalUrl = asOriginalUrl(sourceUrl)
|
|
107
108
|
const sourceUrlRelativeToSourceMap = urlToRelativeUrl(
|
|
108
|
-
|
|
109
|
+
sourceOriginalUrl,
|
|
109
110
|
sourcemapPrecomputedBuildUrl,
|
|
110
111
|
)
|
|
111
112
|
return sourceUrlRelativeToSourceMap
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const convertJsonTextToJavascriptModule = ({ code }) => {
|
|
2
|
+
// here we could do the following
|
|
3
|
+
// return export default jsonText
|
|
4
|
+
// This would return valid js, that would be minified later
|
|
5
|
+
// however we will prefer using JSON.parse because it's faster
|
|
6
|
+
// for js engine to parse JSON than JS
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
code: `export default JSON.parse(${JSON.stringify(code.trim())})`,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -22,7 +22,7 @@ import { parseJsRessource } from "./js/parseJsRessource.js"
|
|
|
22
22
|
import { parseJsonRessource } from "./json/parseJsonRessource.js"
|
|
23
23
|
import { parseWebmanifestRessource } from "./webmanifest/parseWebmanifestRessource.js"
|
|
24
24
|
|
|
25
|
-
export const parseRessource = (
|
|
25
|
+
export const parseRessource = async (
|
|
26
26
|
ressource,
|
|
27
27
|
notifiers,
|
|
28
28
|
{
|