@bemedev/dev-utils 1.1.1 → 1.3.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/README.md +121 -0
- package/lib/_virtual/_rolldown/runtime.cjs +1 -1
- package/lib/build-tests/addTarball.cjs +5 -1
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +3 -0
- package/lib/build-tests/addTarball.js +5 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs +17 -9
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +5 -0
- package/lib/build-tests/buildPackageJson.js +17 -9
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs +3 -0
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +3 -0
- package/lib/build-tests/cleanup.js +3 -0
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +6 -0
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +6 -0
- package/lib/build-tests/cli/cli.js +6 -0
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/post.cjs +3 -0
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +3 -0
- package/lib/build-tests/cli/post.js +3 -0
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +3 -0
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +3 -0
- package/lib/build-tests/cli/pre.js +3 -0
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs +3 -0
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +3 -0
- package/lib/build-tests/cli/test.js +3 -0
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs +42 -0
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +42 -0
- package/lib/build-tests/constants.js +42 -0
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +7 -0
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +7 -0
- package/lib/build-tests/getRelativePath.js +7 -0
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
- package/lib/build-tests/getTypescriptOutdir.js +5 -0
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs +9 -0
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +9 -0
- package/lib/build-tests/import.js +9 -0
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +7 -0
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +13 -0
- package/lib/build-tests/imports/create.js +7 -0
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +9 -0
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +12 -0
- package/lib/build-tests/imports/helper.js +9 -0
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/pack.cjs +7 -1
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +5 -0
- package/lib/build-tests/pack.js +7 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/plugins/hmr.cjs +72 -0
- package/lib/plugins/hmr.cjs.map +1 -0
- package/lib/plugins/hmr.d.ts +22 -0
- package/lib/plugins/hmr.js +71 -0
- package/lib/plugins/hmr.js.map +1 -0
- package/lib/plugins/index.cjs +5 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -0
- package/lib/plugins/suppressWarnings.cjs +37 -0
- package/lib/plugins/suppressWarnings.cjs.map +1 -0
- package/lib/plugins/suppressWarnings.d.ts +12 -0
- package/lib/plugins/suppressWarnings.js +36 -0
- package/lib/plugins/suppressWarnings.js.map +1 -0
- package/lib/rolldown-config/config.cjs +13 -5
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +7 -0
- package/lib/rolldown-config/config.js +13 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs +15 -0
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +15 -0
- package/lib/rolldown-config/constants.js +15 -0
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +16 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +14 -0
- package/lib/rolldown-config/helpers.js +16 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/input.cjs +8 -0
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +8 -0
- package/lib/rolldown-config/input.js +8 -0
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs +8 -0
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +8 -0
- package/lib/rolldown-config/output.js +8 -0
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +5 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +10 -6
- package/lib/rolldown-config/plugins/circulars.js +5 -5
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +10 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +10 -0
- package/lib/rolldown-config/plugins/clean.js +10 -1
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +4 -3
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -3
- package/lib/rolldown-config/plugins/externals.js +4 -3
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +6 -0
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +6 -0
- package/lib/rolldown-config/plugins/index.js +6 -0
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +7 -0
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.js +7 -0
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +18 -0
- package/lib/utils/array.cjs +7 -0
- package/lib/utils/array.cjs.map +1 -1
- package/lib/utils/array.d.ts +8 -0
- package/lib/utils/array.js +7 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bemedev/globals/types.d.ts +20 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
- package/lib/utils/clamp.cjs +18 -0
- package/lib/utils/clamp.cjs.map +1 -0
- package/lib/utils/clamp.d.ts +10 -0
- package/lib/utils/clamp.js +17 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/identity.cjs +9 -0
- package/lib/utils/identity.cjs.map +1 -1
- package/lib/utils/identity.d.ts +9 -0
- package/lib/utils/identity.js +9 -0
- package/lib/utils/identity.js.map +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs +7 -0
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +7 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +17 -1
- package/lib/vitest-exclude/constants.cjs +3 -0
- package/lib/vitest-exclude/constants.cjs.map +1 -1
- package/lib/vitest-exclude/constants.d.ts +3 -0
- package/lib/vitest-exclude/constants.js +3 -0
- package/lib/vitest-exclude/constants.js.map +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -0
- package/lib/vitest-exclude/vitest.cjs +25 -12
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +9 -8
- package/lib/vitest-exclude/vitest.js +25 -12
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +30 -0
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
- package/lib/vitest-exclude/vitest.utils.js +30 -0
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +11 -2
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +9 -1
- package/lib/vitest-extended/acceptation.js +11 -2
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +34 -27
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +20 -37
- package/lib/vitest-extended/createTests.js +34 -27
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +13 -2
- package/lib/vitest-extended/done.cjs +18 -15
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +6 -5
- package/lib/vitest-extended/done.js +18 -15
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +12 -0
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +12 -0
- package/lib/vitest-extended/each/error.js +12 -0
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +17 -0
- package/lib/vitest-extended/each/pass.cjs +9 -20
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +9 -20
- package/lib/vitest-extended/each/pass.js +9 -20
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +24 -0
- package/lib/vitest-extended/fakeWaiter.cjs +7 -0
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
- package/lib/vitest-extended/fakeWaiter.js +7 -0
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js +11 -0
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +9 -4
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js +18 -0
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
- package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.js +3 -0
- package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs +22 -0
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js +22 -0
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +18 -0
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +18 -0
- package/lib/vitest-extended/identity.js +18 -0
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/isDefined.cjs +9 -0
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +9 -0
- package/lib/vitest-extended/isDefined.js +9 -0
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs +7 -0
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +7 -0
- package/lib/vitest-extended/isFunction.js +7 -0
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/project.cjs +7 -0
- package/lib/vitest-extended/project.cjs.map +1 -1
- package/lib/vitest-extended/project.d.ts +7 -0
- package/lib/vitest-extended/project.js +7 -0
- package/lib/vitest-extended/project.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs +6 -0
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +6 -0
- package/lib/vitest-extended/toArray.js +6 -0
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs +8 -0
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +8 -0
- package/lib/vitest-extended/toStringFlat.js +8 -0
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +64 -0
- package/package.json +14 -9
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_clamp = require("../utils/clamp.cjs");
|
|
3
|
+
const require_utils_array = require("../utils/array.cjs");
|
|
4
|
+
let path = require("path");
|
|
5
|
+
let child_process = require("child_process");
|
|
6
|
+
//#region src/plugins/hmr.ts
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes backslashes in a file path to forward slashes.
|
|
9
|
+
*
|
|
10
|
+
* @param path - File path to normalize.
|
|
11
|
+
*
|
|
12
|
+
* @returns Normalized path string.
|
|
13
|
+
*/
|
|
14
|
+
const normalizePath = (path$1) => path$1.replace(/\\/g, "/");
|
|
15
|
+
/**
|
|
16
|
+
* Vite plugin providing Hot Module Reloading (HMR) capabilities for external
|
|
17
|
+
* file paths by watching files and executing build scripts on changes.
|
|
18
|
+
*
|
|
19
|
+
* @param props - Configuration properties of type {@linkcode HmrPluginProps}.
|
|
20
|
+
*
|
|
21
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
22
|
+
*/
|
|
23
|
+
const hmr = (props) => {
|
|
24
|
+
let isBuilding = false;
|
|
25
|
+
const debounce = require_utils_clamp.clamp(props?.debounce ?? 500, 500, 1e4);
|
|
26
|
+
const paths = [];
|
|
27
|
+
let isDev = false;
|
|
28
|
+
return {
|
|
29
|
+
name: "hmr-add-on",
|
|
30
|
+
configResolved(config) {
|
|
31
|
+
isDev = !config.isProduction;
|
|
32
|
+
if (!isDev) return;
|
|
33
|
+
const resolvedPaths = require_utils_array.toArray(props?.paths).map((p) => (0, path.isAbsolute)(p) ? p : (0, path.resolve)(config.root, p)).map(normalizePath);
|
|
34
|
+
paths.push(...resolvedPaths);
|
|
35
|
+
},
|
|
36
|
+
configEnvironment(name) {
|
|
37
|
+
isDev = name === "dev";
|
|
38
|
+
},
|
|
39
|
+
configureServer(server) {
|
|
40
|
+
if (!isDev) return;
|
|
41
|
+
server.watcher.add(paths);
|
|
42
|
+
},
|
|
43
|
+
handleHotUpdate(ctx) {
|
|
44
|
+
if (!isDev) return;
|
|
45
|
+
if (isBuilding) return ctx.modules;
|
|
46
|
+
const normalizedFile = normalizePath(ctx.file);
|
|
47
|
+
if (paths.some((p) => normalizedFile.includes(p))) {
|
|
48
|
+
console.log(`\n⚡ External file modified: ${ctx.file}. Starting build...`);
|
|
49
|
+
try {
|
|
50
|
+
isBuilding = true;
|
|
51
|
+
require_utils_array.toArray(props?.scripts).forEach((script) => {
|
|
52
|
+
(0, child_process.execSync)(script, { stdio: "inherit" });
|
|
53
|
+
});
|
|
54
|
+
ctx.server.moduleGraph.invalidateAll();
|
|
55
|
+
ctx.server.ws.send({ type: "full-reload" });
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error("❌ Command execution failed during HMR:", error);
|
|
58
|
+
} finally {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
isBuilding = false;
|
|
61
|
+
console.log("✅ Build completed. Ready for subsequent changes.");
|
|
62
|
+
}, debounce);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return ctx.modules;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.hmr = hmr;
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=hmr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.cjs","names":["path","clamp","toArray","isAbsolute","resolve"],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { resolve, isAbsolute } from 'path';\n\nimport { type Plugin } from 'vitest/config';\n\nimport { toArray } from '#utils/array';\nimport { clamp } from '#utils/clamp';\nimport type { SoA } from '#utils/types';\n\n/**\n * Configuration options for the HMR add-on plugin.\n */\nexport type HmrPluginProps = {\n /** Single file path or array of file paths of type {@linkcode SoA} to watch for changes. */\n paths?: SoA<string>;\n\n /** Single shell command or array of shell commands of type {@linkcode SoA} to execute when a change is detected. */\n scripts?: SoA<string>;\n\n /** Optional interval in milliseconds to wait before allowing another build. */\n debounce?: number;\n};\n\n/**\n * Normalizes backslashes in a file path to forward slashes.\n *\n * @param path - File path to normalize.\n *\n * @returns Normalized path string.\n */\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\n/**\n * Vite plugin providing Hot Module Reloading (HMR) capabilities for external\n * file paths by watching files and executing build scripts on changes.\n *\n * @param props - Configuration properties of type {@linkcode HmrPluginProps}.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport const hmr = (props?: HmrPluginProps): Plugin => {\n // Lock variable to prevent infinite build loops\n let isBuilding = false;\n const debounce = clamp(props?.debounce ?? 500, 500, 10_000);\n const paths: string[] = [];\n let isDev = false;\n\n return {\n name: 'hmr-add-on',\n\n configResolved(config) {\n isDev = !config.isProduction;\n if (!isDev) return;\n\n // Resolve relative paths based on Vite project root\n const resolvedPaths = toArray(props?.paths)\n .map(p => (isAbsolute(p) ? p : resolve(config.root, p)))\n .map(normalizePath);\n\n paths.push(...resolvedPaths);\n },\n\n configEnvironment(name) {\n isDev = name === 'dev';\n },\n\n configureServer(server) {\n if (!isDev) return;\n\n server.watcher.add(paths);\n },\n\n handleHotUpdate(ctx) {\n if (!isDev) return;\n\n // 1. If a build is already in progress, ignore ALL changes (prevents loops)\n if (isBuilding) return ctx.modules;\n const normalizedFile = normalizePath(ctx.file);\n const checks = paths.some(p => normalizedFile.includes(p));\n\n if (checks) {\n console.log(\n `\\n⚡ External file modified: ${ctx.file}. Starting build...`,\n );\n\n try {\n // 2. Acquire lock before starting the build\n isBuilding = true;\n const scripts = toArray(props?.scripts);\n\n scripts.forEach(script => {\n execSync(script, { stdio: 'inherit' });\n });\n\n // Invalidate module graph so Vite reads fresh built files from disk\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n } catch (error) {\n console.error('❌ Command execution failed during HMR:', error);\n } finally {\n // 3. Once build is complete, wait for the debounce period to allow\n // Vite to ignore generated build files, then release the lock.\n setTimeout(() => {\n isBuilding = false;\n console.log(\n '✅ Build completed. Ready for subsequent changes.',\n );\n }, debounce);\n }\n }\n\n return ctx.modules;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,iBAAiB,WAAiBA,OAAK,QAAQ,OAAO,GAAG;;;;;;;;;AAU/D,MAAa,OAAO,UAAmC;CAErD,IAAI,aAAa;CACjB,MAAM,WAAWC,oBAAAA,MAAM,OAAO,YAAY,KAAK,KAAK,GAAM;CAC1D,MAAM,QAAkB,CAAC;CACzB,IAAI,QAAQ;CAEZ,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,QAAQ,CAAC,OAAO;GAChB,IAAI,CAAC,OAAO;GAGZ,MAAM,gBAAgBC,oBAAAA,QAAQ,OAAO,KAAK,CAAC,CACxC,KAAI,OAAA,GAAMC,KAAAA,WAAAA,CAAW,CAAC,IAAI,KAAA,GAAIC,KAAAA,QAAAA,CAAQ,OAAO,MAAM,CAAC,CAAE,CAAC,CACvD,IAAI,aAAa;GAEpB,MAAM,KAAK,GAAG,aAAa;EAC7B;EAEA,kBAAkB,MAAM;GACtB,QAAQ,SAAS;EACnB;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,OAAO;GAEZ,OAAO,QAAQ,IAAI,KAAK;EAC1B;EAEA,gBAAgB,KAAK;GACnB,IAAI,CAAC,OAAO;GAGZ,IAAI,YAAY,OAAO,IAAI;GAC3B,MAAM,iBAAiB,cAAc,IAAI,IAAI;GAG7C,IAFe,MAAM,MAAK,MAAK,eAAe,SAAS,CAAC,CAE/C,GAAG;IACV,QAAQ,IACN,+BAA+B,IAAI,KAAK,oBAC1C;IAEA,IAAI;KAEF,aAAa;KAGb,oBAFgBF,QAAQ,OAAO,OAEzB,CAAC,CAAC,SAAQ,WAAU;MACxB,CAAA,GAAA,cAAA,SAAA,CAAS,QAAQ,EAAE,OAAO,UAAU,CAAC;KACvC,CAAC;KAGD,IAAI,OAAO,YAAY,cAAc;KACrC,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5C,SAAS,OAAO;KACd,QAAQ,MAAM,0CAA0C,KAAK;IAC/D,UAAU;KAGR,iBAAiB;MACf,aAAa;MACb,QAAQ,IACN,kDACF;KACF,GAAG,QAAQ;IACb;GACF;GAEA,OAAO,IAAI;EACb;CACF;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Plugin } from 'vitest/config';
|
|
2
|
+
import type { SoA } from '../utils/types';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the HMR add-on plugin.
|
|
5
|
+
*/
|
|
6
|
+
export type HmrPluginProps = {
|
|
7
|
+
/** Single file path or array of file paths of type {@linkcode SoA} to watch for changes. */
|
|
8
|
+
paths?: SoA<string>;
|
|
9
|
+
/** Single shell command or array of shell commands of type {@linkcode SoA} to execute when a change is detected. */
|
|
10
|
+
scripts?: SoA<string>;
|
|
11
|
+
/** Optional interval in milliseconds to wait before allowing another build. */
|
|
12
|
+
debounce?: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Vite plugin providing Hot Module Reloading (HMR) capabilities for external
|
|
16
|
+
* file paths by watching files and executing build scripts on changes.
|
|
17
|
+
*
|
|
18
|
+
* @param props - Configuration properties of type {@linkcode HmrPluginProps}.
|
|
19
|
+
*
|
|
20
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
21
|
+
*/
|
|
22
|
+
export declare const hmr: (props?: HmrPluginProps) => Plugin;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { clamp } from "../utils/clamp.js";
|
|
2
|
+
import { toArray } from "../utils/array.js";
|
|
3
|
+
import { isAbsolute, resolve } from "path";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
//#region src/plugins/hmr.ts
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes backslashes in a file path to forward slashes.
|
|
8
|
+
*
|
|
9
|
+
* @param path - File path to normalize.
|
|
10
|
+
*
|
|
11
|
+
* @returns Normalized path string.
|
|
12
|
+
*/
|
|
13
|
+
const normalizePath = (path) => path.replace(/\\/g, "/");
|
|
14
|
+
/**
|
|
15
|
+
* Vite plugin providing Hot Module Reloading (HMR) capabilities for external
|
|
16
|
+
* file paths by watching files and executing build scripts on changes.
|
|
17
|
+
*
|
|
18
|
+
* @param props - Configuration properties of type {@linkcode HmrPluginProps}.
|
|
19
|
+
*
|
|
20
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
21
|
+
*/
|
|
22
|
+
const hmr = (props) => {
|
|
23
|
+
let isBuilding = false;
|
|
24
|
+
const debounce = clamp(props?.debounce ?? 500, 500, 1e4);
|
|
25
|
+
const paths = [];
|
|
26
|
+
let isDev = false;
|
|
27
|
+
return {
|
|
28
|
+
name: "hmr-add-on",
|
|
29
|
+
configResolved(config) {
|
|
30
|
+
isDev = !config.isProduction;
|
|
31
|
+
if (!isDev) return;
|
|
32
|
+
const resolvedPaths = toArray(props?.paths).map((p) => isAbsolute(p) ? p : resolve(config.root, p)).map(normalizePath);
|
|
33
|
+
paths.push(...resolvedPaths);
|
|
34
|
+
},
|
|
35
|
+
configEnvironment(name) {
|
|
36
|
+
isDev = name === "dev";
|
|
37
|
+
},
|
|
38
|
+
configureServer(server) {
|
|
39
|
+
if (!isDev) return;
|
|
40
|
+
server.watcher.add(paths);
|
|
41
|
+
},
|
|
42
|
+
handleHotUpdate(ctx) {
|
|
43
|
+
if (!isDev) return;
|
|
44
|
+
if (isBuilding) return ctx.modules;
|
|
45
|
+
const normalizedFile = normalizePath(ctx.file);
|
|
46
|
+
if (paths.some((p) => normalizedFile.includes(p))) {
|
|
47
|
+
console.log(`\n⚡ External file modified: ${ctx.file}. Starting build...`);
|
|
48
|
+
try {
|
|
49
|
+
isBuilding = true;
|
|
50
|
+
toArray(props?.scripts).forEach((script) => {
|
|
51
|
+
execSync(script, { stdio: "inherit" });
|
|
52
|
+
});
|
|
53
|
+
ctx.server.moduleGraph.invalidateAll();
|
|
54
|
+
ctx.server.ws.send({ type: "full-reload" });
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("❌ Command execution failed during HMR:", error);
|
|
57
|
+
} finally {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
isBuilding = false;
|
|
60
|
+
console.log("✅ Build completed. Ready for subsequent changes.");
|
|
61
|
+
}, debounce);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return ctx.modules;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { hmr };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=hmr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.js","names":[],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { resolve, isAbsolute } from 'path';\n\nimport { type Plugin } from 'vitest/config';\n\nimport { toArray } from '#utils/array';\nimport { clamp } from '#utils/clamp';\nimport type { SoA } from '#utils/types';\n\n/**\n * Configuration options for the HMR add-on plugin.\n */\nexport type HmrPluginProps = {\n /** Single file path or array of file paths of type {@linkcode SoA} to watch for changes. */\n paths?: SoA<string>;\n\n /** Single shell command or array of shell commands of type {@linkcode SoA} to execute when a change is detected. */\n scripts?: SoA<string>;\n\n /** Optional interval in milliseconds to wait before allowing another build. */\n debounce?: number;\n};\n\n/**\n * Normalizes backslashes in a file path to forward slashes.\n *\n * @param path - File path to normalize.\n *\n * @returns Normalized path string.\n */\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\n/**\n * Vite plugin providing Hot Module Reloading (HMR) capabilities for external\n * file paths by watching files and executing build scripts on changes.\n *\n * @param props - Configuration properties of type {@linkcode HmrPluginProps}.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport const hmr = (props?: HmrPluginProps): Plugin => {\n // Lock variable to prevent infinite build loops\n let isBuilding = false;\n const debounce = clamp(props?.debounce ?? 500, 500, 10_000);\n const paths: string[] = [];\n let isDev = false;\n\n return {\n name: 'hmr-add-on',\n\n configResolved(config) {\n isDev = !config.isProduction;\n if (!isDev) return;\n\n // Resolve relative paths based on Vite project root\n const resolvedPaths = toArray(props?.paths)\n .map(p => (isAbsolute(p) ? p : resolve(config.root, p)))\n .map(normalizePath);\n\n paths.push(...resolvedPaths);\n },\n\n configEnvironment(name) {\n isDev = name === 'dev';\n },\n\n configureServer(server) {\n if (!isDev) return;\n\n server.watcher.add(paths);\n },\n\n handleHotUpdate(ctx) {\n if (!isDev) return;\n\n // 1. If a build is already in progress, ignore ALL changes (prevents loops)\n if (isBuilding) return ctx.modules;\n const normalizedFile = normalizePath(ctx.file);\n const checks = paths.some(p => normalizedFile.includes(p));\n\n if (checks) {\n console.log(\n `\\n⚡ External file modified: ${ctx.file}. Starting build...`,\n );\n\n try {\n // 2. Acquire lock before starting the build\n isBuilding = true;\n const scripts = toArray(props?.scripts);\n\n scripts.forEach(script => {\n execSync(script, { stdio: 'inherit' });\n });\n\n // Invalidate module graph so Vite reads fresh built files from disk\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n } catch (error) {\n console.error('❌ Command execution failed during HMR:', error);\n } finally {\n // 3. Once build is complete, wait for the debounce period to allow\n // Vite to ignore generated build files, then release the lock.\n setTimeout(() => {\n isBuilding = false;\n console.log(\n '✅ Build completed. Ready for subsequent changes.',\n );\n }, debounce);\n }\n }\n\n return ctx.modules;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,iBAAiB,SAAiB,KAAK,QAAQ,OAAO,GAAG;;;;;;;;;AAU/D,MAAa,OAAO,UAAmC;CAErD,IAAI,aAAa;CACjB,MAAM,WAAW,MAAM,OAAO,YAAY,KAAK,KAAK,GAAM;CAC1D,MAAM,QAAkB,CAAC;CACzB,IAAI,QAAQ;CAEZ,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,QAAQ,CAAC,OAAO;GAChB,IAAI,CAAC,OAAO;GAGZ,MAAM,gBAAgB,QAAQ,OAAO,KAAK,CAAC,CACxC,KAAI,MAAM,WAAW,CAAC,IAAI,IAAI,QAAQ,OAAO,MAAM,CAAC,CAAE,CAAC,CACvD,IAAI,aAAa;GAEpB,MAAM,KAAK,GAAG,aAAa;EAC7B;EAEA,kBAAkB,MAAM;GACtB,QAAQ,SAAS;EACnB;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,OAAO;GAEZ,OAAO,QAAQ,IAAI,KAAK;EAC1B;EAEA,gBAAgB,KAAK;GACnB,IAAI,CAAC,OAAO;GAGZ,IAAI,YAAY,OAAO,IAAI;GAC3B,MAAM,iBAAiB,cAAc,IAAI,IAAI;GAG7C,IAFe,MAAM,MAAK,MAAK,eAAe,SAAS,CAAC,CAE/C,GAAG;IACV,QAAQ,IACN,+BAA+B,IAAI,KAAK,oBAC1C;IAEA,IAAI;KAEF,aAAa;KAGb,QAFwB,OAAO,OAEzB,CAAC,CAAC,SAAQ,WAAU;MACxB,SAAS,QAAQ,EAAE,OAAO,UAAU,CAAC;KACvC,CAAC;KAGD,IAAI,OAAO,YAAY,cAAc;KACrC,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5C,SAAS,OAAO;KACd,QAAQ,MAAM,0CAA0C,KAAK;IAC/D,UAAU;KAGR,iBAAiB;MACf,aAAa;MACb,QAAQ,IACN,kDACF;KACF,GAAG,QAAQ;IACb;GACF;GAEA,OAAO,IAAI;EACb;CACF;AACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_plugins_suppressWarnings = require("./suppressWarnings.cjs");
|
|
3
|
+
const require_plugins_hmr = require("./hmr.cjs");
|
|
4
|
+
exports.hmr = require_plugins_hmr.hmr;
|
|
5
|
+
exports.suppressWarnings = require_plugins_suppressWarnings.suppressWarnings;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/plugins/suppressWarnings.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin to filter out noisy terminal stdout/stderr warnings emitted
|
|
5
|
+
* by Nitro, SSR workers, or third-party dependencies during dev.
|
|
6
|
+
*
|
|
7
|
+
* @param patterns - Array of type {@linkcode string} or type
|
|
8
|
+
* {@linkcode RegExp} patterns to match against `stderr` chunks to
|
|
9
|
+
* suppress.
|
|
10
|
+
*
|
|
11
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
12
|
+
*/
|
|
13
|
+
function suppressWarnings(...patterns) {
|
|
14
|
+
let isInitialized = false;
|
|
15
|
+
const shouldSuppress = (chunk) => {
|
|
16
|
+
const str = typeof chunk === "string" ? chunk : chunk?.toString?.() || "";
|
|
17
|
+
return patterns.some((pattern) => typeof pattern === "string" ? str.includes(pattern) : pattern.test(str));
|
|
18
|
+
};
|
|
19
|
+
const initFilter = () => {
|
|
20
|
+
if (isInitialized) return;
|
|
21
|
+
isInitialized = true;
|
|
22
|
+
const origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
23
|
+
process.stderr.write = ((chunk, ...args) => {
|
|
24
|
+
if (shouldSuppress(chunk)) return true;
|
|
25
|
+
return origStderrWrite(chunk, ...args);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
initFilter();
|
|
29
|
+
return {
|
|
30
|
+
name: "suppress-logs-plugin",
|
|
31
|
+
apply: "serve"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.suppressWarnings = suppressWarnings;
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=suppressWarnings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressWarnings.cjs","names":[],"sources":["../../src/plugins/suppressWarnings.ts"],"sourcesContent":["import { type Plugin } from 'vitest/config';\n\n/**\n * Vite plugin to filter out noisy terminal stdout/stderr warnings emitted\n * by Nitro, SSR workers, or third-party dependencies during dev.\n *\n * @param patterns - Array of type {@linkcode string} or type\n * {@linkcode RegExp} patterns to match against `stderr` chunks to\n * suppress.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport function suppressWarnings(\n ...patterns: Array<string | RegExp>\n): Plugin {\n let isInitialized = false;\n\n const shouldSuppress = (chunk: unknown): boolean => {\n const str =\n typeof chunk === 'string'\n ? chunk\n : (chunk as any)?.toString?.() || '';\n return patterns.some(pattern =>\n typeof pattern === 'string'\n ? str.includes(pattern)\n : pattern.test(str),\n );\n };\n\n const initFilter = () => {\n if (isInitialized) return;\n isInitialized = true;\n\n const origStderrWrite = process.stderr.write.bind(process.stderr);\n process.stderr.write = ((chunk: any, ...args: any[]) => {\n if (shouldSuppress(chunk)) return true;\n return (origStderrWrite as any)(chunk, ...args);\n }) as any;\n };\n\n // Initialize immediately on plugin registration\n initFilter();\n\n return {\n name: 'suppress-logs-plugin',\n apply: 'serve', // Runs only during dev\n };\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,iBACd,GAAG,UACK;CACR,IAAI,gBAAgB;CAEpB,MAAM,kBAAkB,UAA4B;EAClD,MAAM,MACJ,OAAO,UAAU,WACb,QACC,OAAe,WAAW,KAAK;EACtC,OAAO,SAAS,MAAK,YACnB,OAAO,YAAY,WACf,IAAI,SAAS,OAAO,IACpB,QAAQ,KAAK,GAAG,CACtB;CACF;CAEA,MAAM,mBAAmB;EACvB,IAAI,eAAe;EACnB,gBAAgB;EAEhB,MAAM,kBAAkB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;EAChE,QAAQ,OAAO,UAAU,OAAY,GAAG,SAAgB;GACtD,IAAI,eAAe,KAAK,GAAG,OAAO;GAClC,OAAQ,gBAAwB,OAAO,GAAG,IAAI;EAChD;CACF;CAGA,WAAW;CAEX,OAAO;EACL,MAAM;EACN,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Plugin } from 'vitest/config';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to filter out noisy terminal stdout/stderr warnings emitted
|
|
4
|
+
* by Nitro, SSR workers, or third-party dependencies during dev.
|
|
5
|
+
*
|
|
6
|
+
* @param patterns - Array of type {@linkcode string} or type
|
|
7
|
+
* {@linkcode RegExp} patterns to match against `stderr` chunks to
|
|
8
|
+
* suppress.
|
|
9
|
+
*
|
|
10
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
11
|
+
*/
|
|
12
|
+
export declare function suppressWarnings(...patterns: Array<string | RegExp>): Plugin;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/plugins/suppressWarnings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to filter out noisy terminal stdout/stderr warnings emitted
|
|
4
|
+
* by Nitro, SSR workers, or third-party dependencies during dev.
|
|
5
|
+
*
|
|
6
|
+
* @param patterns - Array of type {@linkcode string} or type
|
|
7
|
+
* {@linkcode RegExp} patterns to match against `stderr` chunks to
|
|
8
|
+
* suppress.
|
|
9
|
+
*
|
|
10
|
+
* @returns A Vite plugin object of type {@linkcode Plugin}.
|
|
11
|
+
*/
|
|
12
|
+
function suppressWarnings(...patterns) {
|
|
13
|
+
let isInitialized = false;
|
|
14
|
+
const shouldSuppress = (chunk) => {
|
|
15
|
+
const str = typeof chunk === "string" ? chunk : chunk?.toString?.() || "";
|
|
16
|
+
return patterns.some((pattern) => typeof pattern === "string" ? str.includes(pattern) : pattern.test(str));
|
|
17
|
+
};
|
|
18
|
+
const initFilter = () => {
|
|
19
|
+
if (isInitialized) return;
|
|
20
|
+
isInitialized = true;
|
|
21
|
+
const origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
22
|
+
process.stderr.write = ((chunk, ...args) => {
|
|
23
|
+
if (shouldSuppress(chunk)) return true;
|
|
24
|
+
return origStderrWrite(chunk, ...args);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
initFilter();
|
|
28
|
+
return {
|
|
29
|
+
name: "suppress-logs-plugin",
|
|
30
|
+
apply: "serve"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { suppressWarnings };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=suppressWarnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressWarnings.js","names":[],"sources":["../../src/plugins/suppressWarnings.ts"],"sourcesContent":["import { type Plugin } from 'vitest/config';\n\n/**\n * Vite plugin to filter out noisy terminal stdout/stderr warnings emitted\n * by Nitro, SSR workers, or third-party dependencies during dev.\n *\n * @param patterns - Array of type {@linkcode string} or type\n * {@linkcode RegExp} patterns to match against `stderr` chunks to\n * suppress.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport function suppressWarnings(\n ...patterns: Array<string | RegExp>\n): Plugin {\n let isInitialized = false;\n\n const shouldSuppress = (chunk: unknown): boolean => {\n const str =\n typeof chunk === 'string'\n ? chunk\n : (chunk as any)?.toString?.() || '';\n return patterns.some(pattern =>\n typeof pattern === 'string'\n ? str.includes(pattern)\n : pattern.test(str),\n );\n };\n\n const initFilter = () => {\n if (isInitialized) return;\n isInitialized = true;\n\n const origStderrWrite = process.stderr.write.bind(process.stderr);\n process.stderr.write = ((chunk: any, ...args: any[]) => {\n if (shouldSuppress(chunk)) return true;\n return (origStderrWrite as any)(chunk, ...args);\n }) as any;\n };\n\n // Initialize immediately on plugin registration\n initFilter();\n\n return {\n name: 'suppress-logs-plugin',\n apply: 'serve', // Runs only during dev\n };\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,iBACd,GAAG,UACK;CACR,IAAI,gBAAgB;CAEpB,MAAM,kBAAkB,UAA4B;EAClD,MAAM,MACJ,OAAO,UAAU,WACb,QACC,OAAe,WAAW,KAAK;EACtC,OAAO,SAAS,MAAK,YACnB,OAAO,YAAY,WACf,IAAI,SAAS,OAAO,IACpB,QAAQ,KAAK,GAAG,CACtB;CACF;CAEA,MAAM,mBAAmB;EACvB,IAAI,eAAe;EACnB,gBAAgB;EAEhB,MAAM,kBAAkB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;EAChE,QAAQ,OAAO,UAAU,OAAY,GAAG,SAAgB;GACtD,IAAI,eAAe,KAAK,GAAG,OAAO;GAClC,OAAQ,gBAAwB,OAAO,GAAG,IAAI;EAChD;CACF;CAGA,WAAW;CAEX,OAAO;EACL,MAAM;EACN,OAAO;CACT;AACF"}
|
|
@@ -7,6 +7,13 @@ const require_rolldown_config_plugins_index = require("./plugins/index.cjs");
|
|
|
7
7
|
let rolldown = require("rolldown");
|
|
8
8
|
let rolldown_plugins = require("rolldown/plugins");
|
|
9
9
|
//#region src/rolldown-config/config.ts
|
|
10
|
+
/**
|
|
11
|
+
* Generates Rolldown configuration using default or customized options.
|
|
12
|
+
*
|
|
13
|
+
* @param additionals - Optional build configuration parameters of type {@linkcode Params}.
|
|
14
|
+
*
|
|
15
|
+
* @returns Configured Rolldown options of type {@linkcode RolldownOptions}.
|
|
16
|
+
*/
|
|
10
17
|
const defineConfig = (additionals) => {
|
|
11
18
|
return defineConfig.default(additionals);
|
|
12
19
|
};
|
|
@@ -57,13 +64,14 @@ defineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {
|
|
|
57
64
|
const input = require_rolldown_config_input.buildInput();
|
|
58
65
|
const external = rest.externals;
|
|
59
66
|
const output = require_rolldown_config_output.buildOutput(dir, sourcemap);
|
|
67
|
+
const plugins = producePlugins({
|
|
68
|
+
dir,
|
|
69
|
+
sourcemap,
|
|
70
|
+
...rest
|
|
71
|
+
});
|
|
60
72
|
return (0, rolldown.defineConfig)({
|
|
61
73
|
input,
|
|
62
|
-
plugins
|
|
63
|
-
dir,
|
|
64
|
-
sourcemap,
|
|
65
|
-
...rest
|
|
66
|
-
}),
|
|
74
|
+
plugins,
|
|
67
75
|
external,
|
|
68
76
|
output,
|
|
69
77
|
platform: "node"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["buildInput","toArray","DEFAULT_EXCLUDE","PLUGIN_BUILDERS","esmExternalRequirePlugin","buildOutput","DEFAULT_CIRCULAR_DEPS"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_CIRCULAR_DEPS, DEFAULT_EXCLUDE } from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\n\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () => PLUGIN_BUILDERS.circulars({ exclude: circularDeps }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n clean: () => PLUGIN_BUILDERS.clean({ ignoresJS, sourcemap, dir }),\n fast: () => {\n return PLUGIN_BUILDERS.fast({\n include,\n exclude,\n declarationMap,\n dir,\n });\n },\n esm: esmExternalRequirePlugin,\n };\n\n const defaultOrdered = () => [\n unordered.circulars(),\n unordered.externals(),\n unordered.esm(),\n unordered.typescript(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({ dir, sourcemap, ...rest });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.fast = rest => {\n return defineConfig.default({\n ...rest,\n plugins: ['circulars', 'externals', 'esm', 'fast', 'clean'],\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["buildInput","toArray","DEFAULT_EXCLUDE","PLUGIN_BUILDERS","esmExternalRequirePlugin","buildOutput","_defineConfig","DEFAULT_CIRCULAR_DEPS"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_CIRCULAR_DEPS, DEFAULT_EXCLUDE } from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\n\n/**\n * Generates Rolldown configuration using default or customized options.\n *\n * @param additionals - Optional build configuration parameters of type {@linkcode Params}.\n *\n * @returns Configured Rolldown options of type {@linkcode RolldownOptions}.\n */\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () => PLUGIN_BUILDERS.circulars({ exclude: circularDeps }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n clean: () => PLUGIN_BUILDERS.clean({ ignoresJS, sourcemap, dir }),\n fast: () => {\n return PLUGIN_BUILDERS.fast({\n include,\n exclude,\n declarationMap,\n dir,\n });\n },\n esm: esmExternalRequirePlugin,\n };\n\n const defaultOrdered = () => [\n unordered.circulars(),\n unordered.externals(),\n unordered.esm(),\n unordered.typescript(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({ dir, sourcemap, ...rest });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.fast = rest => {\n return defineConfig.default({\n ...rest,\n plugins: ['circulars', 'externals', 'esm', 'fast', 'clean'],\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAyB,gBAAe;CACnD,OAAO,aAAa,QAAQ,WAAW;AACzC;AAEA,MAAM,kBAAkB,EACtB,cACA,WACA,KACA,YAAY,OACZ,YACA,gBACA,YACU,CAAC,MAAM;CACjB,MAAM,UAAUA,8BAAAA,WAAW,GAAGC,oBAAAA,QAAQ,UAAU,CAAC;CACjD,MAAM,UAAUC,kCAAAA,gBAAgB,OAAOD,oBAAAA,QAAQ,UAAU,CAAC;CAC1D,MAAM,YAAY;EAChB,kBACEE,sCAAAA,gBAAgB,WAAW;GACzB;GACA;GACA;GACA;EACF,CAAC;EACH,iBAAiBA,sCAAAA,gBAAgB,UAAU,EAAE,SAAS,aAAa,CAAC;EACpE,iBACEA,sCAAAA,gBAAgB,UAAU;GAExB,SAAS;GACT,gBAAgB;GAChB,SAAS;EACX,CAAC;EACH,aAAaA,sCAAAA,gBAAgB,MAAM;GAAE;GAAW;GAAW;EAAI,CAAC;EAChE,YAAY;GACV,OAAOA,sCAAAA,gBAAgB,KAAK;IAC1B;IACA;IACA;IACA;GACF,CAAC;EACH;EACA,KAAKC,iBAAAA;CACP;CAEA,MAAM,uBAAuB;EAC3B,UAAU,UAAU;EACpB,UAAU,UAAU;EACpB,UAAU,IAAI;EACd,UAAU,WAAW;EACrB,UAAU,MAAM;CAClB;CAEA,OAAO,UACH,QACG,KAAI,MAAK;EACR,IAAI,OAAO,MAAM,UAAU,OAAO,UAAU,EAAE,CAAC;EAC/C,OAAO;CACT,CAAC,CAAC,CACD,QAAO,MAAK,CAAC,CAAC,CAAC,IAClB,eAAe;AACrB;AAEA,aAAa,WAAW,EAAE,KAAK,YAAY,OAAO,GAAG,SAAS,CAAC,MAAM;CACnE,MAAM,QAAQJ,8BAAAA,WAAW;CACzB,MAAM,WAAW,KAAK;CACtB,MAAM,SAASK,+BAAAA,YAAY,KAAK,SAAS;CAEzC,MAAM,UAAU,eAAe;EAAE;EAAK;EAAW,GAAG;CAAK,CAAC;CAE1D,QAAA,GAAOC,SAAAA,aAAAA,CAAc;EACnB;EACA;EACA;EACA;EACA,UAAU;CACZ,CAAC;AACH;AAEA,aAAa,QAAO,SAAQ;CAC1B,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH,SAAS;GAAC;GAAa;GAAa;GAAO;GAAQ;EAAO;CAC5D,CAAC;AACH;AAEA,aAAa,WAAU,gBAAe;CAEpC,MAAM,eAAeC,kCAAAA,sBAAsB,OACzCN,oBAAAA,QAAQ,aAAa,YAAY,CACnC;CACA,MAAM,YAAYA,oBAAAA,QAAQ,aAAa,SAAS,CAAC,CAAC,OAChDM,kCAAAA,qBACF;CAEA,MAAM,aAAaL,kCAAAA,gBAAgB,OACjCD,oBAAAA,QAAQ,aAAa,UAAU,CACjC;CACA,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;CAG7D,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { Config_F } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Generates Rolldown configuration using default or customized options.
|
|
4
|
+
*
|
|
5
|
+
* @param additionals - Optional build configuration parameters of type {@linkcode Params}.
|
|
6
|
+
*
|
|
7
|
+
* @returns Configured Rolldown options of type {@linkcode RolldownOptions}.
|
|
8
|
+
*/
|
|
2
9
|
export declare const defineConfig: Config_F;
|
|
@@ -6,6 +6,13 @@ import { PLUGIN_BUILDERS } from "./plugins/index.js";
|
|
|
6
6
|
import { defineConfig as defineConfig$1 } from "rolldown";
|
|
7
7
|
import { esmExternalRequirePlugin } from "rolldown/plugins";
|
|
8
8
|
//#region src/rolldown-config/config.ts
|
|
9
|
+
/**
|
|
10
|
+
* Generates Rolldown configuration using default or customized options.
|
|
11
|
+
*
|
|
12
|
+
* @param additionals - Optional build configuration parameters of type {@linkcode Params}.
|
|
13
|
+
*
|
|
14
|
+
* @returns Configured Rolldown options of type {@linkcode RolldownOptions}.
|
|
15
|
+
*/
|
|
9
16
|
const defineConfig = (additionals) => {
|
|
10
17
|
return defineConfig.default(additionals);
|
|
11
18
|
};
|
|
@@ -56,13 +63,14 @@ defineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {
|
|
|
56
63
|
const input = buildInput();
|
|
57
64
|
const external = rest.externals;
|
|
58
65
|
const output = buildOutput(dir, sourcemap);
|
|
66
|
+
const plugins = producePlugins({
|
|
67
|
+
dir,
|
|
68
|
+
sourcemap,
|
|
69
|
+
...rest
|
|
70
|
+
});
|
|
59
71
|
return defineConfig$1({
|
|
60
72
|
input,
|
|
61
|
-
plugins
|
|
62
|
-
dir,
|
|
63
|
-
sourcemap,
|
|
64
|
-
...rest
|
|
65
|
-
}),
|
|
73
|
+
plugins,
|
|
66
74
|
external,
|
|
67
75
|
output,
|
|
68
76
|
platform: "node"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["_defineConfig"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_CIRCULAR_DEPS, DEFAULT_EXCLUDE } from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\n\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () => PLUGIN_BUILDERS.circulars({ exclude: circularDeps }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n clean: () => PLUGIN_BUILDERS.clean({ ignoresJS, sourcemap, dir }),\n fast: () => {\n return PLUGIN_BUILDERS.fast({\n include,\n exclude,\n declarationMap,\n dir,\n });\n },\n esm: esmExternalRequirePlugin,\n };\n\n const defaultOrdered = () => [\n unordered.circulars(),\n unordered.externals(),\n unordered.esm(),\n unordered.typescript(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({ dir, sourcemap, ...rest });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.fast = rest => {\n return defineConfig.default({\n ...rest,\n plugins: ['circulars', 'externals', 'esm', 'fast', 'clean'],\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","names":["_defineConfig"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_CIRCULAR_DEPS, DEFAULT_EXCLUDE } from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\n\n/**\n * Generates Rolldown configuration using default or customized options.\n *\n * @param additionals - Optional build configuration parameters of type {@linkcode Params}.\n *\n * @returns Configured Rolldown options of type {@linkcode RolldownOptions}.\n */\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () => PLUGIN_BUILDERS.circulars({ exclude: circularDeps }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n clean: () => PLUGIN_BUILDERS.clean({ ignoresJS, sourcemap, dir }),\n fast: () => {\n return PLUGIN_BUILDERS.fast({\n include,\n exclude,\n declarationMap,\n dir,\n });\n },\n esm: esmExternalRequirePlugin,\n };\n\n const defaultOrdered = () => [\n unordered.circulars(),\n unordered.externals(),\n unordered.esm(),\n unordered.typescript(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({ dir, sourcemap = false, ...rest } = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({ dir, sourcemap, ...rest });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.fast = rest => {\n return defineConfig.default({\n ...rest,\n plugins: ['circulars', 'externals', 'esm', 'fast', 'clean'],\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,gBAAyB,gBAAe;CACnD,OAAO,aAAa,QAAQ,WAAW;AACzC;AAEA,MAAM,kBAAkB,EACtB,cACA,WACA,KACA,YAAY,OACZ,YACA,gBACA,YACU,CAAC,MAAM;CACjB,MAAM,UAAU,WAAW,GAAG,QAAQ,UAAU,CAAC;CACjD,MAAM,UAAU,gBAAgB,OAAO,QAAQ,UAAU,CAAC;CAC1D,MAAM,YAAY;EAChB,kBACE,gBAAgB,WAAW;GACzB;GACA;GACA;GACA;EACF,CAAC;EACH,iBAAiB,gBAAgB,UAAU,EAAE,SAAS,aAAa,CAAC;EACpE,iBACE,gBAAgB,UAAU;GAExB,SAAS;GACT,gBAAgB;GAChB,SAAS;EACX,CAAC;EACH,aAAa,gBAAgB,MAAM;GAAE;GAAW;GAAW;EAAI,CAAC;EAChE,YAAY;GACV,OAAO,gBAAgB,KAAK;IAC1B;IACA;IACA;IACA;GACF,CAAC;EACH;EACA,KAAK;CACP;CAEA,MAAM,uBAAuB;EAC3B,UAAU,UAAU;EACpB,UAAU,UAAU;EACpB,UAAU,IAAI;EACd,UAAU,WAAW;EACrB,UAAU,MAAM;CAClB;CAEA,OAAO,UACH,QACG,KAAI,MAAK;EACR,IAAI,OAAO,MAAM,UAAU,OAAO,UAAU,EAAE,CAAC;EAC/C,OAAO;CACT,CAAC,CAAC,CACD,QAAO,MAAK,CAAC,CAAC,CAAC,IAClB,eAAe;AACrB;AAEA,aAAa,WAAW,EAAE,KAAK,YAAY,OAAO,GAAG,SAAS,CAAC,MAAM;CACnE,MAAM,QAAQ,WAAW;CACzB,MAAM,WAAW,KAAK;CACtB,MAAM,SAAS,YAAY,KAAK,SAAS;CAEzC,MAAM,UAAU,eAAe;EAAE;EAAK;EAAW,GAAG;CAAK,CAAC;CAE1D,OAAOA,eAAc;EACnB;EACA;EACA;EACA;EACA,UAAU;CACZ,CAAC;AACH;AAEA,aAAa,QAAO,SAAQ;CAC1B,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH,SAAS;GAAC;GAAa;GAAa;GAAO;GAAQ;EAAO;CAC5D,CAAC;AACH;AAEA,aAAa,WAAU,gBAAe;CAEpC,MAAM,eAAe,sBAAsB,OACzC,QAAQ,aAAa,YAAY,CACnC;CACA,MAAM,YAAY,QAAQ,aAAa,SAAS,CAAC,CAAC,OAChD,qBACF;CAEA,MAAM,aAAa,gBAAgB,OACjC,QAAQ,aAAa,UAAU,CACjC;CACA,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;CAG7D,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/rolldown-config/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* Default exclude glob patterns for bundling and type generation.
|
|
5
|
+
*/
|
|
3
6
|
const DEFAULT_EXCLUDE = [
|
|
4
7
|
"**/node_modules/**/*",
|
|
5
8
|
"**/__tests__/**/*",
|
|
@@ -9,14 +12,26 @@ const DEFAULT_EXCLUDE = [
|
|
|
9
12
|
"**/fixtures.ts",
|
|
10
13
|
"src/fixtures/**/*.ts"
|
|
11
14
|
];
|
|
15
|
+
/**
|
|
16
|
+
* Default patterns for type files that may contain circular references.
|
|
17
|
+
*/
|
|
12
18
|
const DEFAULT_CIRCULAR_DEPS = [
|
|
13
19
|
"**/types.ts",
|
|
14
20
|
"**/type.ts",
|
|
15
21
|
"**/*.types.ts",
|
|
16
22
|
"**/*.type.ts"
|
|
17
23
|
];
|
|
24
|
+
/**
|
|
25
|
+
* Combined default exclusions and circular dependency file patterns.
|
|
26
|
+
*/
|
|
18
27
|
const IGNORE = DEFAULT_EXCLUDE.concat(DEFAULT_CIRCULAR_DEPS);
|
|
28
|
+
/**
|
|
29
|
+
* Default output directory name.
|
|
30
|
+
*/
|
|
19
31
|
const DEFAULT_DIR = "lib";
|
|
32
|
+
/**
|
|
33
|
+
* Rolldown log warning codes.
|
|
34
|
+
*/
|
|
20
35
|
const WARNING_CODES = {
|
|
21
36
|
EMPTY_BUNDLE: "EMPTY_BUNDLE",
|
|
22
37
|
CIRCULAR_DEPENDENCY: "CIRCULAR_DEPENDENCY"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/rolldown-config/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/rolldown-config/constants.ts"],"sourcesContent":["/**\n * Default exclude glob patterns for bundling and type generation.\n */\nexport const DEFAULT_EXCLUDE = [\n '**/node_modules/**/*',\n '**/__tests__/**/*',\n '**/*.test.ts',\n '**/*.test-d.ts',\n '**/*.fixtures.ts',\n '**/fixtures.ts',\n 'src/fixtures/**/*.ts',\n];\n\n/**\n * Default patterns for type files that may contain circular references.\n */\nexport const DEFAULT_CIRCULAR_DEPS = [\n '**/types.ts',\n '**/type.ts',\n '**/*.types.ts',\n '**/*.type.ts',\n];\n\n/**\n * Combined default exclusions and circular dependency file patterns.\n */\nexport const IGNORE = DEFAULT_EXCLUDE.concat(DEFAULT_CIRCULAR_DEPS);\n\n/**\n * Default output directory name.\n */\nexport const DEFAULT_DIR = 'lib';\n\n/**\n * Rolldown log warning codes.\n */\nexport const WARNING_CODES = {\n EMPTY_BUNDLE: 'EMPTY_BUNDLE',\n CIRCULAR_DEPENDENCY: 'CIRCULAR_DEPENDENCY',\n};\n"],"mappings":";;;;;AAGA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,SAAS,gBAAgB,OAAO,qBAAqB;;;;AAKlE,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;CAC3B,cAAc;CACd,qBAAqB;AACvB"}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default exclude glob patterns for bundling and type generation.
|
|
3
|
+
*/
|
|
1
4
|
export declare const DEFAULT_EXCLUDE: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Default patterns for type files that may contain circular references.
|
|
7
|
+
*/
|
|
2
8
|
export declare const DEFAULT_CIRCULAR_DEPS: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Combined default exclusions and circular dependency file patterns.
|
|
11
|
+
*/
|
|
3
12
|
export declare const IGNORE: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Default output directory name.
|
|
15
|
+
*/
|
|
4
16
|
export declare const DEFAULT_DIR = "lib";
|
|
17
|
+
/**
|
|
18
|
+
* Rolldown log warning codes.
|
|
19
|
+
*/
|
|
5
20
|
export declare const WARNING_CODES: {
|
|
6
21
|
EMPTY_BUNDLE: string;
|
|
7
22
|
CIRCULAR_DEPENDENCY: string;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
//#region src/rolldown-config/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default exclude glob patterns for bundling and type generation.
|
|
4
|
+
*/
|
|
2
5
|
const DEFAULT_EXCLUDE = [
|
|
3
6
|
"**/node_modules/**/*",
|
|
4
7
|
"**/__tests__/**/*",
|
|
@@ -8,14 +11,26 @@ const DEFAULT_EXCLUDE = [
|
|
|
8
11
|
"**/fixtures.ts",
|
|
9
12
|
"src/fixtures/**/*.ts"
|
|
10
13
|
];
|
|
14
|
+
/**
|
|
15
|
+
* Default patterns for type files that may contain circular references.
|
|
16
|
+
*/
|
|
11
17
|
const DEFAULT_CIRCULAR_DEPS = [
|
|
12
18
|
"**/types.ts",
|
|
13
19
|
"**/type.ts",
|
|
14
20
|
"**/*.types.ts",
|
|
15
21
|
"**/*.type.ts"
|
|
16
22
|
];
|
|
23
|
+
/**
|
|
24
|
+
* Combined default exclusions and circular dependency file patterns.
|
|
25
|
+
*/
|
|
17
26
|
const IGNORE = DEFAULT_EXCLUDE.concat(DEFAULT_CIRCULAR_DEPS);
|
|
27
|
+
/**
|
|
28
|
+
* Default output directory name.
|
|
29
|
+
*/
|
|
18
30
|
const DEFAULT_DIR = "lib";
|
|
31
|
+
/**
|
|
32
|
+
* Rolldown log warning codes.
|
|
33
|
+
*/
|
|
19
34
|
const WARNING_CODES = {
|
|
20
35
|
EMPTY_BUNDLE: "EMPTY_BUNDLE",
|
|
21
36
|
CIRCULAR_DEPENDENCY: "CIRCULAR_DEPENDENCY"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../src/rolldown-config/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/rolldown-config/constants.ts"],"sourcesContent":["/**\n * Default exclude glob patterns for bundling and type generation.\n */\nexport const DEFAULT_EXCLUDE = [\n '**/node_modules/**/*',\n '**/__tests__/**/*',\n '**/*.test.ts',\n '**/*.test-d.ts',\n '**/*.fixtures.ts',\n '**/fixtures.ts',\n 'src/fixtures/**/*.ts',\n];\n\n/**\n * Default patterns for type files that may contain circular references.\n */\nexport const DEFAULT_CIRCULAR_DEPS = [\n '**/types.ts',\n '**/type.ts',\n '**/*.types.ts',\n '**/*.type.ts',\n];\n\n/**\n * Combined default exclusions and circular dependency file patterns.\n */\nexport const IGNORE = DEFAULT_EXCLUDE.concat(DEFAULT_CIRCULAR_DEPS);\n\n/**\n * Default output directory name.\n */\nexport const DEFAULT_DIR = 'lib';\n\n/**\n * Rolldown log warning codes.\n */\nexport const WARNING_CODES = {\n EMPTY_BUNDLE: 'EMPTY_BUNDLE',\n CIRCULAR_DEPENDENCY: 'CIRCULAR_DEPENDENCY',\n};\n"],"mappings":";;;;AAGA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,SAAS,gBAAgB,OAAO,qBAAqB;;;;AAKlE,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;CAC3B,cAAc;CACd,qBAAqB;AACvB"}
|
|
@@ -2,12 +2,27 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let fs = require("fs");
|
|
3
3
|
let path = require("path");
|
|
4
4
|
//#region src/rolldown-config/helpers.ts
|
|
5
|
+
/**
|
|
6
|
+
* Strips the extension from a file path.
|
|
7
|
+
*
|
|
8
|
+
* @param file - File path string.
|
|
9
|
+
*
|
|
10
|
+
* @returns File path without file extension.
|
|
11
|
+
*/
|
|
5
12
|
const withoutExtension = (file) => {
|
|
6
13
|
return file.slice(0, file.length - (0, path.extname)(file).length);
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Removes compiled JavaScript and sourcemap files for specified sources.
|
|
17
|
+
*
|
|
18
|
+
* @param files - Set of source file paths.
|
|
19
|
+
* @param dir - Target output directory.
|
|
20
|
+
* @param sourcemap - Whether sourcemap files should also be deleted.
|
|
21
|
+
*/
|
|
8
22
|
const cleanupJS = (files, dir, sourcemap) => {
|
|
9
23
|
for (const file of files) {
|
|
10
|
-
const
|
|
24
|
+
const withoutExt = withoutExtension(file);
|
|
25
|
+
const rel = (0, path.relative)("src", withoutExt);
|
|
11
26
|
const baseOut = (0, path.resolve)(process.cwd(), dir, rel);
|
|
12
27
|
console.warn(`Cleaning up ${baseOut}`);
|
|
13
28
|
(0, fs.rmSync)(`${baseOut}.js`, { force: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":[],"sources":["../../src/rolldown-config/helpers.ts"],"sourcesContent":["import { rmSync } from 'node:fs';\nimport { extname, relative, resolve } from 'node:path';\n\nexport const withoutExtension = (file: string) => {\n return file.slice(0, file.length - extname(file).length);\n};\n\nexport const cleanupJS = (\n files: Set<string>,\n dir: string,\n sourcemap: boolean,\n) => {\n for (const file of files) {\n const withoutExt = withoutExtension(file);\n const rel = relative('src', withoutExt);\n const baseOut = resolve(process.cwd(), dir, rel);\n\n // #region JS outputs\n console.warn(`Cleaning up ${baseOut}`);\n\n rmSync(`${baseOut}.js`, { force: true });\n rmSync(`${baseOut}.cjs`, { force: true });\n if (sourcemap) {\n rmSync(`${baseOut}.js.map`, { force: true });\n rmSync(`${baseOut}.cjs.map`, { force: true });\n }\n\n const REMOVEDS = ['js', 'cjs', 'js.map', 'cjs.map'].map(\n ext => `${baseOut}.${ext}`,\n );\n\n const endMessage = JSON.stringify(REMOVEDS, null, 2);\n\n console.warn('removeds ::');\n console.log('***********');\n console.warn(endMessage);\n console.log('***********');\n // #endregion\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.cjs","names":["extname","relative","resolve"],"sources":["../../src/rolldown-config/helpers.ts"],"sourcesContent":["import { rmSync } from 'node:fs';\nimport { extname, relative, resolve } from 'node:path';\n\n/**\n * Strips the extension from a file path.\n *\n * @param file - File path string.\n *\n * @returns File path without file extension.\n */\nexport const withoutExtension = (file: string) => {\n return file.slice(0, file.length - extname(file).length);\n};\n\n/**\n * Removes compiled JavaScript and sourcemap files for specified sources.\n *\n * @param files - Set of source file paths.\n * @param dir - Target output directory.\n * @param sourcemap - Whether sourcemap files should also be deleted.\n */\nexport const cleanupJS = (\n files: Set<string>,\n dir: string,\n sourcemap: boolean,\n) => {\n for (const file of files) {\n const withoutExt = withoutExtension(file);\n const rel = relative('src', withoutExt);\n const baseOut = resolve(process.cwd(), dir, rel);\n\n // #region JS outputs\n console.warn(`Cleaning up ${baseOut}`);\n\n rmSync(`${baseOut}.js`, { force: true });\n rmSync(`${baseOut}.cjs`, { force: true });\n if (sourcemap) {\n rmSync(`${baseOut}.js.map`, { force: true });\n rmSync(`${baseOut}.cjs.map`, { force: true });\n }\n\n const REMOVEDS = ['js', 'cjs', 'js.map', 'cjs.map'].map(\n ext => `${baseOut}.${ext}`,\n );\n\n const endMessage = JSON.stringify(REMOVEDS, null, 2);\n\n console.warn('removeds ::');\n console.log('***********');\n console.warn(endMessage);\n console.log('***********');\n // #endregion\n }\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,oBAAoB,SAAiB;CAChD,OAAO,KAAK,MAAM,GAAG,KAAK,UAAA,GAASA,KAAAA,QAAAA,CAAQ,IAAI,CAAC,CAAC,MAAM;AACzD;;;;;;;;AASA,MAAa,aACX,OACA,KACA,cACG;CACH,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,aAAa,iBAAiB,IAAI;EACxC,MAAM,OAAA,GAAMC,KAAAA,SAAAA,CAAS,OAAO,UAAU;EACtC,MAAM,WAAA,GAAUC,KAAAA,QAAAA,CAAQ,QAAQ,IAAI,GAAG,KAAK,GAAG;EAG/C,QAAQ,KAAK,eAAe,SAAS;EAErC,CAAA,GAAA,GAAA,OAAA,CAAO,GAAG,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC;EACvC,CAAA,GAAA,GAAA,OAAA,CAAO,GAAG,QAAQ,OAAO,EAAE,OAAO,KAAK,CAAC;EACxC,IAAI,WAAW;GACb,CAAA,GAAA,GAAA,OAAA,CAAO,GAAG,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC;GAC3C,CAAA,GAAA,GAAA,OAAA,CAAO,GAAG,QAAQ,WAAW,EAAE,OAAO,KAAK,CAAC;EAC9C;EAEA,MAAM,WAAW;GAAC;GAAM;GAAO;GAAU;EAAS,CAAC,CAAC,KAClD,QAAO,GAAG,QAAQ,GAAG,KACvB;EAEA,MAAM,aAAa,KAAK,UAAU,UAAU,MAAM,CAAC;EAEnD,QAAQ,KAAK,aAAa;EAC1B,QAAQ,IAAI,aAAa;EACzB,QAAQ,KAAK,UAAU;EACvB,QAAQ,IAAI,aAAa;CAE3B;AACF"}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips the extension from a file path.
|
|
3
|
+
*
|
|
4
|
+
* @param file - File path string.
|
|
5
|
+
*
|
|
6
|
+
* @returns File path without file extension.
|
|
7
|
+
*/
|
|
1
8
|
export declare const withoutExtension: (file: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Removes compiled JavaScript and sourcemap files for specified sources.
|
|
11
|
+
*
|
|
12
|
+
* @param files - Set of source file paths.
|
|
13
|
+
* @param dir - Target output directory.
|
|
14
|
+
* @param sourcemap - Whether sourcemap files should also be deleted.
|
|
15
|
+
*/
|
|
2
16
|
export declare const cleanupJS: (files: Set<string>, dir: string, sourcemap: boolean) => void;
|