@jsenv/core 20.1.11 → 20.1.12
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
CHANGED
|
@@ -586,6 +586,10 @@ building ${entryFileRelativeUrls.length} entry files...`)
|
|
|
586
586
|
return asRollupUrl(importUrl)
|
|
587
587
|
},
|
|
588
588
|
|
|
589
|
+
// TODO: when code is using new URL() pattern
|
|
590
|
+
// the code after build is currently returning a string instead of an url object
|
|
591
|
+
// can we always return an url object because resolveFileUrl is always called
|
|
592
|
+
// by this pattern?
|
|
589
593
|
resolveFileUrl: ({ referenceId, fileName }) => {
|
|
590
594
|
const ressourceFound = ressourceBuilder.findRessource((ressource) => {
|
|
591
595
|
return ressource.rollupReferenceId === referenceId
|
|
@@ -600,21 +604,21 @@ building ${entryFileRelativeUrls.length} entry files...`)
|
|
|
600
604
|
buildRelativeUrlToFileName(buildRelativeUrl)
|
|
601
605
|
return `window.__resolveImportUrl__("./${buildRelativeUrlWithoutVersion}", import.meta.url)`
|
|
602
606
|
}
|
|
603
|
-
return `new URL("${buildRelativeUrl}", import.meta.url)
|
|
607
|
+
return `new URL("${buildRelativeUrl}", import.meta.url)`
|
|
604
608
|
}
|
|
605
609
|
if (format === "systemjs") {
|
|
606
610
|
if (useImportMapToMaximizeCacheReuse && urlVersioning) {
|
|
607
611
|
const buildRelativeUrlWithoutVersion =
|
|
608
612
|
buildRelativeUrlToFileName(buildRelativeUrl)
|
|
609
|
-
return `System.resolve("./${buildRelativeUrlWithoutVersion}", module.meta.url)`
|
|
613
|
+
return `new URL(System.resolve("./${buildRelativeUrlWithoutVersion}", module.meta.url))`
|
|
610
614
|
}
|
|
611
|
-
return `System.resolve("./${buildRelativeUrl}", module.meta.url)`
|
|
615
|
+
return `new URL(System.resolve("./${buildRelativeUrl}", module.meta.url))`
|
|
612
616
|
}
|
|
613
617
|
if (format === "global") {
|
|
614
|
-
return `new URL("${buildRelativeUrl}", document.currentScript && document.currentScript.src || document.baseURI)
|
|
618
|
+
return `new URL("${buildRelativeUrl}", document.currentScript && document.currentScript.src || document.baseURI)`
|
|
615
619
|
}
|
|
616
620
|
if (format === "commonjs") {
|
|
617
|
-
return `new URL("${buildRelativeUrl}", "file:///" + __filename.replace(/\\/g, "/"))
|
|
621
|
+
return `new URL("${buildRelativeUrl}", "file:///" + __filename.replace(/\\/g, "/"))`
|
|
618
622
|
}
|
|
619
623
|
return null
|
|
620
624
|
},
|
|
@@ -815,14 +819,8 @@ building ${entryFileRelativeUrls.length} entry files...`)
|
|
|
815
819
|
jsChunks[fileName] = fileCopy
|
|
816
820
|
})
|
|
817
821
|
await ensureTopLevelAwaitTranspilationIfNeeded({
|
|
818
|
-
jsChunks,
|
|
819
822
|
format,
|
|
820
|
-
babelPluginMap,
|
|
821
823
|
transformTopLevelAwait,
|
|
822
|
-
projectDirectoryUrl,
|
|
823
|
-
asProjectUrl,
|
|
824
|
-
minify,
|
|
825
|
-
minifyJsOptions,
|
|
826
824
|
})
|
|
827
825
|
|
|
828
826
|
const jsModuleBuild = {}
|
|
@@ -1170,62 +1168,23 @@ building ${entryFileRelativeUrls.length} entry files...`)
|
|
|
1170
1168
|
}
|
|
1171
1169
|
|
|
1172
1170
|
const ensureTopLevelAwaitTranspilationIfNeeded = async ({
|
|
1173
|
-
jsChunks,
|
|
1174
1171
|
format,
|
|
1175
1172
|
transformTopLevelAwait,
|
|
1176
|
-
babelPluginMap,
|
|
1177
|
-
projectDirectoryUrl,
|
|
1178
|
-
asProjectUrl,
|
|
1179
|
-
minify,
|
|
1180
|
-
minifyJsOptions,
|
|
1181
1173
|
}) => {
|
|
1182
1174
|
if (!transformTopLevelAwait) {
|
|
1183
1175
|
return
|
|
1184
1176
|
}
|
|
1185
1177
|
|
|
1186
|
-
if (format
|
|
1178
|
+
if (format === "esmodule") {
|
|
1187
1179
|
// transform-async-to-promises won't be able to transform top level await
|
|
1188
1180
|
// for "esmodule", so it would be useless
|
|
1189
1181
|
return
|
|
1190
1182
|
}
|
|
1191
1183
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
const file = jsChunks[fileName]
|
|
1197
|
-
|
|
1198
|
-
let { code, map } = await transformJs({
|
|
1199
|
-
projectDirectoryUrl,
|
|
1200
|
-
code: file.code,
|
|
1201
|
-
map: file.map,
|
|
1202
|
-
url: asProjectUrl(file.url), // transformJs expect a file:// url
|
|
1203
|
-
babelPluginMap,
|
|
1204
|
-
// the top level await transformation should not need any new babel helper
|
|
1205
|
-
// if so let them be inlined
|
|
1206
|
-
babelHelpersInjectionAsImport: false,
|
|
1207
|
-
transformGenerator: false, // assume it was done
|
|
1208
|
-
transformGlobalThis: false,
|
|
1209
|
-
// moduleOutFormat: format, // we are compiling for rollup output must be "esmodule"
|
|
1210
|
-
})
|
|
1211
|
-
|
|
1212
|
-
if (minify) {
|
|
1213
|
-
const result = await minifyJs(code, file.fileName, {
|
|
1214
|
-
sourceMap: {
|
|
1215
|
-
...(map ? { content: JSON.stringify(map) } : {}),
|
|
1216
|
-
asObject: true,
|
|
1217
|
-
},
|
|
1218
|
-
...(format === "global" ? { toplevel: false } : { toplevel: true }),
|
|
1219
|
-
...minifyJsOptions,
|
|
1220
|
-
})
|
|
1221
|
-
code = result.code
|
|
1222
|
-
map = result.map
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
file.code = code
|
|
1226
|
-
file.map = map
|
|
1227
|
-
}),
|
|
1228
|
-
)
|
|
1184
|
+
if (format === "systemjs") {
|
|
1185
|
+
// top level await is an async function for systemjs
|
|
1186
|
+
return
|
|
1187
|
+
}
|
|
1229
1188
|
}
|
|
1230
1189
|
|
|
1231
1190
|
const prepareEntryPoints = async (
|