diff --git a/dist/jsenv_core.js b/dist/jsenv_core.js index 873a7e010a..74b352363c 100644 --- a/dist/jsenv_core.js +++ b/dist/jsenv_core.js @@ -22116,6 +22116,11 @@ const defaultRuntimeCompat = { safari: "11.3", samsung: "9.2", }; +const logsDefault = { + level: "info", + disabled: false, + animation: true, +}; /** * Generate an optimized version of source files into a directory @@ -22154,11 +22159,7 @@ const defaultRuntimeCompat = { const build = async ({ signal = new AbortController().signal, handleSIGINT = true, - logLevel = "info", - logs = { - disabled: false, - animation: true, - }, + logs = logsDefault, sourceDirectoryUrl, buildDirectoryUrl, entryPoints = {}, @@ -22208,6 +22209,21 @@ const build = async ({ `${unexpectedParamNames.join(",")}: there is no such param`, ); } + // logs + { + if (typeof logs !== "object") { + throw new TypeError(`logs must be an object, got ${logs}`); + } + const unexpectedLogsKeys = Object.keys(logs).filter( + (key) => !Object.hasOwn(logsDefault, key), + ); + if (unexpectedLogsKeys.length > 0) { + throw new TypeError( + `${unexpectedLogsKeys.join(",")}: no such key on logs`, + ); + } + logs = { ...logsDefault, ...logs }; + } sourceDirectoryUrl = assertAndNormalizeDirectoryUrl( sourceDirectoryUrl, "sourceDirectoryUrl", @@ -22336,7 +22352,7 @@ build ${entryPointKeys.length} entry points`); }; const rawKitchen = createKitchen({ signal, - logLevel, + logLevel: logs.level, rootDirectoryUrl: sourceDirectoryUrl, ignore, // during first pass (craft) we keep "ignore:" when a reference is ignored @@ -22416,7 +22432,7 @@ build ${entryPointKeys.length} entry points`); const finalKitchen = createKitchen({ name: "shape", - logLevel, + logLevel: logs.level, rootDirectoryUrl: sourceDirectoryUrl, // here most plugins are not there // - no external plugin @@ -22741,7 +22757,7 @@ build ${entryPointKeys.length} entry points`); try { const result = await runBuild({ signal: operation.signal, - logLevel, + logLevel: logs.level, }); return result; } finally { diff --git a/packages/internal/plugin-bundling/tests/chunks_vendors/chunks_vendors.test.mjs b/packages/internal/plugin-bundling/tests/chunks_vendors/chunks_vendors.test.mjs index 29b0abd6a3..0536ca956e 100644 --- a/packages/internal/plugin-bundling/tests/chunks_vendors/chunks_vendors.test.mjs +++ b/packages/internal/plugin-bundling/tests/chunks_vendors/chunks_vendors.test.mjs @@ -5,7 +5,7 @@ const test = async ({ name, ...params }) => { const snapshotDirectoryUrl = new URL(`./snapshots/${name}/`, import.meta.url); const directorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-as-js-classic/tests/as_js_classic/as_js_classic_build.test.mjs b/packages/related/plugin-as-js-classic/tests/as_js_classic/as_js_classic_build.test.mjs index 639bc48070..770ddde612 100644 --- a/packages/related/plugin-as-js-classic/tests/as_js_classic/as_js_classic_build.test.mjs +++ b/packages/related/plugin-as-js-classic/tests/as_js_classic/as_js_classic_build.test.mjs @@ -10,7 +10,7 @@ const test = async (params) => { const snapshotDirectoryUrl = new URL(`./snapshots/`, import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-as-js-classic/tests/as_js_classic_2/as_js_classic_2_build.test.mjs b/packages/related/plugin-as-js-classic/tests/as_js_classic_2/as_js_classic_2_build.test.mjs index 3450b741a2..7a436f5ef1 100644 --- a/packages/related/plugin-as-js-classic/tests/as_js_classic_2/as_js_classic_2_build.test.mjs +++ b/packages/related/plugin-as-js-classic/tests/as_js_classic_2/as_js_classic_2_build.test.mjs @@ -11,7 +11,7 @@ const test = async (params) => { const snapshotDirectoryUrl = new URL("./snapshots/", import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-as-js-classic/tests/as_js_classic_and_fallback/as_js_classic_and_fallback_build.test.mjs b/packages/related/plugin-as-js-classic/tests/as_js_classic_and_fallback/as_js_classic_and_fallback_build.test.mjs index 85cb76f2ea..fa7e1c5f45 100644 --- a/packages/related/plugin-as-js-classic/tests/as_js_classic_and_fallback/as_js_classic_and_fallback_build.test.mjs +++ b/packages/related/plugin-as-js-classic/tests/as_js_classic_and_fallback/as_js_classic_and_fallback_build.test.mjs @@ -10,7 +10,7 @@ const test = async (params) => { const snapshotDirectoryUrl = new URL("./snapshots/build/", import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-as-js-classic/tests/as_js_classic_dynamic_import/as_js_classic_dynamic_import_build.test.mjs b/packages/related/plugin-as-js-classic/tests/as_js_classic_dynamic_import/as_js_classic_dynamic_import_build.test.mjs index 528d885cfd..27d4505f57 100644 --- a/packages/related/plugin-as-js-classic/tests/as_js_classic_dynamic_import/as_js_classic_dynamic_import_build.test.mjs +++ b/packages/related/plugin-as-js-classic/tests/as_js_classic_dynamic_import/as_js_classic_dynamic_import_build.test.mjs @@ -10,7 +10,7 @@ const test = async (params) => { const snapshotDirectoryUrl = new URL("./snapshots/build/", import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-as-js-classic/tests/as_js_classic_inline/as_js_classic_inline_build.test.mjs b/packages/related/plugin-as-js-classic/tests/as_js_classic_inline/as_js_classic_inline_build.test.mjs index 1c4ed76506..17c2b19273 100644 --- a/packages/related/plugin-as-js-classic/tests/as_js_classic_inline/as_js_classic_inline_build.test.mjs +++ b/packages/related/plugin-as-js-classic/tests/as_js_classic_inline/as_js_classic_inline_build.test.mjs @@ -6,7 +6,7 @@ const test = async (params) => { const snapshotDirectoryUrl = new URL("./snapshots/build/", import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/packages/related/plugin-react/tests/react_build/react_build.test.mjs b/packages/related/plugin-react/tests/react_build/react_build.test.mjs index 955edcb91f..d42a5e1a2e 100644 --- a/packages/related/plugin-react/tests/react_build/react_build.test.mjs +++ b/packages/related/plugin-react/tests/react_build/react_build.test.mjs @@ -10,7 +10,7 @@ const test = async ({ name, ...params }) => { const snapshotDirectoryUrl = new URL(`./snapshots/${name}/`, import.meta.url); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: snapshotDirectoryUrl, entryPoints: { diff --git a/tests/__internal__/sigint_warning/build_sigint_warning.test.mjs b/tests/__internal__/sigint_warning/build_sigint_warning.test.mjs index a79c9b2ee1..af470379e7 100644 --- a/tests/__internal__/sigint_warning/build_sigint_warning.test.mjs +++ b/tests/__internal__/sigint_warning/build_sigint_warning.test.mjs @@ -9,7 +9,7 @@ const countListeners = () => { const beforeBuild = countListeners(); const buildPromise = build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: new URL("./dist/", import.meta.url), outDirectoryUrl: new URL("./.jsenv/", import.meta.url), diff --git a/tests/build/versioning_static_import/versioning_static_import.test.mjs b/tests/build/versioning_static_import/versioning_static_import.test.mjs index a4541acb9e..84faad2310 100644 --- a/tests/build/versioning_static_import/versioning_static_import.test.mjs +++ b/tests/build/versioning_static_import/versioning_static_import.test.mjs @@ -30,12 +30,10 @@ const test = async ({ name, ...rest }) => { ); const buildDirectorySnapshot = takeDirectorySnapshot(snapshotDirectoryUrl); await build({ - logLevel: "warn", + logs: { level: "warn" }, sourceDirectoryUrl: new URL("./client/", import.meta.url), buildDirectoryUrl: new URL("./dist/", import.meta.url), - entryPoints: { - "./main.html": "main.html", - }, + entryPoints: { "./main.html": "main.html" }, versioningMethod: "filename", // we could just disable bundling to achieve the same result // but this allows to test versioning with bundling and include param