@bemedev/dev-utils 1.3.0 → 1.4.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 +62 -83
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/plugins/hmr.cjs +14 -26
- package/lib/plugins/hmr.cjs.map +1 -1
- package/lib/plugins/hmr.d.ts +5 -15
- package/lib/plugins/hmr.js +14 -26
- package/lib/plugins/hmr.js.map +1 -1
- package/lib/plugins/suppressWarnings.cjs.map +1 -1
- package/lib/plugins/suppressWarnings.js.map +1 -1
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/package.json +1 -1
package/lib/plugins/hmr.js
CHANGED
|
@@ -3,54 +3,42 @@ import { toArray } from "../utils/array.js";
|
|
|
3
3
|
import { isAbsolute, resolve } from "path";
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
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
6
|
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
7
|
const hmr = (props) => {
|
|
23
8
|
let isBuilding = false;
|
|
24
9
|
const debounce = clamp(props?.debounce ?? 500, 500, 1e4);
|
|
25
|
-
const
|
|
10
|
+
const pathMap = /* @__PURE__ */ new Map();
|
|
26
11
|
let isDev = false;
|
|
27
12
|
return {
|
|
28
13
|
name: "hmr-add-on",
|
|
29
14
|
configResolved(config) {
|
|
30
15
|
isDev = !config.isProduction;
|
|
31
16
|
if (!isDev) return;
|
|
32
|
-
|
|
33
|
-
paths
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
pathMap.clear();
|
|
18
|
+
const rawPaths = props?.paths ?? {};
|
|
19
|
+
Object.entries(rawPaths).forEach(([pathKey, rawScripts]) => {
|
|
20
|
+
const resolved = isAbsolute(pathKey) ? pathKey : resolve(config.root, pathKey);
|
|
21
|
+
const normalized = normalizePath(resolved);
|
|
22
|
+
const scripts = toArray(rawScripts);
|
|
23
|
+
pathMap.set(normalized, scripts);
|
|
24
|
+
});
|
|
37
25
|
},
|
|
38
26
|
configureServer(server) {
|
|
39
27
|
if (!isDev) return;
|
|
40
|
-
server.watcher.add(
|
|
28
|
+
server.watcher.add(Array.from(pathMap.keys()));
|
|
41
29
|
},
|
|
42
30
|
handleHotUpdate(ctx) {
|
|
43
31
|
if (!isDev) return;
|
|
44
32
|
if (isBuilding) return ctx.modules;
|
|
45
33
|
const normalizedFile = normalizePath(ctx.file);
|
|
46
|
-
|
|
34
|
+
const matchingScripts = /* @__PURE__ */ new Set();
|
|
35
|
+
for (const [watchedPath, scripts] of pathMap.entries()) if (normalizedFile.includes(watchedPath)) scripts.forEach(matchingScripts.add);
|
|
36
|
+
if (matchingScripts.size > 0) {
|
|
47
37
|
console.log(`\n⚡ External file modified: ${ctx.file}. Starting build...`);
|
|
48
38
|
try {
|
|
49
39
|
isBuilding = true;
|
|
50
|
-
toArray(props?.scripts).forEach((script) => {
|
|
51
|
-
execSync(script, { stdio: "inherit" });
|
|
52
|
-
});
|
|
53
40
|
ctx.server.moduleGraph.invalidateAll();
|
|
41
|
+
matchingScripts.forEach((script) => execSync(script, { stdio: "inherit" }));
|
|
54
42
|
ctx.server.ws.send({ type: "full-reload" });
|
|
55
43
|
} catch (error) {
|
|
56
44
|
console.error("❌ Command execution failed during HMR:", error);
|
package/lib/plugins/hmr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr.js","names":[],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport {
|
|
1
|
+
{"version":3,"file":"hmr.js","names":[],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { isAbsolute, resolve } 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\nexport type HmrPluginProps = {\n /**\n * Map of watched file/directory paths to one or many shell commands to execute\n * when changes are detected.\n */\n paths?: Record<string, SoA<string>>;\n\n /** Optional interval in milliseconds to wait before allowing another build. */\n debounce?: number;\n};\n\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\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 pathMap = new Map<string, 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 pathMap.clear();\n const rawPaths = props?.paths ?? {};\n\n Object.entries(rawPaths).forEach(([pathKey, rawScripts]) => {\n const resolved = isAbsolute(pathKey)\n ? pathKey\n : resolve(config.root, pathKey);\n\n const normalized = normalizePath(resolved);\n const scripts = toArray(rawScripts);\n pathMap.set(normalized, scripts);\n });\n },\n\n configureServer(server) {\n if (!isDev) return;\n\n server.watcher.add(Array.from(pathMap.keys()));\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\n // Find all matching path entries for the changed file\n const matchingScripts = new Set<string>();\n for (const [watchedPath, scripts] of pathMap.entries()) {\n if (normalizedFile.includes(watchedPath)) {\n scripts.forEach(matchingScripts.add);\n }\n }\n\n if (matchingScripts.size > 0) {\n console.log(`\\n⚡ External file modified: ${ctx.file}. Starting build...`);\n\n try {\n // 2. Acquire lock before starting the build\n isBuilding = true;\n\n // Invalidate module graph so Vite reads fresh built files from disk\n ctx.server.moduleGraph.invalidateAll();\n matchingScripts.forEach(script => execSync(script, { stdio: 'inherit' }));\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('✅ Build completed. Ready for subsequent changes.');\n }, debounce);\n }\n }\n\n return ctx.modules;\n },\n };\n};\n"],"mappings":";;;;;AAoBA,MAAM,iBAAiB,SAAiB,KAAK,QAAQ,OAAO,GAAG;AAE/D,MAAa,OAAO,UAAmC;CAErD,IAAI,aAAa;CACjB,MAAM,WAAW,MAAM,OAAO,YAAY,KAAK,KAAK,GAAM;CAC1D,MAAM,0BAAU,IAAI,IAAsB;CAC1C,IAAI,QAAQ;CAEZ,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,QAAQ,CAAC,OAAO;GAChB,IAAI,CAAC,OAAO;GAEZ,QAAQ,MAAM;GACd,MAAM,WAAW,OAAO,SAAS,CAAC;GAElC,OAAO,QAAQ,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,gBAAgB;IAC1D,MAAM,WAAW,WAAW,OAAO,IAC/B,UACA,QAAQ,OAAO,MAAM,OAAO;IAEhC,MAAM,aAAa,cAAc,QAAQ;IACzC,MAAM,UAAU,QAAQ,UAAU;IAClC,QAAQ,IAAI,YAAY,OAAO;GACjC,CAAC;EACH;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,OAAO;GAEZ,OAAO,QAAQ,IAAI,MAAM,KAAK,QAAQ,KAAK,CAAC,CAAC;EAC/C;EAEA,gBAAgB,KAAK;GACnB,IAAI,CAAC,OAAO;GAGZ,IAAI,YAAY,OAAO,IAAI;GAC3B,MAAM,iBAAiB,cAAc,IAAI,IAAI;GAG7C,MAAM,kCAAkB,IAAI,IAAY;GACxC,KAAK,MAAM,CAAC,aAAa,YAAY,QAAQ,QAAQ,GACnD,IAAI,eAAe,SAAS,WAAW,GACrC,QAAQ,QAAQ,gBAAgB,GAAG;GAIvC,IAAI,gBAAgB,OAAO,GAAG;IAC5B,QAAQ,IAAI,+BAA+B,IAAI,KAAK,oBAAoB;IAExE,IAAI;KAEF,aAAa;KAGb,IAAI,OAAO,YAAY,cAAc;KACrC,gBAAgB,SAAQ,WAAU,SAAS,QAAQ,EAAE,OAAO,UAAU,CAAC,CAAC;KACxE,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,IAAI,kDAAkD;KAChE,GAAG,QAAQ;IACb;GACF;GAEA,OAAO,IAAI;EACb;CACF;AACF"}
|
|
@@ -1 +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(
|
|
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(...patterns: Array<string | RegExp>): Plugin {\n let isInitialized = false;\n\n const shouldSuppress = (chunk: unknown): boolean => {\n const str =\n typeof chunk === 'string' ? chunk : (chunk as any)?.toString?.() || '';\n return patterns.some(pattern =>\n typeof pattern === 'string' ? str.includes(pattern) : 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,iBAAiB,GAAG,UAA0C;CAC5E,IAAI,gBAAgB;CAEpB,MAAM,kBAAkB,UAA4B;EAClD,MAAM,MACJ,OAAO,UAAU,WAAW,QAAS,OAAe,WAAW,KAAK;EACtE,OAAO,SAAS,MAAK,YACnB,OAAO,YAAY,WAAW,IAAI,SAAS,OAAO,IAAI,QAAQ,KAAK,GAAG,CACxE;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"}
|
|
@@ -1 +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(
|
|
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(...patterns: Array<string | RegExp>): Plugin {\n let isInitialized = false;\n\n const shouldSuppress = (chunk: unknown): boolean => {\n const str =\n typeof chunk === 'string' ? chunk : (chunk as any)?.toString?.() || '';\n return patterns.some(pattern =>\n typeof pattern === 'string' ? str.includes(pattern) : 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,iBAAiB,GAAG,UAA0C;CAC5E,IAAI,gBAAgB;CAEpB,MAAM,kBAAkB,UAA4B;EAClD,MAAM,MACJ,OAAO,UAAU,WAAW,QAAS,OAAe,WAAW,KAAK;EACtE,OAAO,SAAS,MAAK,YACnB,OAAO,YAAY,WAAW,IAAI,SAAS,OAAO,IAAI,QAAQ,KAAK,GAAG,CACxE;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"}
|
|
@@ -1 +1 @@
|
|
|
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({
|
|
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({ include, exclude, declarationMap, dir }),\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({ include, exclude, declarationMap, dir });\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({ input, plugins, external, output, platform: 'node' });\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(DEFAULT_CIRCULAR_DEPS);\n\n const excludesTS = DEFAULT_EXCLUDE.concat(toArray(additionals?.excludesTS));\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;GAAE;GAAS;GAAS;GAAgB;EAAI,CAAC;EACtE,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;IAAE;IAAS;IAAS;IAAgB;GAAI,CAAC;EACvE;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;EAAE;EAAO;EAAS;EAAU;EAAQ,UAAU;CAAO,CAAC;AAC7E;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,OAAOM,kCAAAA,qBAAqB;CAE9E,MAAM,aAAaL,kCAAAA,gBAAgB,OAAOD,oBAAAA,QAAQ,aAAa,UAAU,CAAC;CAC1E,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;CAG7D,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -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\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({
|
|
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({ include, exclude, declarationMap, dir }),\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({ include, exclude, declarationMap, dir });\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({ input, plugins, external, output, platform: 'node' });\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(DEFAULT_CIRCULAR_DEPS);\n\n const excludesTS = DEFAULT_EXCLUDE.concat(toArray(additionals?.excludesTS));\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;GAAE;GAAS;GAAS;GAAgB;EAAI,CAAC;EACtE,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;IAAE;IAAS;IAAS;IAAgB;GAAI,CAAC;EACvE;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;EAAE;EAAO;EAAS;EAAU;EAAQ,UAAU;CAAO,CAAC;AAC7E;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,OAAO,qBAAqB;CAE9E,MAAM,aAAa,gBAAgB,OAAO,QAAQ,aAAa,UAAU,CAAC;CAC1E,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;CAG7D,OAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
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 = (
|
|
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 = (files: Set<string>, dir: string, sourcemap: boolean) => {\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,aAAa,OAAoB,KAAa,cAAuB;CAChF,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"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 = (
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"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 = (files: Set<string>, dir: string, sourcemap: boolean) => {\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,SAAS,QAAQ,IAAI,CAAC,CAAC,MAAM;AACzD;;;;;;;;AASA,MAAa,aAAa,OAAoB,KAAa,cAAuB;CAChF,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,aAAa,iBAAiB,IAAI;EACxC,MAAM,MAAM,SAAS,OAAO,UAAU;EACtC,MAAM,UAAU,QAAQ,QAAQ,IAAI,GAAG,KAAK,GAAG;EAG/C,QAAQ,KAAK,eAAe,SAAS;EAErC,OAAO,GAAG,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC;EACvC,OAAO,GAAG,QAAQ,OAAO,EAAE,OAAO,KAAK,CAAC;EACxC,IAAI,WAAW;GACb,OAAO,GAAG,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC;GAC3C,OAAO,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.cjs","names":["globSync","DEFAULT_EXCLUDE","relative","extname"],"sources":["../../src/rolldown-config/input.ts"],"sourcesContent":["import { extname, relative } from 'node:path';\n\nimport { globSync } from 'glob';\n\nimport { DEFAULT_EXCLUDE } from './constants';\nimport type { BuildInput_F } from './types';\n\n/**\n * Builds entry points record for Rolldown from all\n * `src/[**]/*.ts]` files.\n *\n * @param ignores - Additional glob patterns to exclude from entry points.\n *\n * @returns An object mapping relative module names to absolute source paths.\n */\nexport const buildInput: BuildInput_F = (...ignores) =>\n Object.fromEntries(\n globSync('src/**/*.ts', {
|
|
1
|
+
{"version":3,"file":"input.cjs","names":["globSync","DEFAULT_EXCLUDE","relative","extname"],"sources":["../../src/rolldown-config/input.ts"],"sourcesContent":["import { extname, relative } from 'node:path';\n\nimport { globSync } from 'glob';\n\nimport { DEFAULT_EXCLUDE } from './constants';\nimport type { BuildInput_F } from './types';\n\n/**\n * Builds entry points record for Rolldown from all\n * `src/[**]/*.ts]` files.\n *\n * @param ignores - Additional glob patterns to exclude from entry points.\n *\n * @returns An object mapping relative module names to absolute source paths.\n */\nexport const buildInput: BuildInput_F = (...ignores) =>\n Object.fromEntries(\n globSync('src/**/*.ts', { ignore: DEFAULT_EXCLUDE.concat(ignores) }).map(\n file => {\n const key = relative(\n 'src',\n file.slice(0, file.length - extname(file).length),\n );\n const value = `${process.cwd()}/${file}`;\n\n return [key, value];\n },\n ),\n );\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,cAA4B,GAAG,YAC1C,OAAO,aAAA,GACLA,KAAAA,SAAAA,CAAS,eAAe,EAAE,QAAQC,kCAAAA,gBAAgB,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,KACnE,SAAQ;CAON,OAAO,EAAA,GANKC,KAAAA,SAAAA,CACV,OACA,KAAK,MAAM,GAAG,KAAK,UAAA,GAASC,KAAAA,QAAAA,CAAQ,IAAI,CAAC,CAAC,MAAM,CAIxC,GAAG,GAFI,QAAQ,IAAI,EAAE,GAAG,MAEhB;AACpB,CACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":[],"sources":["../../src/rolldown-config/input.ts"],"sourcesContent":["import { extname, relative } from 'node:path';\n\nimport { globSync } from 'glob';\n\nimport { DEFAULT_EXCLUDE } from './constants';\nimport type { BuildInput_F } from './types';\n\n/**\n * Builds entry points record for Rolldown from all\n * `src/[**]/*.ts]` files.\n *\n * @param ignores - Additional glob patterns to exclude from entry points.\n *\n * @returns An object mapping relative module names to absolute source paths.\n */\nexport const buildInput: BuildInput_F = (...ignores) =>\n Object.fromEntries(\n globSync('src/**/*.ts', {
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../src/rolldown-config/input.ts"],"sourcesContent":["import { extname, relative } from 'node:path';\n\nimport { globSync } from 'glob';\n\nimport { DEFAULT_EXCLUDE } from './constants';\nimport type { BuildInput_F } from './types';\n\n/**\n * Builds entry points record for Rolldown from all\n * `src/[**]/*.ts]` files.\n *\n * @param ignores - Additional glob patterns to exclude from entry points.\n *\n * @returns An object mapping relative module names to absolute source paths.\n */\nexport const buildInput: BuildInput_F = (...ignores) =>\n Object.fromEntries(\n globSync('src/**/*.ts', { ignore: DEFAULT_EXCLUDE.concat(ignores) }).map(\n file => {\n const key = relative(\n 'src',\n file.slice(0, file.length - extname(file).length),\n );\n const value = `${process.cwd()}/${file}`;\n\n return [key, value];\n },\n ),\n );\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,cAA4B,GAAG,YAC1C,OAAO,YACL,SAAS,eAAe,EAAE,QAAQ,gBAAgB,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,KACnE,SAAQ;CAON,OAAO,CANK,SACV,OACA,KAAK,MAAM,GAAG,KAAK,SAAS,QAAQ,IAAI,CAAC,CAAC,MAAM,CAIxC,GAAG,GAFI,QAAQ,IAAI,EAAE,GAAG,MAEhB;AACpB,CACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circulars.cjs","names":["circularDependencies","toArray","globSync","withoutExtension","relative","WARNING_CODES"],"sources":["../../../src/rolldown-config/plugins/circulars.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { circularDependencies } from 'rollup-plugin-circular-dependencies';\n\nimport { toArray, type SoA } from '#utils';\n\nimport { WARNING_CODES } from '../constants';\nimport { withoutExtension } from '../helpers';\n\n/**\n * Options for the circular dependencies plugin.\n */\nexport type CircularDependenciesOptions = Omit<\n Parameters<typeof circularDependencies>[0],\n 'exclude'\n> & { exclude?: SoA<string> };\n\n/**\n * Creates a configured circular dependencies plugin instance with suppression for known patterns.\n *\n * @param options - Configuration options of type {@linkcode CircularDependenciesOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function circulars(\n options: CircularDependenciesOptions = {},\n): RolldownPluginOption {\n const all = circularDependencies(options);\n const exclude = toArray(options.exclude);\n\n const CIRCULAR_CHUNKS = exclude\n .filter(Boolean)\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n return {\n ...all,\n name: 'better circular-dependencies',\n onLog: {\n handler: (_, { code, names }) => {\n if (\n code === WARNING_CODES.CIRCULAR_DEPENDENCY &&\n names?.every(name => CIRCULAR_CHUNKS.includes(name))\n ) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log(
|
|
1
|
+
{"version":3,"file":"circulars.cjs","names":["circularDependencies","toArray","globSync","withoutExtension","relative","WARNING_CODES"],"sources":["../../../src/rolldown-config/plugins/circulars.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { circularDependencies } from 'rollup-plugin-circular-dependencies';\n\nimport { toArray, type SoA } from '#utils';\n\nimport { WARNING_CODES } from '../constants';\nimport { withoutExtension } from '../helpers';\n\n/**\n * Options for the circular dependencies plugin.\n */\nexport type CircularDependenciesOptions = Omit<\n Parameters<typeof circularDependencies>[0],\n 'exclude'\n> & { exclude?: SoA<string> };\n\n/**\n * Creates a configured circular dependencies plugin instance with suppression for known patterns.\n *\n * @param options - Configuration options of type {@linkcode CircularDependenciesOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function circulars(\n options: CircularDependenciesOptions = {},\n): RolldownPluginOption {\n const all = circularDependencies(options);\n const exclude = toArray(options.exclude);\n\n const CIRCULAR_CHUNKS = exclude\n .filter(Boolean)\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n return {\n ...all,\n name: 'better circular-dependencies',\n onLog: {\n handler: (_, { code, names }) => {\n if (\n code === WARNING_CODES.CIRCULAR_DEPENDENCY &&\n names?.every(name => CIRCULAR_CHUNKS.includes(name))\n ) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[bemedev] Skipping circular dependency warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n console.log();\n return false;\n }\n\n return;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,UACd,UAAuC,CAAC,GAClB;CACtB,MAAM,OAAA,GAAMA,oCAAAA,qBAAAA,CAAqB,OAAO;CAGxC,MAAM,kBAFUC,oBAAAA,QAAQ,QAAQ,OAEF,CAAC,CAC5B,OAAO,OAAO,CAAC,CACf,KAAI,OAAA,GAAKC,KAAAA,SAAAA,CAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAIC,gCAAAA,gBAAgB,CAAC,CACrB,KAAI,UAAA,GAAQC,KAAAA,SAAAA,CAAS,OAAO,IAAI,CAAC;CAEpC,OAAO;EACL,GAAG;EACH,MAAM;EACN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,IACE,SAASC,kCAAAA,cAAc,uBACvB,OAAO,OAAM,SAAQ,gBAAgB,SAAS,IAAI,CAAC,GACnD;IACA,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,sDAAsD;IAClE,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI;IACZ,OAAO;GACT;EAGF,EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circulars.js","names":[],"sources":["../../../src/rolldown-config/plugins/circulars.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { circularDependencies } from 'rollup-plugin-circular-dependencies';\n\nimport { toArray, type SoA } from '#utils';\n\nimport { WARNING_CODES } from '../constants';\nimport { withoutExtension } from '../helpers';\n\n/**\n * Options for the circular dependencies plugin.\n */\nexport type CircularDependenciesOptions = Omit<\n Parameters<typeof circularDependencies>[0],\n 'exclude'\n> & { exclude?: SoA<string> };\n\n/**\n * Creates a configured circular dependencies plugin instance with suppression for known patterns.\n *\n * @param options - Configuration options of type {@linkcode CircularDependenciesOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function circulars(\n options: CircularDependenciesOptions = {},\n): RolldownPluginOption {\n const all = circularDependencies(options);\n const exclude = toArray(options.exclude);\n\n const CIRCULAR_CHUNKS = exclude\n .filter(Boolean)\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n return {\n ...all,\n name: 'better circular-dependencies',\n onLog: {\n handler: (_, { code, names }) => {\n if (\n code === WARNING_CODES.CIRCULAR_DEPENDENCY &&\n names?.every(name => CIRCULAR_CHUNKS.includes(name))\n ) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log(
|
|
1
|
+
{"version":3,"file":"circulars.js","names":[],"sources":["../../../src/rolldown-config/plugins/circulars.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { circularDependencies } from 'rollup-plugin-circular-dependencies';\n\nimport { toArray, type SoA } from '#utils';\n\nimport { WARNING_CODES } from '../constants';\nimport { withoutExtension } from '../helpers';\n\n/**\n * Options for the circular dependencies plugin.\n */\nexport type CircularDependenciesOptions = Omit<\n Parameters<typeof circularDependencies>[0],\n 'exclude'\n> & { exclude?: SoA<string> };\n\n/**\n * Creates a configured circular dependencies plugin instance with suppression for known patterns.\n *\n * @param options - Configuration options of type {@linkcode CircularDependenciesOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function circulars(\n options: CircularDependenciesOptions = {},\n): RolldownPluginOption {\n const all = circularDependencies(options);\n const exclude = toArray(options.exclude);\n\n const CIRCULAR_CHUNKS = exclude\n .filter(Boolean)\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n return {\n ...all,\n name: 'better circular-dependencies',\n onLog: {\n handler: (_, { code, names }) => {\n if (\n code === WARNING_CODES.CIRCULAR_DEPENDENCY &&\n names?.every(name => CIRCULAR_CHUNKS.includes(name))\n ) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[bemedev] Skipping circular dependency warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n console.log();\n return false;\n }\n\n return;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,SAAgB,UACd,UAAuC,CAAC,GAClB;CACtB,MAAM,MAAM,qBAAqB,OAAO;CAGxC,MAAM,kBAFU,QAAQ,QAAQ,OAEF,CAAC,CAC5B,OAAO,OAAO,CAAC,CACf,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAI,gBAAgB,CAAC,CACrB,KAAI,SAAQ,SAAS,OAAO,IAAI,CAAC;CAEpC,OAAO;EACL,GAAG;EACH,MAAM;EACN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,IACE,SAAS,cAAc,uBACvB,OAAO,OAAM,SAAQ,gBAAgB,SAAS,IAAI,CAAC,GACnD;IACA,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,sDAAsD;IAClE,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI;IACZ,OAAO;GACT;EAGF,EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.cjs","names":["toArray","globSync","withoutExtension","relative","WARNING_CODES","findConfigFile","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(
|
|
1
|
+
{"version":3,"file":"clean.cjs","names":["toArray","globSync","withoutExtension","relative","WARNING_CODES","findConfigFile","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,oBAAAA,QAAQ,SAAS;CAwDpC,OAAO;EArDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAKC,KAAAA,SAAAA,CAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAIC,gCAAAA,gBAAgB,CAAC,CACrB,KAAI,UAAA,GAAQC,KAAAA,SAAAA,CAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,gBAAA,GAAeC,wBAAAA,eAAAA,CAAe,KAAKC,GAAAA,YAAY,eAAe;IAEpE,MAAM,SADUC,kDAAAA,aAAa,YAAY,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,CAAA,GADcN,KAAAA,SAAAA,CAAS,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,gCAAA,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(
|
|
1
|
+
{"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,SAAS;CAwDpC,OAAO;EArDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAI,gBAAgB,CAAC,CACrB,KAAI,SAAQ,SAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,eAAe,KAAK,YAAY,eAAe;IAEpE,MAAM,SADU,aAAa,YAAY,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,SADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.cjs","names":["nodeExternals"],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(
|
|
1
|
+
{"version":3,"file":"externals.cjs","names":["nodeExternals"],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(options: NodeExternalsOptions = {}): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAgB,UAAU,UAAgC,CAAC,GAAyB;CAClF,QAAA,GAAOA,6BAAAA,cAAAA,CAAc,OAAO;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(
|
|
1
|
+
{"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(options: NodeExternalsOptions = {}): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,UAAU,UAAgC,CAAC,GAAyB;CAClF,OAAO,cAAc,OAAO;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.cjs","names":["toArray","ts","existsSync","readTsConfig","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(
|
|
1
|
+
{"version":3,"file":"typescript.cjs","names":["toArray","ts","existsSync","readTsConfig","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(ts.formatDiagnosticsWithColorAndContext(errors, host));\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAA,oBAAAA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAeC,wBAAAA,QAAG,eAAe,KAAKC,GAAAA,YAAY,eAAe;IAEvE,MAAM,aAAaC,kDAAAA,aAAa,YAAY;IAC5C,MAAM,OAAOF,wBAAAA,QAAG,mBAAmB,WAAW,OAAO;IACrD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAASA,wBAAAA,QAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAGD,oBAAAA,QAAQ,OAAO,GAAG,MAAM;KACrC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;KACF;IACF,GACAC,wBAAAA,QAAG,KACH,GACF;IAEA,MAAM,UAAUA,wBAAAA,QAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;IACF,GACA,IACF;IAEA,MAAM,aAAa,QAAQ,KAAK;IAEhC,MAAM,SAASA,wBAAAA,QACZ,sBAAsB,OAAO,CAAC,CAC9B,OAAO,WAAW,WAAW,CAAC,CAC9B,QAAO,MAAK,EAAE,aAAaA,wBAAAA,QAAG,mBAAmB,KAAK;IAEzD,IAAI,OAAO,SAAS,GAClB,QAAQ,MAAMA,wBAAAA,QAAG,qCAAqC,QAAQ,IAAI,CAAC;IAGrE,OAAA,GAAMG,UAAAA,qBAAAA,CAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.cjs","names":["readFileSync","readdirSync","join","statSync","existsSync","ts","path","dirname"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (
|
|
1
|
+
{"version":3,"file":"typescript.config.cjs","names":["readFileSync","readdirSync","join","statSync","existsSync","ts","path","dirname"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (!extensions || extensions.some(ext => entry.endsWith(ext))) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(searchPath: string, configName: string = 'tsconfig.json') {\n const tsconfigPath = ts.findConfigFile(searchPath, existsSync, configName)!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,GAAOA,GAAAA,aAAAA,CAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,WAAA,GAAUC,GAAAA,YAAAA,CAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAWC,KAAAA,KAAAA,CAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,QAAA,GAAOC,GAAAA,SAAAA,CAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IAAI,CAAC,cAAc,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAClE,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYC,GAAAA;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UAAU,YAAoB,aAAqB,iBAAiB;CAClF,MAAM,eAAeC,wBAAAA,QAAG,eAAe,YAAYD,GAAAA,YAAY,UAAU;CAGzE,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,wBAAAA,QAAG,eAAeC,QAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACRD,wBAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqBA,wBAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GACAE,KAAAA,QAAAA,CAAQD,MAAI,CAGI;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (
|
|
1
|
+
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (!extensions || extensions.some(ext => entry.endsWith(ext))) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(searchPath: string, configName: string = 'tsconfig.json') {\n const tsconfigPath = ts.findConfigFile(searchPath, existsSync, configName)!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IAAI,CAAC,cAAc,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAClE,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UAAU,YAAoB,aAAqB,iBAAiB;CAClF,MAAM,eAAe,GAAG,eAAe,YAAY,YAAY,UAAU;CAGzE,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,IAAI,CAGI;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig","join","globSync","readFileSync","transformSync","relative","dirname","basename","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig","join","globSync","readFileSync","transformSync","relative","dirname","basename","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAA,oBAAAA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAeC,wBAAAA,QAAG,eAAe,KAAKC,GAAAA,YAAY,eAAe;IAEvE,MAAM,aAAaC,kDAAAA,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,YAAA,GAAWC,KAAAA,KAAAA,CAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,SAAA,GAAQC,KAAAA,SAAAA,EAAAA,GAASD,KAAAA,KAAAA,CAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQJ,oBAAAA,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KACF,MAAM,WAAA,GAAUM,GAAAA,aAAAA,CAAa,MAAM,OAAO;KAC1C,MAAM,UAAA,GAASC,cAAAA,cAAAA,CAAc,MAAM,SAAS;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,gBAAA,GAAeC,KAAAA,SAAAA,CAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,WAAA,GAAUJ,KAAAA,KAAAA,CAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,CAAA,GAAA,GAAA,UAAA,EAAA,GAAUK,KAAAA,QAAAA,CAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,2BAAA,GAA0BC,KAAAA,SAAAA,CAAS,OAAO,EAAE;MACvD,CAAA,GAAA,GAAA,cAAA,CACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,CAAA,GAAA,GAAA,cAAA,CAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,OAAA,GAAMC,UAAAA,qBAAAA,CAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eAAe,KAAK,YAAY,eAAe;IAEvE,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,WAAW,KAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,QAAQ,SAAS,KAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQ,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KACF,MAAM,UAAU,aAAa,MAAM,OAAO;KAC1C,MAAM,SAAS,cAAc,MAAM,SAAS;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,eAAe,SAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,UAAU,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,0BAA0B,SAAS,OAAO,EAAE;MACvD,cACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,cAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(
|
|
1
|
+
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(cwd, existsSync, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(ts.formatDiagnosticsWithColorAndContext(errors, host));\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eAAe,KAAK,YAAY,eAAe;IAEvE,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,OAAO,GAAG,mBAAmB,WAAW,OAAO;IACrD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAAS,GAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAG,QAAQ,OAAO,GAAG,MAAM;KACrC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;KACF;IACF,GACA,GAAG,KACH,GACF;IAEA,MAAM,UAAU,GAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;IACF,GACA,IACF;IAEA,MAAM,aAAa,QAAQ,KAAK;IAEhC,MAAM,SAAS,GACZ,sBAAsB,OAAO,CAAC,CAC9B,OAAO,WAAW,WAAW,CAAC,CAC9B,QAAO,MAAK,EAAE,aAAa,GAAG,mBAAmB,KAAK;IAEzD,IAAI,OAAO,SAAS,GAClB,QAAQ,MAAM,GAAG,qCAAqC,QAAQ,IAAI,CAAC;IAGrE,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFn.cjs","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn =
|
|
1
|
+
{"version":3,"file":"expandFn.cjs","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn = <Main extends Fn, const Tr extends object = object>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,YACX,MACA,eACsB;CACtB,MAAM,MAAW;CAEjB,IAAI,YACF,OAAO,OAAO,KAAK,UAAU;CAG/B,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFn.js","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn =
|
|
1
|
+
{"version":3,"file":"expandFn.js","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn = <Main extends Fn, const Tr extends object = object>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,YACX,MACA,eACsB;CACtB,MAAM,MAAW;CAEjB,IAAI,YACF,OAAO,OAAO,KAAK,UAAU;CAG/B,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport { buildInclude, defaultCovPattern, testPattern } from './vitest.utils';\n\n/**\n * Creates include arrays for test and coverage files from glob patterns.\n *\n * @param args - Glob patterns to ignore for test and coverage files.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\n/**\n * Creates include arrays using custom test and coverage glob patterns.\n *\n * @param patterns - Custom test and coverage pattern object.\n * @param patterns.patternTest - Glob pattern for test files.\n * @param patterns.patternCov - Glob pattern for coverage files.\n * @param args - Ignore options for tests and coverage.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Vitest plugin to configure test and coverage file inclusion via glob patterns.\n *\n * @param args - Globs to ignore for test and coverage files.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Vitest plugin to configure test and coverage file inclusion with custom search patterns.\n *\n * @param patterns - Custom test and coverage glob patterns.\n * @param ignore - Globs to exclude.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAaA,oCAAAA,YAAY,IAAI;EAC7B,YAAYC,oCAAAA,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;;;;;;;;;;;;AAaA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;AASA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL,MAAA,iCAAA;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,IAAI;GACzC,MAAM,cAAcD,oCAAAA,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL,MAAA,iCAAA;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
|