@jsenv/core 25.1.1 → 25.2.0
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/browser_runtime_91c5a3b8.js.map +2 -2
- package/dist/build_manifest.js +4 -4
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/{compile_proxy_e3b0c442_809f35f7.js.map → compile_proxy.html__inline__20_809f35f7.js.map} +0 -0
- package/dist/compile_proxy/{compile_proxy_7ad5faa6.html → compile_proxy_8dfaee51.html} +3 -4
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/{redirector_e3b0c442_e391410e.js.map → redirector.html__inline__15_e391410e.js.map} +0 -0
- package/dist/redirector/{redirector_eb92e8a7.html → redirector_3e9a97b9.html} +3 -4
- package/dist/toolbar/asset-manifest.json +1 -1
- package/dist/toolbar/{toolbar_f7b8a263.html → toolbar_361afb84.html} +2 -3
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/{toolbar_injector_49e4756e.js → toolbar_injector_fac1e995.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector_49e4756e.js.map → toolbar_injector_fac1e995.js.map} +2 -2
- package/package.json +7 -7
- package/readme.md +43 -49
- package/src/buildProject.js +21 -13
- package/src/commonJsToJavaScriptModule.js +8 -7
- package/src/execute.js +2 -0
- package/src/executeTestPlan.js +4 -1
- package/src/internal/building/buildUsingRollup.js +4 -2
- package/src/internal/building/build_stats.js +3 -0
- package/src/internal/building/build_url_generator.js +153 -0
- package/src/internal/building/css/parseCssRessource.js +32 -26
- package/src/internal/building/html/parseHtmlRessource.js +92 -68
- package/src/internal/building/js/parseJsRessource.js +4 -7
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +64 -62
- package/src/internal/building/ressource_builder_util.js +17 -5
- package/src/internal/building/rollup_plugin_jsenv.js +259 -189
- package/src/internal/building/url_fetcher.js +16 -7
- package/src/internal/building/url_loader.js +1 -5
- package/src/internal/building/url_versioning.js +0 -173
- package/src/internal/compiling/babel_plugin_import_metadata.js +7 -11
- package/src/internal/compiling/babel_plugin_proxy_external_imports.js +31 -0
- package/src/internal/compiling/compile-directory/compile-asset.js +8 -4
- package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +43 -8
- package/src/internal/compiling/compile-directory/updateMeta.js +2 -8
- package/src/internal/compiling/compile-directory/validateCache.js +1 -2
- package/src/internal/compiling/compileFile.js +22 -10
- package/src/internal/compiling/createCompiledFileService.js +22 -24
- package/src/internal/compiling/html_source_file_service.js +9 -9
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +14 -4
- package/src/internal/compiling/js-compilation-service/transformJs.js +9 -5
- package/src/internal/compiling/jsenvCompilerForHtml.js +221 -182
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +15 -11
- package/src/internal/compiling/startCompileServer.js +79 -19
- package/src/internal/compiling/transformResultToCompilationResult.js +47 -25
- package/src/internal/executing/executePlan.js +2 -0
- package/src/internal/fetchUrl.js +3 -2
- package/src/internal/integrity/integrity_algorithms.js +26 -0
- package/src/internal/integrity/integrity_parsing.js +50 -0
- package/src/internal/integrity/integrity_update.js +23 -0
- package/src/internal/integrity/integrity_validation.js +49 -0
- package/src/internal/jsenv_remote_directory.js +156 -0
- package/src/internal/origin_directory_converter.js +62 -0
- package/src/internal/response_validation.js +11 -24
- package/src/internal/sourceMappingURLUtils.js +10 -0
- package/src/internal/url_conversion.js +1 -0
|
@@ -232,22 +232,23 @@ const transformHTMLSourceFile = async ({
|
|
|
232
232
|
const { scripts } = parseHtmlAstRessources(htmlAst)
|
|
233
233
|
scripts.forEach((script) => {
|
|
234
234
|
const typeAttribute = getHtmlNodeAttributeByName(script, "type")
|
|
235
|
+
const type = typeAttribute ? typeAttribute.value : ""
|
|
235
236
|
const srcAttribute = getHtmlNodeAttributeByName(script, "src")
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (typeAttribute && typeAttribute.value === "module" && srcAttribute) {
|
|
237
|
+
const src = srcAttribute ? srcAttribute.value : ""
|
|
238
|
+
if (type === "module" && src) {
|
|
239
239
|
removeHtmlNodeAttribute(script, srcAttribute)
|
|
240
|
+
// Ideally jsenv should take into account eventual
|
|
241
|
+
// "integrity" and "crossorigin" attribute during "executeFileUsingDynamicImport"
|
|
240
242
|
setHtmlNodeText(
|
|
241
243
|
script,
|
|
242
244
|
`window.__jsenv__.executeFileUsingDynamicImport(${JSON.stringify(
|
|
243
|
-
|
|
245
|
+
src,
|
|
244
246
|
)})`,
|
|
245
247
|
)
|
|
246
248
|
return
|
|
247
249
|
}
|
|
248
|
-
// inline
|
|
249
250
|
const textNode = getHtmlNodeTextNode(script)
|
|
250
|
-
if (
|
|
251
|
+
if (type === "module" && textNode) {
|
|
251
252
|
const scriptId = getIdForInlineHtmlNode(script, scripts)
|
|
252
253
|
const scriptSpecifier = `${urlToFilename(
|
|
253
254
|
fileUrl,
|
|
@@ -274,7 +275,8 @@ const transformHTMLSourceFile = async ({
|
|
|
274
275
|
projectDirectoryUrl,
|
|
275
276
|
})
|
|
276
277
|
|
|
277
|
-
|
|
278
|
+
const htmlTransformed = stringifyHtmlAst(htmlAst)
|
|
279
|
+
return htmlTransformed
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
const visitImportmapScripts = async ({
|
|
@@ -314,14 +316,12 @@ const visitImportmapScripts = async ({
|
|
|
314
316
|
)
|
|
315
317
|
return
|
|
316
318
|
}
|
|
317
|
-
|
|
318
319
|
const importMapContent = await importMapResponse.json()
|
|
319
320
|
const importMapInlined = moveImportMap(
|
|
320
321
|
importMapContent,
|
|
321
322
|
importMapUrl,
|
|
322
323
|
htmlFileUrl,
|
|
323
324
|
)
|
|
324
|
-
|
|
325
325
|
replaceHtmlNode(
|
|
326
326
|
importmapScript,
|
|
327
327
|
`<script type="importmap">${JSON.stringify(
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getMinimalBabelPluginMap,
|
|
7
7
|
babelPluginsFromBabelPluginMap,
|
|
8
8
|
} from "@jsenv/core/src/internal/compiling/babel_plugins.js"
|
|
9
|
+
import { babelPluginProxyExternalImports } from "@jsenv/core/src/internal/compiling/babel_plugin_proxy_external_imports.js"
|
|
9
10
|
import { babelPluginImportMetadata } from "@jsenv/core/src/internal/compiling/babel_plugin_import_metadata.js"
|
|
10
11
|
|
|
11
12
|
import { ansiToHTML } from "./ansiToHTML.js"
|
|
@@ -15,9 +16,7 @@ import { babelPluginSystemJsPrepend } from "./babel_plugin_systemjs_prepend.js"
|
|
|
15
16
|
import { filePathToBabelHelperName } from "./babelHelper.js"
|
|
16
17
|
|
|
17
18
|
export const jsenvTransform = async ({
|
|
18
|
-
|
|
19
|
-
map, // optional
|
|
20
|
-
ast, // optional
|
|
19
|
+
jsenvRemoteDirectory,
|
|
21
20
|
url,
|
|
22
21
|
relativeUrl, // optional
|
|
23
22
|
|
|
@@ -25,12 +24,15 @@ export const jsenvTransform = async ({
|
|
|
25
24
|
moduleOutFormat,
|
|
26
25
|
importMetaFormat = moduleOutFormat,
|
|
27
26
|
topLevelAwait,
|
|
28
|
-
|
|
29
27
|
babelHelpersInjectionAsImport,
|
|
30
28
|
prependSystemJs,
|
|
31
29
|
transformGenerator,
|
|
32
30
|
regeneratorRuntimeImportPath,
|
|
31
|
+
|
|
33
32
|
sourcemapEnabled,
|
|
33
|
+
ast, // optional
|
|
34
|
+
map, // optional
|
|
35
|
+
code,
|
|
34
36
|
}) => {
|
|
35
37
|
const transformModulesSystemJs = require("@babel/plugin-transform-modules-systemjs")
|
|
36
38
|
const proposalDynamicImport = require("@babel/plugin-proposal-dynamic-import")
|
|
@@ -146,6 +148,14 @@ export const jsenvTransform = async ({
|
|
|
146
148
|
],
|
|
147
149
|
}
|
|
148
150
|
: {}),
|
|
151
|
+
...(jsenvRemoteDirectory
|
|
152
|
+
? {
|
|
153
|
+
"proxy-external-imports": [
|
|
154
|
+
babelPluginProxyExternalImports,
|
|
155
|
+
{ jsenvRemoteDirectory },
|
|
156
|
+
],
|
|
157
|
+
}
|
|
158
|
+
: {}),
|
|
149
159
|
"import-metadata": [babelPluginImportMetadata],
|
|
150
160
|
}
|
|
151
161
|
if (moduleOutFormat === "systemjs") {
|
|
@@ -3,10 +3,9 @@ import { urlToRelativeUrl } from "@jsenv/filesystem"
|
|
|
3
3
|
import { jsenvTransform } from "./jsenvTransform.js"
|
|
4
4
|
|
|
5
5
|
export const transformJs = async ({
|
|
6
|
-
code,
|
|
7
|
-
map,
|
|
8
|
-
url,
|
|
9
6
|
projectDirectoryUrl,
|
|
7
|
+
jsenvRemoteDirectory,
|
|
8
|
+
url,
|
|
10
9
|
|
|
11
10
|
babelPluginMap,
|
|
12
11
|
moduleOutFormat = "esmodule",
|
|
@@ -16,6 +15,9 @@ export const transformJs = async ({
|
|
|
16
15
|
topLevelAwait,
|
|
17
16
|
transformGenerator = true,
|
|
18
17
|
sourcemapEnabled = true,
|
|
18
|
+
|
|
19
|
+
map,
|
|
20
|
+
code,
|
|
19
21
|
}) => {
|
|
20
22
|
if (typeof projectDirectoryUrl !== "string") {
|
|
21
23
|
throw new TypeError(
|
|
@@ -40,12 +42,14 @@ export const transformJs = async ({
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const transformResult = await jsenvTransform({
|
|
43
|
-
code,
|
|
44
|
-
map,
|
|
45
45
|
url,
|
|
46
46
|
relativeUrl: url.startsWith(projectDirectoryUrl)
|
|
47
47
|
? urlToRelativeUrl(url, projectDirectoryUrl)
|
|
48
48
|
: undefined,
|
|
49
|
+
projectDirectoryUrl,
|
|
50
|
+
jsenvRemoteDirectory,
|
|
51
|
+
code,
|
|
52
|
+
map,
|
|
49
53
|
|
|
50
54
|
babelPluginMap,
|
|
51
55
|
moduleOutFormat,
|