@jsenv/core 22.5.1 → 23.0.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/jsenv_browser_system.js +203 -49
- package/dist/jsenv_browser_system.js.map +39 -8
- package/dist/jsenv_compile_proxy.js +186 -108
- package/dist/jsenv_compile_proxy.js.map +48 -42
- package/dist/jsenv_exploring_redirector.js +148 -71
- package/dist/jsenv_exploring_redirector.js.map +26 -20
- package/dist/jsenv_toolbar.js +215 -104
- package/dist/jsenv_toolbar.js.map +39 -26
- package/helpers/new_stylesheet/new_stylesheet.js +411 -0
- package/{LICENSE → license} +0 -0
- package/main.js +7 -7
- package/package.json +23 -19
- package/readme.md +5 -4
- package/src/execute.js +23 -10
- package/src/executeTestPlan.js +0 -4
- package/src/importUsingChildProcess.js +36 -32
- package/src/internal/{babel-plugin-replace-expressions.js → babel_plugin_replace_expressions.js} +0 -0
- package/src/internal/{babel-plugin-transform-import-meta.js → babel_plugin_transform_import_meta.js} +0 -0
- package/src/internal/browser-launcher/executeHtmlFile.js +6 -8
- package/src/internal/browser-launcher/jsenv-browser-system.js +3 -0
- package/src/internal/building/asset_url_versioning.js +5 -9
- package/src/internal/building/buildServiceWorker.js +6 -13
- package/src/internal/building/buildUsingRollup.js +34 -0
- package/src/internal/building/build_logs.js +11 -0
- package/src/internal/building/build_stats.js +7 -1
- package/src/internal/building/createJsenvRollupPlugin.js +380 -297
- package/src/internal/building/css/parseCssRessource.js +67 -71
- package/src/internal/building/css/parseCssUrls.js +2 -2
- package/src/internal/building/css/{postcss-urlhash-plugin.js → postcss_plugin_url_visitor.js} +43 -21
- package/src/internal/building/css/replaceCssUrls.js +17 -14
- package/src/internal/building/css_module.js +47 -0
- package/src/internal/building/html/parseHtmlRessource.js +44 -43
- package/src/internal/building/import_references.js +81 -0
- package/src/internal/building/importmap/parseImportmapRessource.js +5 -2
- package/src/internal/building/js/minifyJs.js +30 -3
- package/src/internal/building/js/parseJsRessource.js +70 -77
- package/src/internal/building/json/parseJsonRessource.js +3 -2
- package/src/internal/building/parseRessource.js +11 -8
- package/src/internal/building/parsing.utils.js +4 -15
- package/src/internal/building/ressource_builder.js +142 -114
- package/src/internal/building/ressource_builder_util.js +31 -18
- package/src/internal/building/{fetchSourcemap.js → sourcemap_loader.js} +29 -27
- package/src/internal/building/svg/parseSvgRessource.js +7 -3
- package/src/internal/building/url-versioning.js +2 -1
- package/src/internal/building/url_fetcher.js +79 -0
- package/src/internal/building/url_loader.js +267 -0
- package/src/internal/building/webmanifest/parseWebmanifestRessource.js +9 -4
- package/src/internal/compiling/{js-compilation-service/ensureGlobalThisImportBabelPlugin.js → babel_plugin_global_this_as_jsenv_import.js} +4 -2
- package/src/internal/compiling/babel_plugin_import_assertions.js +100 -0
- package/src/internal/compiling/babel_plugin_new_stylesheet_as_jsenv_import.js +109 -0
- package/src/internal/compiling/babel_plugin_transform_import_specifier.js +86 -0
- package/src/internal/compiling/babel_plugins.js +2 -0
- package/src/internal/compiling/createCompiledFileService.js +6 -8
- package/src/internal/compiling/html_source_file_service.js +2 -2
- package/src/internal/compiling/js-compilation-service/{transformBabelHelperToImportBabelPlugin.js → babel_plugin_babel_helpers_as_jsenv_imports.js} +1 -1
- package/src/internal/compiling/js-compilation-service/{ensureRegeneratorRuntimeImportBabelPlugin.js → babel_plugin_regenerator_runtime_as_jsenv_import.js} +1 -1
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +7 -16
- package/src/internal/compiling/js-compilation-service/transformJs.js +0 -2
- package/src/internal/compiling/rollup_plugin_commonjs_named_exports.js +2 -2
- package/src/internal/compiling/startCompileServer.js +11 -4
- package/src/internal/escapeTemplateStringSpecialCharacters.js +20 -0
- package/src/internal/executing/coverage/{babel-plugin-instrument.js → babel_plugin_instrument.js} +17 -6
- package/src/internal/executing/coverage/relativeUrlToEmptyCoverage.js +1 -1
- package/src/internal/executing/executeConcurrently.js +2 -2
- package/src/internal/executing/executePlan.js +16 -2
- package/src/internal/executing/generateFileExecutionSteps.js +2 -1
- package/src/internal/executing/launchAndExecute.js +43 -69
- package/src/internal/exploring/exploring.css +2 -1
- package/src/internal/exploring/exploring.redirector.js +0 -1
- package/src/internal/generateGroupMap/generateGroupMap.js +14 -10
- package/src/internal/generateGroupMap/jsenvBabelPluginCompatMap.js +30 -0
- package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -6
- package/src/internal/generateGroupMap/one_runtime_compat.js +9 -38
- package/src/internal/generateGroupMap/runtime_compat.js +9 -24
- package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -12
- package/src/internal/generateGroupMap/runtime_support.js +53 -0
- package/src/internal/jsenvInternalFiles.js +0 -1
- package/src/internal/node-launcher/createControllableNodeProcess.js +2 -3
- package/src/internal/response_validation.js +143 -0
- package/src/internal/runtime/createBrowserRuntime/createBrowserRuntime.js +8 -3
- package/src/internal/runtime/createBrowserRuntime/createBrowserSystem.js +117 -0
- package/src/internal/runtime/createBrowserRuntime/displayErrorInDocument.js +1 -1
- package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +124 -68
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +8 -86
- package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +115 -0
- package/src/internal/runtime/module-registration.js +1 -2
- package/src/internal/runtime/resolveGroup.js +2 -3
- package/src/internal/toolbar/compilation/toolbar.compilation.js +15 -17
- package/src/internal/toolbar/eventsource/toolbar.eventsource.js +35 -8
- package/src/internal/toolbar/toolbar.main.js +7 -4
- package/src/internal/url_utils.js +20 -0
- package/src/launchBrowser.js +47 -34
- package/src/launchNode.js +6 -3
- package/src/requireUsingChildProcess.js +36 -32
- package/src/startExploring.js +23 -11
- package/src/internal/building/transformImportMetaUrlReferences.js +0 -71
- package/src/internal/runtime/resolveBrowserGroup.js +0 -5
- package/src/internal/runtime/resolveNodeGroup.js +0 -5
- package/src/internal/validateResponseStatusIsOk.js +0 -91
package/src/executeTestPlan.js
CHANGED
|
@@ -24,7 +24,6 @@ import { generateCoverageJsonFile } from "./internal/executing/coverage/generate
|
|
|
24
24
|
import { generateCoverageHtmlDirectory } from "./internal/executing/coverage/generateCoverageHtmlDirectory.js"
|
|
25
25
|
import { generateCoverageTextLog } from "./internal/executing/coverage/generateCoverageTextLog.js"
|
|
26
26
|
import { jsenvCoverageConfig } from "./jsenvCoverageConfig.js"
|
|
27
|
-
import { jsenvRuntimeSupportDuringDev } from "./jsenvRuntimeSupportDuringDev.js"
|
|
28
27
|
|
|
29
28
|
export const executeTestPlan = async ({
|
|
30
29
|
logLevel = "info",
|
|
@@ -79,8 +78,6 @@ export const executeTestPlan = async ({
|
|
|
79
78
|
babelPluginMap,
|
|
80
79
|
babelConfigFileUrl,
|
|
81
80
|
customCompilers,
|
|
82
|
-
// we could even affine depending on testPlan
|
|
83
|
-
runtimeSupportDuringDev = jsenvRuntimeSupportDuringDev,
|
|
84
81
|
jsenvDirectoryClean,
|
|
85
82
|
}) => {
|
|
86
83
|
const jsenvExecuteTestPlanFunction = async ({ jsenvCancellationToken }) => {
|
|
@@ -188,7 +185,6 @@ export const executeTestPlan = async ({
|
|
|
188
185
|
babelPluginMap,
|
|
189
186
|
babelConfigFileUrl,
|
|
190
187
|
customCompilers,
|
|
191
|
-
runtimeSupport: runtimeSupportDuringDev,
|
|
192
188
|
})
|
|
193
189
|
|
|
194
190
|
if (updateProcessExitCode && !executionIsPassed(result)) {
|
|
@@ -18,41 +18,45 @@ export const importUsingChildProcess = async (
|
|
|
18
18
|
const result = await launchAndExecute({
|
|
19
19
|
stopAfterExecute: true,
|
|
20
20
|
fileRelativeUrl: String(fileUrl),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
runtime: {
|
|
22
|
+
name: "node",
|
|
23
|
+
version: process.version.slice(1),
|
|
24
|
+
launch: async () => {
|
|
25
|
+
const controllableNodeProcess = await createControllableNodeProcess({
|
|
26
|
+
logLevel,
|
|
27
|
+
debugPort,
|
|
28
|
+
debugMode,
|
|
29
|
+
debugModeInheritBreak,
|
|
30
|
+
env,
|
|
31
|
+
commandLineOptions,
|
|
32
|
+
stdin,
|
|
33
|
+
stdout,
|
|
34
|
+
stderr,
|
|
35
|
+
})
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
return {
|
|
38
|
+
...controllableNodeProcess,
|
|
39
|
+
execute: async () => {
|
|
40
|
+
try {
|
|
41
|
+
const namespace =
|
|
42
|
+
await controllableNodeProcess.requestActionOnChildProcess({
|
|
43
|
+
actionType: "execute-using-import",
|
|
44
|
+
actionParams: { fileUrl },
|
|
45
|
+
})
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
return {
|
|
48
|
+
status: "ok",
|
|
49
|
+
namespace,
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return {
|
|
53
|
+
status: "errored",
|
|
54
|
+
error: e,
|
|
55
|
+
}
|
|
47
56
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
error: e,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
}
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
},
|
|
56
60
|
},
|
|
57
61
|
})
|
|
58
62
|
if (result.status === "errored") {
|
package/src/internal/{babel-plugin-replace-expressions.js → babel_plugin_replace_expressions.js}
RENAMED
|
File without changes
|
package/src/internal/{babel-plugin-transform-import-meta.js → babel_plugin_transform_import_meta.js}
RENAMED
|
File without changes
|
|
@@ -47,22 +47,20 @@ export const executeHtmlFile = async (
|
|
|
47
47
|
)
|
|
48
48
|
await page.goto(compileProxyClientUrl)
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const coverageHandledFromOutside =
|
|
51
|
+
coveragePlaywrightAPIAvailable && !coverageForceIstanbul
|
|
52
52
|
|
|
53
53
|
const browserRuntimeFeaturesReport = await page.evaluate(
|
|
54
54
|
/* istanbul ignore next */
|
|
55
|
-
({
|
|
55
|
+
({ coverageHandledFromOutside }) => {
|
|
56
56
|
// eslint-disable-next-line no-undef
|
|
57
57
|
return window.scanBrowserRuntimeFeatures({
|
|
58
|
-
|
|
58
|
+
coverageHandledFromOutside,
|
|
59
|
+
failFastOnFeatureDetection: true,
|
|
59
60
|
})
|
|
60
61
|
},
|
|
61
|
-
{
|
|
62
|
+
{ coverageHandledFromOutside },
|
|
62
63
|
)
|
|
63
|
-
// ici si on peut avoid compilation alors on pourrait visiter la page de base
|
|
64
|
-
// mais il faudrait alors un moyen d'obtenir:
|
|
65
|
-
// coverage et namespace des scripts qui s'éxécute
|
|
66
64
|
|
|
67
65
|
try {
|
|
68
66
|
let executionResult
|
|
@@ -189,7 +189,10 @@ const getBrowserRuntime = memoize(async () => {
|
|
|
189
189
|
return browserRuntime
|
|
190
190
|
})
|
|
191
191
|
|
|
192
|
+
const livereloadingCallbacks = {}
|
|
193
|
+
|
|
192
194
|
window.__jsenv__ = {
|
|
195
|
+
livereloadingCallbacks,
|
|
193
196
|
executionResultPromise,
|
|
194
197
|
executeFileUsingDynamicImport,
|
|
195
198
|
executeFileUsingSystemJs,
|
|
@@ -4,15 +4,11 @@ export const computeBuildRelativeUrlForRessource = (
|
|
|
4
4
|
ressource,
|
|
5
5
|
{ lineBreakNormalization },
|
|
6
6
|
) => {
|
|
7
|
-
return computeBuildRelativeUrl(
|
|
8
|
-
ressource
|
|
9
|
-
ressource.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
contentType: ressource.contentType,
|
|
13
|
-
lineBreakNormalization,
|
|
14
|
-
},
|
|
15
|
-
)
|
|
7
|
+
return computeBuildRelativeUrl(ressource.url, ressource.bufferAfterBuild, {
|
|
8
|
+
pattern: fileNamePatternFromRessource(ressource),
|
|
9
|
+
contentType: ressource.contentType,
|
|
10
|
+
lineBreakNormalization,
|
|
11
|
+
})
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
const assetFileNamePattern = "assets/[name]-[hash][extname]"
|
|
@@ -31,19 +31,12 @@ export const buildServiceWorker = async ({
|
|
|
31
31
|
const serviceWorkerCode = serviceWorkerTransformer(workerBundle.code)
|
|
32
32
|
|
|
33
33
|
if (minify) {
|
|
34
|
-
const minifyResult = await minifyJs(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? { content: JSON.stringify(workerBundle.map) }
|
|
41
|
-
: {}),
|
|
42
|
-
asObject: true,
|
|
43
|
-
includeSources: true,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
)
|
|
34
|
+
const minifyResult = await minifyJs({
|
|
35
|
+
url: serviceWorkerProjectUrl,
|
|
36
|
+
code: serviceWorkerCode,
|
|
37
|
+
map: workerBundle.map,
|
|
38
|
+
sourcemapIncludeSources: true,
|
|
39
|
+
})
|
|
47
40
|
await writeJsAndSourcemap(
|
|
48
41
|
serviceWorkerBuildUrl,
|
|
49
42
|
minifyResult.code,
|
|
@@ -9,6 +9,7 @@ import { createDetailedMessage } from "@jsenv/logger"
|
|
|
9
9
|
|
|
10
10
|
import { buildServiceWorker } from "@jsenv/core/src/internal/building/buildServiceWorker.js"
|
|
11
11
|
import { humanizeUrl } from "@jsenv/core/src/internal/building/url_trace.js"
|
|
12
|
+
import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
|
|
12
13
|
import { createJsenvRollupPlugin } from "./createJsenvRollupPlugin.js"
|
|
13
14
|
|
|
14
15
|
export const buildUsingRollup = async ({
|
|
@@ -68,6 +69,36 @@ export const buildUsingRollup = async ({
|
|
|
68
69
|
runtimeSupport.safari,
|
|
69
70
|
)
|
|
70
71
|
|
|
72
|
+
const runtimeCompatMap = createRuntimeCompat({
|
|
73
|
+
runtimeSupport,
|
|
74
|
+
pluginMap: {
|
|
75
|
+
import_assertion_type_json: true,
|
|
76
|
+
import_assertion_type_css: true,
|
|
77
|
+
},
|
|
78
|
+
pluginCompatMap: {
|
|
79
|
+
import_assertion_type_json: {
|
|
80
|
+
chrome: "91",
|
|
81
|
+
edge: "91",
|
|
82
|
+
},
|
|
83
|
+
import_assertion_type_css: {
|
|
84
|
+
chrome: "93",
|
|
85
|
+
edge: "93",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
const importAssertionsSupport = {
|
|
90
|
+
json:
|
|
91
|
+
format === "esmodule" &&
|
|
92
|
+
!runtimeCompatMap.pluginRequiredNameArray.includes(
|
|
93
|
+
"import_assertion_type_json",
|
|
94
|
+
),
|
|
95
|
+
css:
|
|
96
|
+
format === "esmodule" &&
|
|
97
|
+
!runtimeCompatMap.pluginRequiredNameArray.includes(
|
|
98
|
+
"import_assertion_type_json",
|
|
99
|
+
),
|
|
100
|
+
}
|
|
101
|
+
|
|
71
102
|
const {
|
|
72
103
|
jsenvRollupPlugin,
|
|
73
104
|
getLastErrorMessage,
|
|
@@ -93,6 +124,7 @@ export const buildUsingRollup = async ({
|
|
|
93
124
|
transformTopLevelAwait,
|
|
94
125
|
node,
|
|
95
126
|
browser,
|
|
127
|
+
importAssertionsSupport,
|
|
96
128
|
|
|
97
129
|
urlMappings,
|
|
98
130
|
importResolutionMethod,
|
|
@@ -205,6 +237,7 @@ const useRollup = async ({
|
|
|
205
237
|
asOriginalUrl,
|
|
206
238
|
}) => {
|
|
207
239
|
const { rollup } = await import("rollup")
|
|
240
|
+
const { importAssertions } = await import("acorn-import-assertions")
|
|
208
241
|
|
|
209
242
|
const rollupInputOptions = {
|
|
210
243
|
// about cache here, we should/could reuse previous rollup call
|
|
@@ -256,6 +289,7 @@ const useRollup = async ({
|
|
|
256
289
|
input: [],
|
|
257
290
|
preserveEntrySignatures,
|
|
258
291
|
plugins: [jsenvRollupPlugin],
|
|
292
|
+
acornInjectPlugins: [importAssertions],
|
|
259
293
|
}
|
|
260
294
|
const rollupOutputOptions = {
|
|
261
295
|
// https://rollupjs.org/guide/en#experimentaltoplevelawait
|
|
@@ -4,6 +4,17 @@ import { byteAsFileSize } from "../logs/byteAsFileSize.js"
|
|
|
4
4
|
import { msAsDuration } from "../logs/msAsDuration.js"
|
|
5
5
|
import { stringifyUrlSite } from "./url_trace.js"
|
|
6
6
|
|
|
7
|
+
export const formatBuildStartLog = ({ entryPointMap }) => {
|
|
8
|
+
const entryFileRelativeUrls = Object.keys(entryPointMap)
|
|
9
|
+
if (entryFileRelativeUrls.length === 1) {
|
|
10
|
+
return `
|
|
11
|
+
building ${entryFileRelativeUrls[0]}...`
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return `
|
|
15
|
+
building ${entryFileRelativeUrls.length} entry files...`
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export const formatUseImportMapFromHtml = (importMapInfoFromHtml) => {
|
|
8
19
|
return `
|
|
9
20
|
use importmap from html ${showHtmlSourceLocation(importMapInfoFromHtml)}`
|
|
@@ -59,7 +59,7 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
59
59
|
|
|
60
60
|
Object.keys(ressourceMap).forEach((url) => {
|
|
61
61
|
const ressource = ressourceMap[url]
|
|
62
|
-
const { isInline, isExternal, bufferBeforeBuild } = ressource
|
|
62
|
+
const { isInline, isExternal, isPlaceholder, bufferBeforeBuild } = ressource
|
|
63
63
|
if (isInline) {
|
|
64
64
|
// inline ressources are not files
|
|
65
65
|
return
|
|
@@ -74,6 +74,12 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
74
74
|
// -> we don't gave the bufferBeforeBuild (the ressource file content)
|
|
75
75
|
return
|
|
76
76
|
}
|
|
77
|
+
if (isPlaceholder) {
|
|
78
|
+
// placeholders (used for sourcemap files)
|
|
79
|
+
// means the file did not exists in the project is there is a placeholder
|
|
80
|
+
// to generate it in the build
|
|
81
|
+
return
|
|
82
|
+
}
|
|
77
83
|
projectFileContents[url] = bufferBeforeBuild
|
|
78
84
|
})
|
|
79
85
|
return projectFileContents
|