🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ts-project-builder

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-project-builder - npm Package Compare versions

Comparing version
4.0.1
to
5.0.0
+1
-1
dist/builder.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACR,cAAc,EAEjB,MAAM,SAAS,CAAC;AAsBjB,eAAO,MAAM,qBAAqB,EAAG,iCAA0C,CAAC;AAChF,eAAO,MAAM,gBAAgB,EAAG,QAAiB,CAAC;AAClD,eAAO,MAAM,gCAAgC,EAAG,OAAgB,CAAC;AAcjE,qBAAa,OAAO;;gBAIJ,OAAO,EAAE,cAAc;IA2B7B,KAAK;CAgJd"}
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EACR,cAAc,EAEjB,MAAM,SAAS,CAAC;AAsBjB,eAAO,MAAM,qBAAqB,EAAG,iCAA0C,CAAC;AAChF,eAAO,MAAM,gBAAgB,EAAG,QAAiB,CAAC;AAClD,eAAO,MAAM,gCAAgC,EAAG,OAAgB,CAAC;AAcjE,qBAAa,OAAO;;gBAIJ,OAAO,EAAE,cAAc;IAqD7B,KAAK;CAiJd"}

@@ -1,3 +0,2 @@

import { globSync } from 'node:fs';
import { rm } from 'node:fs/promises';
import { glob, rm } from 'node:fs/promises';
import { resolve, relative, isAbsolute } from 'node:path';

@@ -9,2 +8,3 @@ import { pathToFileURL } from 'node:url';

import typescript from '@rollup/plugin-typescript';
import isGlob from 'is-glob';
import { cloneDeep, merge } from 'lodash-es';

@@ -34,3 +34,3 @@ import prettyMilliseconds from 'pretty-ms';

const defaultOutputPreserveModulesRoot = './src';
const outputFormatToExtMap = Object.freeze({
const outputFormatToExtMap = {
amd: 'amd.js',

@@ -46,3 +46,3 @@ cjs: 'cjs',

umd: 'umd.js',
});
};
class Builder {

@@ -77,2 +77,22 @@ #configFilePath;

}
#prepareInputPlugins(config) {
const plugins = config.additionalInputPlugins?.beforeBuiltIns || [];
if (config.enableBuiltInInputPlugins?.nodeExternal !== false) {
plugins.push(nodeExternals(config.builtInInputPluginOptions?.nodeExternal));
}
if (config.enableBuiltInInputPlugins?.nodeResolve !== false) {
plugins.push(nodeResolve(config.builtInInputPluginOptions?.nodeResolve));
}
if (config.enableBuiltInInputPlugins?.commonjs !== false) {
plugins.push(commonjs(config.builtInInputPluginOptions?.commonjs));
}
if (config.enableBuiltInInputPlugins?.json !== false) {
plugins.push(json(config.builtInInputPluginOptions?.json));
}
if (config.enableBuiltInInputPlugins?.typescript !== false) {
plugins.push(typescript(config.builtInInputPluginOptions?.typescript));
}
plugins.push(...config.additionalInputPlugins?.afterBuiltIns || []);
return plugins;
}
async build() {

@@ -89,15 +109,17 @@ stderr(cyan('Starting build...'));

};
const inputFiles = await Promise.all([...new Set(this.#options.inputs)].map(async (input) => {
if (!isGlob(input, { strict: false }))
return input;
const files = [];
for await (const file of glob(input))
files.push(file);
if (!files.length)
console.warn(`⚠️ No files matched for glob pattern: ${input}`);
return files;
}));
const logOutputTargetsStrings = [];
const rollupInputPlugins = [
...config.additionalInputPlugins?.beforeBuiltIns || [],
nodeExternals(config.builtInInputPluginOptions?.nodeExternal),
nodeResolve(config.builtInInputPluginOptions?.nodeResolve),
commonjs(config.builtInInputPluginOptions?.commonjs),
json(config.builtInInputPluginOptions?.json),
typescript(config.builtInInputPluginOptions?.typescript),
...config.additionalInputPlugins?.afterBuiltIns || [],
];
const rollupInputPlugins = this.#prepareInputPlugins(config);
const rollupOptions = {
...config.rollupOptions,
input: [...new Set(this.#options.inputs)].map((input) => globSync(input)).flat().sort(),
input: [...new Set(inputFiles.flat())].sort(),
};

@@ -104,0 +126,0 @@ const rollupOutputs = [];

@@ -1,1 +0,1 @@

{"version":3,"file":"builder.mjs","sources":["../src/builder.ts"],"sourcesContent":["import { globSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport {\n isAbsolute,\n relative,\n resolve,\n} from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport typescript from '@rollup/plugin-typescript';\nimport {\n cloneDeep,\n merge,\n} from 'lodash-es';\nimport prettyMilliseconds from 'pretty-ms';\nimport { rollup } from 'rollup';\nimport type {\n ModuleFormat,\n OutputOptions,\n OutputPlugin,\n Plugin,\n RollupOptions,\n} from 'rollup';\nimport { minify } from 'rollup-plugin-esbuild';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\nimport type { SetFieldType } from 'type-fest';\n\nimport type {\n BuilderOptions,\n Config,\n} from './types';\nimport { pathIsFile } from './utils';\nimport {\n bold,\n cyan,\n green,\n} from './utils/rollup/colors';\nimport { stderr } from './utils/rollup/logging';\n\nconst availableOutputFormats = new Set<ModuleFormat>([\n 'amd',\n 'cjs',\n 'commonjs',\n 'es',\n 'esm',\n 'iife',\n 'module',\n 'system',\n 'systemjs',\n 'umd',\n]);\n\nexport const defaultConfigFilePath = './ts-project-builder.config.mjs' as const;\nexport const defaultOutputDir = './dist' as const;\nexport const defaultOutputPreserveModulesRoot = './src' as const;\nconst outputFormatToExtMap = Object.freeze<Record<ModuleFormat, string>>({\n amd: 'amd.js',\n cjs: 'cjs',\n commonjs: 'cjs',\n es: 'mjs',\n esm: 'mjs',\n iife: 'iife.js',\n module: 'mjs',\n system: 'system.js',\n systemjs: 'system.js',\n umd: 'umd.js',\n});\n\nexport class Builder {\n #configFilePath: string;\n #options: BuilderOptions;\n\n constructor(options: BuilderOptions) {\n options = cloneDeep(options);\n if (!options.inputs.length) throw new Error('No inputs specified');\n if (!options.output.formats.size) throw new Error('No output formats specified');\n this.#configFilePath = resolve(options.configFilePath || defaultConfigFilePath);\n this.#options = options;\n }\n\n async #getConfig() {\n if (!this.#configFilePath) return {};\n if (!await pathIsFile(this.#configFilePath)) {\n if (relative(this.#configFilePath, resolve(defaultConfigFilePath)) !== '') {\n throw new Error(`Config file not found: ${this.#configFilePath}`);\n }\n\n return {};\n }\n\n const config = await import(pathToFileURL(resolve(this.#configFilePath)).toString());\n return (config && typeof config === 'object' && 'default' in config ? config.default : config) as Config;\n }\n\n #isOutputOptionEnabled(format: ModuleFormat, optionKey: 'clean' | 'forceClean' | 'minify' | 'preserveModules') {\n if (!this.#options.output[optionKey]) return;\n return this.#options.output[optionKey] === true || this.#options.output[optionKey].has(format);\n }\n\n async build() {\n stderr(cyan('Starting build...'));\n const startAt = Date.now();\n const config = await this.#getConfig();\n const baseOutputOptions: OutputOptions & { ext?: string } = {\n dir: this.#options.output.dirs?.default || defaultOutputDir,\n ext: this.#options.output.exts?.default,\n file: this.#options.output.files?.default,\n preserveModulesRoot: this.#options.output.preserveModulesRoots?.default || defaultOutputPreserveModulesRoot,\n sourcemap: this.#options.output.sourcemaps?.default,\n };\n\n const logOutputTargetsStrings: string[] = [];\n const rollupInputPlugins: Plugin[] = [\n ...config.additionalInputPlugins?.beforeBuiltIns || [],\n nodeExternals(config.builtInInputPluginOptions?.nodeExternal),\n nodeResolve(config.builtInInputPluginOptions?.nodeResolve),\n commonjs(config.builtInInputPluginOptions?.commonjs),\n json(config.builtInInputPluginOptions?.json),\n typescript(config.builtInInputPluginOptions?.typescript),\n ...config.additionalInputPlugins?.afterBuiltIns || [],\n ];\n\n const rollupOptions: RollupOptions = {\n ...config.rollupOptions,\n input: [...new Set(this.#options.inputs)].map((input) => globSync(input)).flat().sort(),\n };\n\n const rollupOutputs: OutputOptions[] = [];\n const rootPath = resolve();\n const toRemovePaths = new Set<string>();\n for (const format of this.#options.output.formats) {\n if (!availableOutputFormats.has(format)) throw new Error(`Invalid output format: ${format}`);\n const configOutputOptions = config.outputOptions?.[format] || config.outputOptions?.default;\n let outputOptions: SetFieldType<OutputOptions, 'plugins', OutputPlugin[]>;\n if (configOutputOptions?.processMethod === 'replace') {\n outputOptions = configOutputOptions.options as typeof outputOptions;\n } else {\n const entryFileNames = `[name].${\n this.#options.output.exts?.[format]\n || baseOutputOptions.ext\n || outputFormatToExtMap[format]\n }`;\n\n outputOptions = {\n dir: this.#options.output.dirs?.[format] || baseOutputOptions.dir,\n entryFileNames,\n exports: 'named',\n externalLiveBindings: false,\n file: this.#options.output.files?.[format] || baseOutputOptions.file,\n generatedCode: {\n arrowFunctions: true,\n constBindings: true,\n objectShorthand: true,\n },\n interop: 'compat',\n plugins: [],\n preserveModules: this.#isOutputOptionEnabled(format, 'preserveModules'),\n // eslint-disable-next-line style/max-len\n preserveModulesRoot: this.#options.output.preserveModulesRoots?.[format] || baseOutputOptions.preserveModulesRoot,\n sourcemap: this.#options.output.sourcemaps?.[format] ?? baseOutputOptions.sourcemap,\n };\n\n if (this.#isOutputOptionEnabled(format, 'minify')) {\n // eslint-disable-next-line style/max-len\n const minifyOptions = config.builtInOutputPluginOptions?.minify?.[format] || config.builtInOutputPluginOptions?.minify?.default;\n outputOptions.plugins?.push(minify(minifyOptions));\n }\n\n outputOptions.plugins?.push(\n ...config.additionalOutputPlugins?.[format]?.afterBuiltIns\n || config.additionalOutputPlugins?.default?.afterBuiltIns\n || [],\n );\n\n outputOptions.plugins?.unshift(\n ...config.additionalOutputPlugins?.[format]?.beforeBuiltIns\n || config.additionalOutputPlugins?.default?.beforeBuiltIns\n || [],\n );\n\n if (configOutputOptions?.processMethod === 'assign') {\n Object.assign(outputOptions, configOutputOptions.options);\n } else merge(outputOptions, configOutputOptions?.options);\n }\n\n outputOptions.format = format;\n if (outputOptions.file) {\n delete outputOptions.dir;\n logOutputTargetsStrings.push(`${outputOptions.file} (${format})`);\n } else if (outputOptions.dir) {\n delete outputOptions.file;\n logOutputTargetsStrings.push(`${outputOptions.dir} (${format})`);\n }\n\n if (this.#isOutputOptionEnabled(format, 'clean')) {\n const outputPath = outputOptions.dir || outputOptions.file;\n if (outputPath) {\n const absoluteOutputPath = resolve(outputPath);\n const relativePath = relative(rootPath, absoluteOutputPath);\n if (relativePath === '') {\n throw new Error('The directory to be cleared is the same as the running directory.');\n }\n\n if (\n !(!isAbsolute(relativePath) && !relativePath.startsWith('..'))\n && !this.#isOutputOptionEnabled(format, 'forceClean')\n ) {\n // eslint-disable-next-line style/max-len\n throw new Error(`The path \"${absoluteOutputPath}\" to be cleaned is not under the running directory. To force clean, please add the --force-clean parameter.`);\n }\n\n toRemovePaths.add(absoluteOutputPath);\n }\n }\n\n rollupOutputs.push(outputOptions);\n }\n\n const logInputFiles = [...rollupOptions.input as string[]];\n if (logInputFiles.length > 20) {\n logInputFiles.splice(20, logInputFiles.length, `... (${logInputFiles.length - 20} more)`);\n }\n\n const logOutputTargetsString = bold(logOutputTargetsStrings.join(', ').trim());\n stderr(cyan(`${bold(logInputFiles.join(', ').trim())} → ${logOutputTargetsString}...`));\n const rollupResult = await rollup({\n ...rollupOptions,\n plugins: rollupInputPlugins,\n });\n\n await Promise.all(\n [...toRemovePaths].map(async (path) => rm(\n path,\n {\n force: true,\n recursive: true,\n },\n )),\n );\n\n await Promise.all(rollupOutputs.map((outputOptions) => rollupResult.write(outputOptions)));\n stderr(green(`Created ${logOutputTargetsString} in ${bold(prettyMilliseconds(Date.now() - startAt))}`));\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAe;IACjD,KAAK;IACL,KAAK;IACL,UAAU;IACV,IAAI;IACJ,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,KAAK;AACR,CAAA,CAAC;AAEK,MAAM,qBAAqB,GAAG;AAC9B,MAAM,gBAAgB,GAAG;AACzB,MAAM,gCAAgC,GAAG;AAChD,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAA+B;AACrE,IAAA,GAAG,EAAE,QAAQ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,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,EAAE,CACrC,IAAI,EACJ;AACI,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,SAAS,EAAE,IAAI;SAClB,CACJ,CAAC,CACL;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,aAAa,KAAK,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1F,MAAM,CAAC,KAAK,CAAC,CAAA,QAAA,EAAW,sBAAsB,CAAO,IAAA,EAAA,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC;;AAE9G;;;;"}
{"version":3,"file":"builder.mjs","sources":["../src/builder.ts"],"sourcesContent":["import {\n glob,\n rm,\n} from 'node:fs/promises';\nimport {\n isAbsolute,\n relative,\n resolve,\n} from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport typescript from '@rollup/plugin-typescript';\n// @ts-expect-error Ignore this error.\nimport isGlob from 'is-glob';\nimport {\n cloneDeep,\n merge,\n} from 'lodash-es';\nimport prettyMilliseconds from 'pretty-ms';\nimport { rollup } from 'rollup';\nimport type {\n ModuleFormat,\n OutputOptions,\n OutputPlugin,\n Plugin,\n RollupOptions,\n} from 'rollup';\nimport { minify } from 'rollup-plugin-esbuild';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\nimport type { SetFieldType } from 'type-fest';\n\nimport type {\n BuilderOptions,\n Config,\n} from './types';\nimport { pathIsFile } from './utils';\nimport {\n bold,\n cyan,\n green,\n} from './utils/rollup/colors';\nimport { stderr } from './utils/rollup/logging';\n\nconst availableOutputFormats = new Set<ModuleFormat>([\n 'amd',\n 'cjs',\n 'commonjs',\n 'es',\n 'esm',\n 'iife',\n 'module',\n 'system',\n 'systemjs',\n 'umd',\n]);\n\nexport const defaultConfigFilePath = './ts-project-builder.config.mjs' as const;\nexport const defaultOutputDir = './dist' as const;\nexport const defaultOutputPreserveModulesRoot = './src' as const;\nconst outputFormatToExtMap: Readonly<Record<ModuleFormat, string>> = {\n amd: 'amd.js',\n cjs: 'cjs',\n commonjs: 'cjs',\n es: 'mjs',\n esm: 'mjs',\n iife: 'iife.js',\n module: 'mjs',\n system: 'system.js',\n systemjs: 'system.js',\n umd: 'umd.js',\n};\n\nexport class Builder {\n #configFilePath: string;\n #options: BuilderOptions;\n\n constructor(options: BuilderOptions) {\n options = cloneDeep(options);\n if (!options.inputs.length) throw new Error('No inputs specified');\n if (!options.output.formats.size) throw new Error('No output formats specified');\n this.#configFilePath = resolve(options.configFilePath || defaultConfigFilePath);\n this.#options = options;\n }\n\n async #getConfig() {\n if (!this.#configFilePath) return {};\n if (!await pathIsFile(this.#configFilePath)) {\n if (relative(this.#configFilePath, resolve(defaultConfigFilePath)) !== '') {\n throw new Error(`Config file not found: ${this.#configFilePath}`);\n }\n\n return {};\n }\n\n const config = await import(pathToFileURL(resolve(this.#configFilePath)).toString());\n return (config && typeof config === 'object' && 'default' in config ? config.default : config) as Config;\n }\n\n #isOutputOptionEnabled(format: ModuleFormat, optionKey: 'clean' | 'forceClean' | 'minify' | 'preserveModules') {\n if (!this.#options.output[optionKey]) return;\n return this.#options.output[optionKey] === true || this.#options.output[optionKey].has(format);\n }\n\n #prepareInputPlugins(config: Config) {\n const plugins: Plugin[] = config.additionalInputPlugins?.beforeBuiltIns || [];\n if (config.enableBuiltInInputPlugins?.nodeExternal !== false) {\n plugins.push(nodeExternals(config.builtInInputPluginOptions?.nodeExternal));\n }\n\n if (config.enableBuiltInInputPlugins?.nodeResolve !== false) {\n plugins.push(nodeResolve(config.builtInInputPluginOptions?.nodeResolve));\n }\n\n if (config.enableBuiltInInputPlugins?.commonjs !== false) {\n plugins.push(commonjs(config.builtInInputPluginOptions?.commonjs));\n }\n\n if (config.enableBuiltInInputPlugins?.json !== false) {\n plugins.push(json(config.builtInInputPluginOptions?.json));\n }\n\n if (config.enableBuiltInInputPlugins?.typescript !== false) {\n plugins.push(typescript(config.builtInInputPluginOptions?.typescript));\n }\n\n plugins.push(...config.additionalInputPlugins?.afterBuiltIns || []);\n return plugins;\n }\n\n async build() {\n stderr(cyan('Starting build...'));\n const startAt = Date.now();\n const config = await this.#getConfig();\n const baseOutputOptions: OutputOptions & { ext?: string } = {\n dir: this.#options.output.dirs?.default || defaultOutputDir,\n ext: this.#options.output.exts?.default,\n file: this.#options.output.files?.default,\n preserveModulesRoot: this.#options.output.preserveModulesRoots?.default || defaultOutputPreserveModulesRoot,\n sourcemap: this.#options.output.sourcemaps?.default,\n };\n\n const inputFiles = await Promise.all(\n [...new Set(this.#options.inputs)].map(async (input) => {\n if (!isGlob(input, { strict: false })) return input;\n const files = [];\n for await (const file of glob(input)) files.push(file);\n if (!files.length) console.warn(`⚠️ No files matched for glob pattern: ${input}`);\n return files;\n }),\n );\n\n const logOutputTargetsStrings: string[] = [];\n const rollupInputPlugins = this.#prepareInputPlugins(config);\n const rollupOptions: RollupOptions = {\n ...config.rollupOptions,\n input: [...new Set(inputFiles.flat())].sort(),\n };\n\n const rollupOutputs: OutputOptions[] = [];\n const rootPath = resolve();\n const toRemovePaths = new Set<string>();\n for (const format of this.#options.output.formats) {\n if (!availableOutputFormats.has(format)) throw new Error(`Invalid output format: ${format}`);\n const configOutputOptions = config.outputOptions?.[format] || config.outputOptions?.default;\n let outputOptions: SetFieldType<OutputOptions, 'plugins', OutputPlugin[]>;\n if (configOutputOptions?.processMethod === 'replace') {\n outputOptions = configOutputOptions.options as typeof outputOptions;\n } else {\n const entryFileNames = `[name].${\n this.#options.output.exts?.[format]\n || baseOutputOptions.ext\n || outputFormatToExtMap[format]\n }`;\n\n outputOptions = {\n dir: this.#options.output.dirs?.[format] || baseOutputOptions.dir,\n entryFileNames,\n exports: 'named',\n externalLiveBindings: false,\n file: this.#options.output.files?.[format] || baseOutputOptions.file,\n generatedCode: {\n arrowFunctions: true,\n constBindings: true,\n objectShorthand: true,\n },\n interop: 'compat',\n plugins: [],\n preserveModules: this.#isOutputOptionEnabled(format, 'preserveModules'),\n // eslint-disable-next-line style/max-len\n preserveModulesRoot: this.#options.output.preserveModulesRoots?.[format] || baseOutputOptions.preserveModulesRoot,\n sourcemap: this.#options.output.sourcemaps?.[format] ?? baseOutputOptions.sourcemap,\n };\n\n if (this.#isOutputOptionEnabled(format, 'minify')) {\n // eslint-disable-next-line style/max-len\n const minifyOptions = config.builtInOutputPluginOptions?.minify?.[format] || config.builtInOutputPluginOptions?.minify?.default;\n outputOptions.plugins?.push(minify(minifyOptions));\n }\n\n outputOptions.plugins?.push(\n ...config.additionalOutputPlugins?.[format]?.afterBuiltIns\n || config.additionalOutputPlugins?.default?.afterBuiltIns\n || [],\n );\n\n outputOptions.plugins?.unshift(\n ...config.additionalOutputPlugins?.[format]?.beforeBuiltIns\n || config.additionalOutputPlugins?.default?.beforeBuiltIns\n || [],\n );\n\n if (configOutputOptions?.processMethod === 'assign') {\n Object.assign(outputOptions, configOutputOptions.options);\n } else merge(outputOptions, configOutputOptions?.options);\n }\n\n outputOptions.format = format;\n if (outputOptions.file) {\n delete outputOptions.dir;\n logOutputTargetsStrings.push(`${outputOptions.file} (${format})`);\n } else if (outputOptions.dir) {\n delete outputOptions.file;\n logOutputTargetsStrings.push(`${outputOptions.dir} (${format})`);\n }\n\n if (this.#isOutputOptionEnabled(format, 'clean')) {\n const outputPath = outputOptions.dir || outputOptions.file;\n if (outputPath) {\n const absoluteOutputPath = resolve(outputPath);\n const relativePath = relative(rootPath, absoluteOutputPath);\n if (relativePath === '') {\n throw new Error('The directory to be cleared is the same as the running directory.');\n }\n\n if (\n !(!isAbsolute(relativePath) && !relativePath.startsWith('..'))\n && !this.#isOutputOptionEnabled(format, 'forceClean')\n ) {\n // eslint-disable-next-line style/max-len\n throw new Error(`The path \"${absoluteOutputPath}\" to be cleaned is not under the running directory. To force clean, please add the --force-clean parameter.`);\n }\n\n toRemovePaths.add(absoluteOutputPath);\n }\n }\n\n rollupOutputs.push(outputOptions);\n }\n\n const logInputFiles = [...rollupOptions.input as string[]];\n if (logInputFiles.length > 20) {\n logInputFiles.splice(20, logInputFiles.length, `... (${logInputFiles.length - 20} more)`);\n }\n\n const logOutputTargetsString = bold(logOutputTargetsStrings.join(', ').trim());\n stderr(cyan(`${bold(logInputFiles.join(', ').trim())} → ${logOutputTargetsString}...`));\n const rollupResult = await rollup({\n ...rollupOptions,\n plugins: rollupInputPlugins,\n });\n\n await Promise.all(\n [...toRemovePaths].map(async (path) => rm(\n path,\n {\n force: true,\n recursive: true,\n },\n )),\n );\n\n await Promise.all(rollupOutputs.map((outputOptions) => rollupResult.write(outputOptions)));\n stderr(green(`Created ${logOutputTargetsString} in ${bold(prettyMilliseconds(Date.now() - startAt))}`));\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8CA,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAe;IACjD,KAAK;IACL,KAAK;IACL,UAAU;IACV,IAAI;IACJ,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,KAAK;AACR,CAAA,CAAC;AAEK,MAAM,qBAAqB,GAAG;AAC9B,MAAM,gBAAgB,GAAG;AACzB,MAAM,gCAAgC,GAAG;AAChD,MAAM,oBAAoB,GAA2C;AACjE,IAAA,GAAG,EAAE,QAAQ;AACb,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,EAAE,EAAE,KAAK;AACT,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,MAAM,EAAE,KAAK;AACb,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,QAAQ,EAAE,WAAW;AACrB,IAAA,GAAG,EAAE,QAAQ;CAChB;MAEY,OAAO,CAAA;AA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@@ -36,15 +36,2 @@ #!/usr/bin/env node

},
dirs: {
default: defaultOutputDir,
description: 'The output directory paths.',
type: String,
},
exts: {
description: 'The output file extensions.',
type: String,
},
files: {
description: 'The output file paths.',
type: String,
},
forceClean: {

@@ -65,2 +52,15 @@ description: 'Force clean the target directory or files before output.',

},
outDirs: {
default: defaultOutputDir,
description: 'The output directory paths.',
type: String,
},
outExts: {
description: 'The output file extensions.',
type: String,
},
outFiles: {
description: 'The output file paths.',
type: String,
},
preserveModules: { type: BooleanOrModuleFormats },

@@ -90,5 +90,5 @@ preserveModulesRoots: {

clean: args.flags.clean,
dirs: parseCliArgString(args.flags.dirs),
exts: parseCliArgString(args.flags.exts || ''),
files: parseCliArgString(args.flags.files || ''),
dirs: parseCliArgString(args.flags.outDirs),
exts: parseCliArgString(args.flags.outExts || ''),
files: parseCliArgString(args.flags.outFiles || ''),
forceClean: args.flags.forceClean,

@@ -98,3 +98,2 @@ formats: new Set(args.flags.formats.split(',')),

preserveModules: args.flags.preserveModules,
// eslint-disable-next-line style/max-len
preserveModulesRoots: parseCliArgString(args.flags.preserveModulesRoots),

@@ -101,0 +100,0 @@ sourcemaps: (() => {

@@ -1,1 +0,1 @@

{"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["import { cli } from 'cleye';\nimport type { ModuleFormat } from 'rollup';\n\nimport {\n name,\n version,\n} from '../package.json';\n\nimport {\n Builder,\n defaultConfigFilePath,\n defaultOutputDir,\n defaultOutputPreserveModulesRoot,\n} from './builder';\nimport type { NonNullableBuilderOutputOptions } from './types';\nimport { parseCliArgString } from './utils';\nimport { handleError } from './utils/rollup/logging';\n\nfunction BooleanOrModuleFormats(value: string): boolean | Set<ModuleFormat> {\n if (value === '') return true;\n return new Set(value.split(',').map((value) => value.trim().toLowerCase())) as Set<ModuleFormat>;\n}\n\nfunction parseSourcemapFlagValue(value?: string) {\n if (!value || value === 'true') return true;\n if (value === 'false') return false;\n if (value === 'hidden' || value === 'inline') return value;\n throw new Error(`Invalid sourcemap option: '${value}'. Valid options are 'true', 'false', 'hidden', or 'inline'.`);\n}\n\n(async () => {\n const args = cli({\n flags: {\n clean: {\n description: 'Clean the target directory or files before output.',\n type: BooleanOrModuleFormats,\n },\n config: {\n alias: 'c',\n default: defaultConfigFilePath,\n description: 'The path to the config file.',\n type: String,\n },\n dirs: {\n default: defaultOutputDir,\n description: 'The output directory paths.',\n type: String,\n },\n exts: {\n description: 'The output file extensions.',\n type: String,\n },\n files: {\n description: 'The output file paths.',\n type: String,\n },\n forceClean: {\n description: 'Force clean the target directory or files before output.',\n type: BooleanOrModuleFormats,\n },\n formats: {\n alias: 'f',\n default: 'cjs,esm',\n description: 'The output formats.',\n type: String,\n },\n minify: {\n alias: 'm',\n description: 'Enable minify output.',\n type: BooleanOrModuleFormats,\n },\n preserveModules: { type: BooleanOrModuleFormats },\n preserveModulesRoots: {\n default: defaultOutputPreserveModulesRoot,\n type: String,\n },\n sourcemaps: {\n description: 'The output sourcemap options.',\n type: String,\n },\n },\n help: { usage: `${name} <inputs...> [flags...]` },\n name,\n parameters: ['<inputs...>'],\n version,\n });\n\n const inputs = args._.inputs;\n if (!inputs.length) inputs.push('./src/index.ts');\n try {\n await new Builder({\n configFilePath: args.flags.config,\n inputs,\n output: {\n clean: args.flags.clean,\n dirs: parseCliArgString<NonNullableBuilderOutputOptions['dirs']>(args.flags.dirs),\n exts: parseCliArgString<NonNullableBuilderOutputOptions['exts']>(args.flags.exts || ''),\n files: parseCliArgString<NonNullableBuilderOutputOptions['files']>(args.flags.files || ''),\n forceClean: args.flags.forceClean,\n formats: new Set(args.flags.formats.split(',') as ModuleFormat[]),\n minify: args.flags.minify,\n preserveModules: args.flags.preserveModules,\n // eslint-disable-next-line style/max-len\n preserveModulesRoots: parseCliArgString<NonNullableBuilderOutputOptions['preserveModulesRoots']>(args.flags.preserveModulesRoots),\n sourcemaps: (() => {\n if (args.flags.sourcemaps === undefined) return;\n const parseResult = parseCliArgString(args.flags.sourcemaps);\n const sourcemaps: NonNullableBuilderOutputOptions['sourcemaps'] = {};\n for (const key in parseResult) {\n // eslint-disable-next-line style/max-len\n sourcemaps[key as keyof NonNullableBuilderOutputOptions['sourcemaps']] = parseSourcemapFlagValue(parseResult[key]);\n }\n\n sourcemaps.default ??= true;\n return sourcemaps;\n })(),\n },\n }).build();\n } catch (error) {\n handleError(error as Error);\n process.exit(1);\n }\n})();\n"],"names":[],"mappings":";;;;;;;;AAkBA,SAAS,sBAAsB,CAAC,KAAa,EAAA;IACzC,IAAI,KAAK,KAAK,EAAE;AAAE,QAAA,OAAO,IAAI;IAC7B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAsB;AACpG;AAEA,SAAS,uBAAuB,CAAC,KAAc,EAAA;AAC3C,IAAA,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM;AAAE,QAAA,OAAO,IAAI;IAC3C,IAAI,KAAK,KAAK,OAAO;AAAE,QAAA,OAAO,KAAK;AACnC,IAAA,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;AAC1D,IAAA,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAA,4DAAA,CAA8D,CAAC;AACtH;AAEA,CAAC,YAAW;IACR,MAAM,IAAI,GAAG,GAAG,CAAC;AACb,QAAA,KAAK,EAAE;AACH,YAAA,KAAK,EAAE;AACH,gBAAA,WAAW,EAAE,oDAAoD;AACjE,gBAAA,IAAI,EAAE,sBAAsB;AAC/B,aAAA;AACD,YAAA,MAAM,EAAE;AACJ,gBAAA,KAAK,EAAE,GAAG;AACV,gBAAA,OAAO,EAAE,qBAAqB;AAC9B,gBAAA,WAAW,EAAE,8BAA8B;AAC3C,gBAAA,IAAI,EAAE,MAAM;AACf,aAAA;AACD,YAAA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AA,OAAO,UAAU;AACrB,iBAAC,GAAG;AACP,aAAA;SACJ,CAAC,CAAC,KAAK,EAAE;;IACZ,OAAO,KAAK,EAAE;QACZ,WAAW,CAAC,KAAc,CAAC;AAC3B,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEvB,CAAC,GAAG"}
{"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["import { cli } from 'cleye';\nimport type { ModuleFormat } from 'rollup';\n\nimport {\n name,\n version,\n} from '../package.json';\n\nimport {\n Builder,\n defaultConfigFilePath,\n defaultOutputDir,\n defaultOutputPreserveModulesRoot,\n} from './builder';\nimport type { NonNullableBuilderOutputOptions } from './types';\nimport { parseCliArgString } from './utils';\nimport { handleError } from './utils/rollup/logging';\n\nfunction BooleanOrModuleFormats(value: string): boolean | Set<ModuleFormat> {\n if (value === '') return true;\n return new Set(value.split(',').map((value) => value.trim().toLowerCase())) as Set<ModuleFormat>;\n}\n\nfunction parseSourcemapFlagValue(value?: string) {\n if (!value || value === 'true') return true;\n if (value === 'false') return false;\n if (value === 'hidden' || value === 'inline') return value;\n throw new Error(`Invalid sourcemap option: '${value}'. Valid options are 'true', 'false', 'hidden', or 'inline'.`);\n}\n\n(async () => {\n const args = cli({\n flags: {\n clean: {\n description: 'Clean the target directory or files before output.',\n type: BooleanOrModuleFormats,\n },\n config: {\n alias: 'c',\n default: defaultConfigFilePath,\n description: 'The path to the config file.',\n type: String,\n },\n forceClean: {\n description: 'Force clean the target directory or files before output.',\n type: BooleanOrModuleFormats,\n },\n formats: {\n alias: 'f',\n default: 'cjs,esm',\n description: 'The output formats.',\n type: String,\n },\n minify: {\n alias: 'm',\n description: 'Enable minify output.',\n type: BooleanOrModuleFormats,\n },\n outDirs: {\n default: defaultOutputDir,\n description: 'The output directory paths.',\n type: String,\n },\n outExts: {\n description: 'The output file extensions.',\n type: String,\n },\n outFiles: {\n description: 'The output file paths.',\n type: String,\n },\n preserveModules: { type: BooleanOrModuleFormats },\n preserveModulesRoots: {\n default: defaultOutputPreserveModulesRoot,\n type: String,\n },\n sourcemaps: {\n description: 'The output sourcemap options.',\n type: String,\n },\n },\n help: { usage: `${name} <inputs...> [flags...]` },\n name,\n parameters: ['<inputs...>'],\n version,\n });\n\n const inputs = args._.inputs;\n if (!inputs.length) inputs.push('./src/index.ts');\n try {\n await new Builder({\n configFilePath: args.flags.config,\n inputs,\n output: {\n clean: args.flags.clean,\n dirs: parseCliArgString<NonNullableBuilderOutputOptions['dirs']>(args.flags.outDirs),\n exts: parseCliArgString<NonNullableBuilderOutputOptions['exts']>(args.flags.outExts || ''),\n files: parseCliArgString<NonNullableBuilderOutputOptions['files']>(args.flags.outFiles || ''),\n forceClean: args.flags.forceClean,\n formats: new Set(args.flags.formats.split(',') as ModuleFormat[]),\n minify: args.flags.minify,\n preserveModules: args.flags.preserveModules,\n preserveModulesRoots: parseCliArgString<NonNullableBuilderOutputOptions['preserveModulesRoots']>(\n args.flags.preserveModulesRoots,\n ),\n sourcemaps: (() => {\n if (args.flags.sourcemaps === undefined) return;\n const parseResult = parseCliArgString(args.flags.sourcemaps);\n const sourcemaps: NonNullableBuilderOutputOptions['sourcemaps'] = {};\n for (const key in parseResult) {\n // eslint-disable-next-line style/max-len\n sourcemaps[key as keyof NonNullableBuilderOutputOptions['sourcemaps']] = parseSourcemapFlagValue(parseResult[key]);\n }\n\n sourcemaps.default ??= true;\n return sourcemaps;\n })(),\n },\n }).build();\n } catch (error) {\n handleError(error as Error);\n process.exit(1);\n }\n})();\n"],"names":[],"mappings":";;;;;;;;AAkBA,SAAS,sBAAsB,CAAC,KAAa,EAAA;IACzC,IAAI,KAAK,KAAK,EAAE;AAAE,QAAA,OAAO,IAAI;IAC7B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAsB;AACpG;AAEA,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,gBAAA,OAAO,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;AACjE,gBAAA,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;AACzB,gBAAA,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe;gBAC3C,oBAAoB,EAAE,iBAAiB,CACnC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAClC;gBACD,UAAU,EAAE,CAAC,MAAK;AACd,oBAAA,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;wBAAE;oBACzC,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;oBAC5D,MAAM,UAAU,GAAkD,EAAE;AACpE,oBAAA,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;;wBAE3B,UAAU,CAAC,GAA0D,CAAC,GAAG,uBAAuB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;;AAGtH,oBAAA,UAAU,CAAC,OAAO,KAAK,IAAI;AAC3B,oBAAA,OAAO,UAAU;AACrB,iBAAC,GAAG;AACP,aAAA;SACJ,CAAC,CAAC,KAAK,EAAE;;IACZ,OAAO,KAAK,EAAE;QACZ,WAAW,CAAC,KAAc,CAAC;AAC3B,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEvB,CAAC,GAAG"}
var name = "ts-project-builder";
var version = "4.0.1";
var version = "5.0.0";
export { name, version };
//# sourceMappingURL=package.json.mjs.map

@@ -62,2 +62,27 @@ import type { RollupCommonJSOptions } from '@rollup/plugin-commonjs';

/**
* Whether to enable built-in input plugins.
*/
enableBuiltInInputPlugins?: {
/**
* @default true
*/
commonjs?: boolean;
/**
* @default true
*/
json?: boolean;
/**
* @default true
*/
nodeExternal?: boolean;
/**
* @default true
*/
nodeResolve?: boolean;
/**
* @default true
*/
typescript?: boolean;
};
/**
* Options for built-in input plugins.

@@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,OAAO,CAAC;QAEvB;;WAEG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;QAEtB;;WAEG;QACH,UAAU,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;IAEF;;OAEG;IACH,yBAAyB,CAAC,EAAE;QACxB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;QACjC,IAAI,CAAC,EAAE,iBAAiB,CAAC;QACzB,YAAY,CAAC,EAAE,gBAAgB,CAAC;QAChC,WAAW,CAAC,EAAE,wBAAwB,CAAC;QACvC,UAAU,CAAC,EAAE,uBAAuB,CAAC;KACxC,CAAC;IAEF;;;;OAIG;IACH,0BAA0B,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,kCAAkC,CAAC,aAAa,CAAC,CAAA;KAAE,CAAC;IAE5F;;;;OAIG;IACH,aAAa,CAAC,EAAE,kCAAkC,CAAC,mBAAmB,CAAC,CAAC;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;CACzD"}

@@ -1,9 +0,2 @@

export declare function isAbsolute(path: string): boolean;
export declare function isRelative(path: string): boolean;
export declare function normalize(path: string): string;
export declare function basename(path: string): string;
export declare function dirname(path: string): string;
export declare function extname(path: string): string;
export declare function relative(from: string, to: string): string;
export declare function resolve(...paths: string[]): string;
//# sourceMappingURL=browser-path.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"browser-path.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/browser-path.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAsBzD;AAED,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAyBlD"}
{"version":3,"file":"browser-path.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/browser-path.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAsBhD"}

@@ -1,1 +0,1 @@

{"version":3,"file":"browser-path.mjs","sources":["../../../src/utils/rollup/browser-path.ts"],"sourcesContent":["const ABSOLUTE_PATH_REGEX = /^(?:\\/|(?:[A-Z]:)?[/\\\\|])/i;\nconst RELATIVE_PATH_REGEX = /^\\.?\\.\\//;\nconst ALL_BACKSLASHES_REGEX = /\\\\/g;\nconst ANY_SLASH_REGEX = /[/\\\\]/;\nconst EXTNAME_REGEX = /\\.[^.]+$/;\n\nexport function isAbsolute(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(path);\n}\n\nexport function isRelative(path: string): boolean {\n return RELATIVE_PATH_REGEX.test(path);\n}\n\nexport function normalize(path: string): string {\n return path.replace(ALL_BACKSLASHES_REGEX, '/');\n}\n\nexport function basename(path: string): string {\n return path.split(ANY_SLASH_REGEX).pop() || '';\n}\n\nexport function dirname(path: string): string {\n const match = /[/\\\\][^/\\\\]*$/.exec(path);\n if (!match) return '.';\n\n const directory = path.slice(0, -match[0].length);\n\n // If `directory` is the empty string, we're at root.\n return directory || '/';\n}\n\nexport function extname(path: string): string {\n const match = EXTNAME_REGEX.exec(basename(path)!);\n return match ? match[0] : '';\n}\n\nexport function relative(from: string, to: string): string {\n const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);\n const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);\n\n if (fromParts[0] === '.') fromParts.shift();\n if (toParts[0] === '.') toParts.shift();\n\n while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {\n fromParts.shift();\n toParts.shift();\n }\n\n while (toParts[0] === '..' && fromParts.length > 0) {\n toParts.shift();\n fromParts.pop();\n }\n\n while (fromParts.pop()) {\n toParts.unshift('..');\n }\n\n return toParts.join('/');\n}\n\nexport function resolve(...paths: string[]): string {\n const firstPathSegment = paths.shift();\n if (!firstPathSegment) {\n return '/';\n }\n let resolvedParts = firstPathSegment.split(ANY_SLASH_REGEX);\n\n for (const path of paths) {\n if (isAbsolute(path)) {\n resolvedParts = path.split(ANY_SLASH_REGEX);\n } else {\n const parts = path.split(ANY_SLASH_REGEX);\n\n while (parts[0] === '.' || parts[0] === '..') {\n const part = parts.shift();\n if (part === '..') {\n resolvedParts.pop();\n }\n }\n\n resolvedParts.push(...parts);\n }\n }\n\n return resolvedParts.join('/');\n}\n"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAG,OAAO;AAkCf,SAAA,QAAQ,CAAC,IAAY,EAAE,EAAU,EAAA;AAC7C,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAC7D,IAAA,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAEzD,IAAA,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,SAAS,CAAC,KAAK,EAAE;AAC3C,IAAA,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,OAAO,CAAC,KAAK,EAAE;IAEvC,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE;QAC9D,SAAS,CAAC,KAAK,EAAE;QACjB,OAAO,CAAC,KAAK,EAAE;;AAGnB,IAAA,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QAChD,OAAO,CAAC,KAAK,EAAE;QACf,SAAS,CAAC,GAAG,EAAE;;AAGnB,IAAA,OAAO,SAAS,CAAC,GAAG,EAAE,EAAE;AACpB,QAAA,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;;AAGzB,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5B;;;;"}
{"version":3,"file":"browser-path.mjs","sources":["../../../src/utils/rollup/browser-path.ts"],"sourcesContent":["const ANY_SLASH_REGEX = /[/\\\\]/;\n\nexport function relative(from: string, to: string) {\n const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);\n const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);\n\n if (fromParts[0] === '.') fromParts.shift();\n if (toParts[0] === '.') toParts.shift();\n\n while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {\n fromParts.shift();\n toParts.shift();\n }\n\n while (toParts[0] === '..' && fromParts.length > 0) {\n toParts.shift();\n fromParts.pop();\n }\n\n while (fromParts.pop()) {\n toParts.unshift('..');\n }\n\n return toParts.join('/');\n}\n"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,OAAO;AAEf,SAAA,QAAQ,CAAC,IAAY,EAAE,EAAU,EAAA;AAC7C,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAC7D,IAAA,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAEzD,IAAA,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,SAAS,CAAC,KAAK,EAAE;AAC3C,IAAA,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,OAAO,CAAC,KAAK,EAAE;IAEvC,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE;QAC9D,SAAS,CAAC,KAAK,EAAE;QACjB,OAAO,CAAC,KAAK,EAAE;;AAGnB,IAAA,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QAChD,OAAO,CAAC,KAAK,EAAE;QACf,SAAS,CAAC,GAAG,EAAE;;AAGnB,IAAA,OAAO,SAAS,CAAC,GAAG,EAAE,EAAE;AACpB,QAAA,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;;AAGzB,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5B;;;;"}

@@ -1,2 +0,2 @@

export declare const bold: import("colorette").Color, cyan: import("colorette").Color, dim: import("colorette").Color, gray: import("colorette").Color, green: import("colorette").Color, red: import("colorette").Color, underline: import("colorette").Color, yellow: import("colorette").Color;
export declare const bold: import("colorette").Color, cyan: import("colorette").Color, dim: import("colorette").Color, green: import("colorette").Color, red: import("colorette").Color;
//# sourceMappingURL=colors.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/colors.ts"],"names":[],"mappings":"AAIA,eAAO,MACH,IAAI,6BACJ,IAAI,6BACJ,GAAG,6BACH,IAAI,6BACJ,KAAK,6BACL,GAAG,6BACH,SAAS,6BACT,MAAM,2BAC8E,CAAC"}
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/colors.ts"],"names":[],"mappings":"AAIA,eAAO,MACH,IAAI,6BACJ,IAAI,6BACJ,GAAG,6BACH,KAAK,6BACL,GAAG,2BACiF,CAAC"}

@@ -5,5 +5,5 @@ import { createColors } from 'colorette';

// @see https://www.npmjs.com/package/chalk
const { bold, cyan, dim, gray, green, red, underline, yellow, } = createColors({ useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR });
const { bold, cyan, dim, green, red, } = createColors({ useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR });
export { bold, cyan, dim, gray, green, red, underline, yellow };
export { bold, cyan, dim, green, red };
//# sourceMappingURL=colors.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"file":"colors.mjs","sources":["../../../src/utils/rollup/colors.ts"],"sourcesContent":["import { createColors } from 'colorette';\n\n// @see https://no-color.org\n// @see https://www.npmjs.com/package/chalk\nexport const {\n bold,\n cyan,\n dim,\n gray,\n green,\n red,\n underline,\n yellow,\n} = createColors({ useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR });\n"],"names":[],"mappings":";;AAEA;AACA;AACa,MAAA,EACT,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,GAAG,EACH,SAAS,EACT,MAAM,GACT,GAAG,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE;;;;"}
{"version":3,"file":"colors.mjs","sources":["../../../src/utils/rollup/colors.ts"],"sourcesContent":["import { createColors } from 'colorette';\n\n// @see https://no-color.org\n// @see https://www.npmjs.com/package/chalk\nexport const {\n bold,\n cyan,\n dim,\n green,\n red,\n} = createColors({ useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR });\n"],"names":[],"mappings":";;AAEA;AACA;AACO,MAAM,EACT,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,GACN,GAAG,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE;;;;"}

@@ -1,1 +0,1 @@

{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAW1C,eAAO,MAAM,MAAM,GAAI,GAAG,YAAY,SAAS,OAAO,EAAE,YAAqD,CAAC;AAC9G,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CA6BpD"}
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAW1C,eAAO,MAAM,MAAM,GAAI,GAAG,YAAY,SAAS,OAAO,EAAE,YAAqD,CAAC;AAC9G,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,QA6B7C"}

@@ -1,1 +0,1 @@

{"version":3,"file":"logging.mjs","sources":["../../../src/utils/rollup/logging.ts"],"sourcesContent":["import type { RollupError } from 'rollup';\n\nimport {\n bold,\n cyan,\n dim,\n red,\n} from './colors';\nimport { relativeId } from './relativeId';\n\n// log to stderr to keep `rollup main.js > bundle.js` from breaking\nexport const stderr = (...parameters: readonly unknown[]) => process.stderr.write(`${parameters.join('')}\\n`);\nexport function handleError(error: RollupError): void {\n const name = error.name || (error.cause as Error)?.name;\n const nameSection = name ? `${name}: ` : '';\n const pluginSection = error.plugin ? `(plugin ${error.plugin}) ` : '';\n const message = `${pluginSection}${nameSection}${error.message}`;\n const outputLines = [bold(red(`[!] ${bold(message.toString())}`))];\n if (error.url) outputLines.push(cyan(error.url));\n if (error.loc) {\n outputLines.push(`${relativeId((error.loc.file || error.id)!)}:${error.loc.line}:${error.loc.column}`);\n } else if (error.id) outputLines.push(relativeId(error.id));\n if (error.frame) outputLines.push(dim(error.frame));\n if (error.stack) outputLines.push(dim(error.stack?.replace(`${nameSection}${error.message}\\n`, '')));\n // ES2022: Error.prototype.cause is optional\n if (error.cause) {\n let cause = error.cause as Error | undefined;\n const causeErrorLines = [];\n let indent = '';\n while (cause) {\n indent += ' ';\n const message = cause.stack || cause;\n causeErrorLines.push(...`[cause] ${message}`.split('\\n').map((line) => `${indent}${line}`));\n cause = cause.cause as Error | undefined;\n }\n\n outputLines.push(dim(causeErrorLines.join('\\n')));\n }\n\n outputLines.push('', '');\n stderr(outputLines.join('\\n'));\n}\n"],"names":[],"mappings":";;;AAUA;AACa,MAAA,MAAM,GAAG,CAAC,GAAG,UAA8B,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,EAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAI,EAAA,CAAA;AACtG,SAAU,WAAW,CAAC,KAAkB,EAAA;IAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAK,KAAK,CAAC,KAAe,EAAE,IAAI;AACvD,IAAA,MAAM,WAAW,GAAG,IAAI,GAAG,CAAG,EAAA,IAAI,CAAI,EAAA,CAAA,GAAG,EAAE;AAC3C,IAAA,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,GAAG,CAAW,QAAA,EAAA,KAAK,CAAC,MAAM,CAAA,EAAA,CAAI,GAAG,EAAE;IACrE,MAAM,OAAO,GAAG,CAAA,EAAG,aAAa,CAAA,EAAG,WAAW,CAAA,EAAG,KAAK,CAAC,OAAO,CAAA,CAAE;AAChE,IAAA,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAO,IAAA,EAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,CAAC,GAAG;QAAE,WAAW,CAAC,IAAI,CAAC,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C,QAAA,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAGrD,IAAA,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IACxB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC;;;;"}
{"version":3,"file":"logging.mjs","sources":["../../../src/utils/rollup/logging.ts"],"sourcesContent":["import type { RollupError } from 'rollup';\n\nimport {\n bold,\n cyan,\n dim,\n red,\n} from './colors';\nimport { relativeId } from './relativeId';\n\n// log to stderr to keep `rollup main.js > bundle.js` from breaking\nexport const stderr = (...parameters: readonly unknown[]) => process.stderr.write(`${parameters.join('')}\\n`);\nexport function handleError(error: RollupError) {\n const name = error.name || (error.cause as Error)?.name;\n const nameSection = name ? `${name}: ` : '';\n const pluginSection = error.plugin ? `(plugin ${error.plugin}) ` : '';\n const message = `${pluginSection}${nameSection}${error.message}`;\n const outputLines = [bold(red(`[!] ${bold(message.toString())}`))];\n if (error.url) outputLines.push(cyan(error.url));\n if (error.loc) {\n outputLines.push(`${relativeId((error.loc.file || error.id)!)}:${error.loc.line}:${error.loc.column}`);\n } else if (error.id) outputLines.push(relativeId(error.id));\n if (error.frame) outputLines.push(dim(error.frame));\n if (error.stack) outputLines.push(dim(error.stack?.replace(`${nameSection}${error.message}\\n`, '')));\n // ES2022: Error.prototype.cause is optional\n if (error.cause) {\n let cause = error.cause as Error | undefined;\n const causeErrorLines = [];\n let indent = '';\n while (cause) {\n indent += ' ';\n const message = cause.stack || cause;\n causeErrorLines.push(...`[cause] ${message}`.split('\\n').map((line) => `${indent}${line}`));\n cause = cause.cause as Error | undefined;\n }\n\n outputLines.push(dim(causeErrorLines.join('\\n')));\n }\n\n outputLines.push('', '');\n stderr(outputLines.join('\\n'));\n}\n"],"names":[],"mappings":";;;AAUA;AACa,MAAA,MAAM,GAAG,CAAC,GAAG,UAA8B,KAAK,OAAO,CAAC,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,KAAK,CAAC,CAAC;IACnD,IAAI,KAAK,CAAC,KAAK;QAAE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,WAAW,CAAA,EAAG,KAAK,CAAC,OAAO,CAAA,EAAA,CAAI,EAAE,EAAE,CAAC,CAAC,CAAC;;AAEpG,IAAA,IAAI,KAAK,CAAC,KAAK,EAAE;AACb,QAAA,IAAI,KAAK,GAAG,KAAK,CAAC,KAA0B;QAC5C,MAAM,eAAe,GAAG,EAAE;QAC1B,IAAI,MAAM,GAAG,EAAE;QACf,OAAO,KAAK,EAAE;YACV,MAAM,IAAI,IAAI;AACd,YAAA,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK;YACpC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAA,EAAG,MAAM,CAAA,EAAG,IAAI,CAAA,CAAE,CAAC,CAAC;AAC3F,YAAA,KAAK,GAAG,KAAK,CAAC,KAA0B;;AAG5C,QAAA,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAGrD,IAAA,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IACxB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC;;;;"}

@@ -1,5 +0,3 @@

export declare function isAbsolute(path: string): boolean;
export declare function isRelative(path: string): boolean;
export declare function normalize(path: string): string;
export { basename, dirname, extname, relative, resolve, } from 'node:path';
export { resolve } from 'node:path';
export declare const isAbsolute: (path: string) => boolean;
//# sourceMappingURL=path.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/path.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAID,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,OAAO,EACH,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,GACV,MAAM,WAAW,CAAC"}
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,YAAmC,CAAC"}
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
function isAbsolute(path) {
return ABSOLUTE_PATH_REGEX.test(path);
}
const isAbsolute = (path) => ABSOLUTE_PATH_REGEX.test(path);
export { isAbsolute };
//# sourceMappingURL=path.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"file":"path.mjs","sources":["../../../src/utils/rollup/path.ts"],"sourcesContent":["const ABSOLUTE_PATH_REGEX = /^(?:\\/|(?:[A-Z]:)?[/\\\\|])/i;\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst RELATIVE_PATH_REGEX = /^\\.?\\.(\\/|$)/;\n\nexport function isAbsolute(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(path);\n}\n\nexport function isRelative(path: string): boolean {\n return RELATIVE_PATH_REGEX.test(path);\n}\n\nconst BACKSLASH_REGEX = /\\\\/g;\n\nexport function normalize(path: string): string {\n return path.replace(BACKSLASH_REGEX, '/');\n}\n\nexport {\n basename,\n dirname,\n extname,\n relative,\n resolve,\n} from 'node:path';\n"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,4BAA4B;AAIlD,SAAU,UAAU,CAAC,IAAY,EAAA;AACnC,IAAA,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;AACzC;;;;"}
{"version":3,"file":"path.mjs","sources":["../../../src/utils/rollup/path.ts"],"sourcesContent":["export { resolve } from 'node:path';\n\nconst ABSOLUTE_PATH_REGEX = /^(?:\\/|(?:[A-Z]:)?[/\\\\|])/i;\n\nexport const isAbsolute = (path: string) => ABSOLUTE_PATH_REGEX.test(path);\n"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG,4BAA4B;AAEjD,MAAM,UAAU,GAAG,CAAC,IAAY,KAAK,mBAAmB,CAAC,IAAI,CAAC,IAAI;;;;"}

@@ -1,5 +0,2 @@

export declare function getAliasName(id: string): string;
export declare function relativeId(id: string): string;
export declare function isPathFragment(name: string): boolean;
export declare function getImportPath(importerId: string, targetPath: string, stripJsExtension: boolean, ensureFileName: boolean): string;
//# sourceMappingURL=relativeId.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"relativeId.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/relativeId.ts"],"names":[],"mappings":"AAUA,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD;AAKD,wBAAgB,aAAa,CACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,OAAO,EACzB,cAAc,EAAE,OAAO,GACxB,MAAM,CAoBR"}
{"version":3,"file":"relativeId.d.ts","sourceRoot":"","sources":["../../../src/utils/rollup/relativeId.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,UAGpC"}

@@ -1,1 +0,1 @@

{"version":3,"file":"relativeId.mjs","sources":["../../../src/utils/rollup/relativeId.ts"],"sourcesContent":["import { relative } from './browser-path';\nimport {\n basename,\n dirname,\n extname,\n isAbsolute,\n normalize,\n resolve,\n} from './path';\n\nexport function getAliasName(id: string): string {\n const base = basename(id);\n return base.slice(0, Math.max(0, base.length - extname(id).length));\n}\n\nexport function relativeId(id: string): string {\n if (!isAbsolute(id)) return id;\n return relative(resolve(), id);\n}\n\nexport function isPathFragment(name: string): boolean {\n // starting with \"/\", \"./\", \"../\", \"C:/\"\n return name.startsWith('/') || (name.startsWith('.') && (name[1] === '/' || name[1] === '.')) || isAbsolute(name);\n}\n\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst UPPER_DIR_REGEX = /^(\\.\\.\\/)*\\.\\.$/;\n\nexport function getImportPath(\n importerId: string,\n targetPath: string,\n stripJsExtension: boolean,\n ensureFileName: boolean,\n): string {\n while (targetPath.startsWith('../')) {\n targetPath = targetPath.slice(3);\n importerId = `_/${importerId}`;\n }\n let relativePath = normalize(relative(dirname(importerId), targetPath));\n if (stripJsExtension && relativePath.endsWith('.js')) {\n relativePath = relativePath.slice(0, -3);\n }\n if (ensureFileName) {\n if (relativePath === '') return `../${basename(targetPath)}`;\n if (UPPER_DIR_REGEX.test(relativePath)) {\n return [\n ...relativePath.split('/'),\n '..',\n basename(targetPath),\n ].join('/');\n }\n }\n return relativePath ? relativePath.startsWith('..') ? relativePath : `./${relativePath}` : '.';\n}\n"],"names":[],"mappings":";;;;AAeM,SAAU,UAAU,CAAC,EAAU,EAAA;AACjC,IAAA,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;AAAE,QAAA,OAAO,EAAE;AAC9B,IAAA,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC;AAClC;;;;"}
{"version":3,"file":"relativeId.mjs","sources":["../../../src/utils/rollup/relativeId.ts"],"sourcesContent":["import { relative } from './browser-path';\nimport {\n isAbsolute,\n resolve,\n} from './path';\n\nexport function relativeId(id: string) {\n if (!isAbsolute(id)) return id;\n return relative(resolve(), id);\n}\n"],"names":[],"mappings":";;;;AAMM,SAAU,UAAU,CAAC,EAAU,EAAA;AACjC,IAAA,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;AAAE,QAAA,OAAO,EAAE;AAC9B,IAAA,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC;AAClC;;;;"}
{
"name": "ts-project-builder",
"type": "module",
"version": "4.0.1",
"description": "A powerful TypeScript project builder supporting multiple output formats, automatic cleaning, and customizable plugins.",
"version": "5.0.0",
"description": "Rollup-based TypeScript builder with multi-format output and built-in common plugins.",
"author": "kiki-kanri",

@@ -13,10 +13,17 @@ "license": "MIT",

"keywords": [
"build tool",
"build-tool",
"builder",
"customizable",
"minification",
"module formats",
"bundler",
"cjs",
"declaration",
"esm",
"multi-format",
"package-builder",
"plugin",
"rollup",
"typescript"
],
"sideEffects": [
"./dist/cli.mjs"
],
"exports": {

@@ -29,3 +36,5 @@ ".": {

"types": "./dist/index.d.ts",
"bin": "./dist/cli.mjs",
"bin": {
"ts-project-builder": "dist/cli.mjs"
},
"files": [

@@ -53,15 +62,17 @@ "./dist",

"colorette": "^2.0.20",
"is-glob": "^4.0.3",
"lodash-es": "^4.17.21",
"pretty-ms": "^9.2.0",
"rollup": "^4.39.0",
"rollup": "^4.40.0",
"rollup-plugin-esbuild": "^6.2.1",
"rollup-plugin-node-externals": "^8.0.0",
"type-fest": "^4.39.1"
"type-fest": "^4.40.0"
},
"devDependencies": {
"@kikiutils/changelogen": "^0.8.0",
"@kikiutils/eslint-config": "^0.12.0",
"@kikiutils/tsconfigs": "^4.0.0",
"@kikiutils/eslint-config": "^0.12.2",
"@kikiutils/tsconfigs": "^4.1.1",
"@types/is-glob": "^4.0.4",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.14.0",
"@types/node": "^22.14.1",
"jiti": "^2.4.2",

@@ -68,0 +79,0 @@ "tslib": "^2.8.1"

+128
-94

@@ -7,3 +7,3 @@ # ts-project-builder

A powerful TypeScript project builder supporting multiple output formats, automatic cleaning, and customizable plugins.
Rollup-based TypeScript builder with multi-format output and built-in common plugins.

@@ -24,9 +24,9 @@ - [✨ Release Notes](./CHANGELOG.md)

## Environment Requirements
## Requirements
- Node.js version 18.12 or higher
- **Node.js** `>= 18.12.1`
## Installation
Add dependency (example using pnpm).
Using [pnpm](https://pnpm.io):

@@ -37,17 +37,17 @@ ```bash

You can also use yarn, npm, or bun to add the dependency.
You can also use `yarn`, `npm`, or `bun`.
That's it! You're ready to use this package for your project. Check out the [usage instructions](#usage) below ✨.
## Usage
Use the `-h` flag to view usage and all available flags:
Use the `-h` flag to view usage and all available options:
```bash
ts-project-builder -h # package.json script
npx ts-project-builder -h # terminal
ts-project-builder -h # from package.json script
npx ts-project-builder -h # directly from terminal
```
Here is the most basic usage, using `./src/index.ts` as the entry point:
### Basic Usage
Run the builder with a single entry file:
```bash

@@ -57,13 +57,13 @@ ts-project-builder ./src/index.ts

By default, it will generate files in both CJS and ESM formats. The output directory is `./dist`, with file extensions `cjs` and `mjs` respectively.
By default, it outputs both CommonJS (`.cjs`) and ESM (`.mjs`) formats to the `./dist` directory.
The input path supports Glob Patterns. Before building, the paths will be processed using glob. Please use quotation marks when specifying the paths.
### Multiple Inputs and Format Control
You can also specify multiple inputs simultaneously and designate the output formats:
You can pass multiple inputs and specify desired output formats:
```bash
# amd, cjs, esm
# Output as amd, cjs, and esm
ts-project-builder ./src/cli.ts ./src/index.ts -f amd,cjs,esm
# cjs
# Use glob patterns (wrap in quotes!)
ts-project-builder './src/**/*.ts' -f cjs

@@ -73,6 +73,8 @@ ```

> [!IMPORTANT]
> Ensure that input parameters are specified before any other flags to avoid incorrect parsing.
> Input files must be listed **before** any flags to ensure correct parsing.
By default, different formats will generate files with different extensions, as shown in the table below:
### Format Extensions
Each format will generate files with the following extensions:
| Format | Extension |

@@ -91,4 +93,6 @@ | -------- | --------- |

This builder includes the following Rollup input plugins (listed in execution order):
### Built-in Rollup Plugins
This builder uses the following Rollup input plugins (in order):
- [rollup-plugin-node-externals](https://github.com/Septh/rollup-plugin-node-externals)

@@ -100,17 +104,22 @@ - [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve)

For more flags and usage details, please refer to [flags](#flags).
For more options and advanced configuration, see the [CLI Flags](#cli-flags) section.
## Flags
## CLI Flags
### --clean
### `--clean`
Clean the target directory or files before output.
Cleans the output directory or files **right before writing output files**.
If the flag is used without any value, all formats will be enabled. If specific formats are provided, only the specified formats will be enabled.
- If used without a value, **all formats** will be cleaned.
- If specific formats are provided, only output files for the specified formats will be cleaned.
- If the build fails, nothing will be cleaned.
- Files or folders to be cleaned are determined by their output paths.
👉 If multiple formats (e.g. CJS and ESM) share the same output directory (like `./dist`), using `--clean cjs` will still clean the **entire directory**.
```bash
# All formats will clean the target directory or files before output
# Clean all formats before output
ts-project-builder ./src/index.ts --clean
# Only the CJS format will clean the target directory or files before output
# Clean only CJS format before output
ts-project-builder ./src/index.ts --clean cjs

@@ -120,114 +129,133 @@ ```

> [!IMPORTANT]
> An error will be thrown if the path to be cleaned is not under the directory where the builder is running. To force cleaning, please use [this flag](#--force-clean).
> An error will be thrown if the path to be cleaned is outside the current working directory.
>
> To bypass this check, use [`--force-clean`](#--force-clean).
### -c, --config
### `-c`, `--config`
The path to the config file. Only `.mjs` files are accepted.
Specifies the path to the config file.
Only `.mjs` files are supported — the file must be an **ES module**, as it is loaded using `await import`.
**Default**: `./ts-project-builder.config.mjs`
### --dirs
### `--force-clean`
The output directory paths. Refer to the [Rollup documentation](https://rollupjs.org/configuration-options/#output-dir) for more details.
Forcibly cleans the target directory or files **before output**, even if they are outside the current working directory.
**Default**: `./dist`
- Must be used **together with** the [`--clean`](#--clean) flag.
- Uses the same syntax and format as [`--clean`](#--clean).
You can specify different output paths for different formats, separated by commas and designated using the `<format>=[path]` method. If there is no `<format>=` and only a path is provided, that path will be used as the common value for all formats.
> [!CAUTION]
>
> Use this flag with caution — it can delete files outside your project folder.
```bash
# All formats are output to ./dist
ts-project-builder ./src/index.ts --dirs ./dist
### `-f`, `--formats`
# CJS output to ./cjs, others output to ./dist
ts-project-builder ./src/index.ts --dirs cjs=./cjs
Specifies the output formats.
# ESM output to ./dist, others output to ./output
ts-project-builder ./src/index.ts --dirs ./output,esm=./dist
```
Multiple formats can be provided, separated by commas. Duplicate entries will be ignored.
### --exts
**Default**: `cjs,esm`
The output file extensions.
### `-m`, `--minify`
If not set, or if the corresponding format is not specified, the default file extension from the table above will be used.
Minifies the output using the `minify` option from [`rollup-plugin-esbuild`](https://github.com/egoist/rollup-plugin-esbuild).
The priority is: specified value > specified common value > table value.
- Uses the same configuration syntax as [`--clean`](#--clean).
The configuration method is the same as for the [`--dirs`](#--dirs) flag.
### `--out-dirs`
```bash
# CJS uses cjs, others use js
ts-project-builder ./src/index.ts --exts cjs=cjs,js
Specifies the output directory path(s).
# ESM uses js, others use the corresponding values from the table
ts-project-builder ./src/index.ts --exts esm=js
```
See [Rollup's `output.dir` documentation](https://rollupjs.org/configuration-options/#output-dir) for more details.
### --files
**Default**: `./dist`
The output file paths. Refer to the [Rollup documentation](https://rollupjs.org/configuration-options/#output-file) for more details.
You can define separate output directories for different formats using `<format>=<path>`, separated by commas.
If this flag is set, it will override the [`--dirs`](#--dirs) flag.
- If only a path is provided (e.g. `./dist`), it will be used for **all formats**.
- If format-specific paths are provided, those formats will output to the corresponding directories.
The configuration method is the same as for the [`--dirs`](#--dirs) flag.
```bash
# CJS output to ./cjs.cjs, others output to the ./dist directory
ts-project-builder ./src/index.ts --files cjs=./cjs.cjs
# All formats output to ./dist
ts-project-builder ./src/index.ts --out-dirs ./dist
# CJS output to ./cjs/index.cjs, ESM output to the ./esm directory, others output to the ./dist directory
ts-project-builder ./src/index.ts --dirs cjs=./cjs-dist,esm=./esm --files cjs=./cjs/index.cjs
# CJS outputs to ./cjs, all others use default ./dist
ts-project-builder ./src/index.ts --out-dirs cjs=./cjs
# ESM outputs to ./dist, all others to ./output
ts-project-builder ./src/index.ts --out-dirs ./output,esm=./dist
```
### --force-clean
### `--out-exts`
Force clean the target directory or files before output. Must be used together with the [`--clean`](#--clean) flag.
Specifies the output file extensions for each format.
The configuration method is the same as for the [`--clean`](#--clean) flag.
- If not set, or if a specific format is not listed, the default extension from the [format table](#format-extensions) will be used.
- The priority order is **explicit per-format value > common extension value > default table value**.
- The syntax is the same as [`--out-dirs`](#--out-dirs), using `<format>=<ext>` and separating multiple values with commas.
> [!CAUTION]
> Use this flag with caution.
```bash
# CJS uses `.cjs`, others use `.js`
ts-project-builder ./src/index.ts --out-exts cjs=cjs,js
### -f, --formats
# ESM uses `.js`, others use default extensions from the format table
ts-project-builder ./src/index.ts --out-exts esm=js
```
The output formats. Can accept multiple formats, but duplicates will only be considered once.
### `--out-files`
**Default**: `cjs,esm`
Specifies exact output file paths.
### -m, --minify
See the [Rollup documentation](https://rollupjs.org/configuration-options/#output-file) for more details.
Minify the code using the `minify` feature provided by [`rollup-plugin-esbuild`](https://github.com/egoist/rollup-plugin-esbuild) before the final output.
- If this flag is set, it will override the [`--out-dirs`](#--out-dirs) flag.
- The format and syntax are the same as [`--out-dirs`](#--out-dirs), using `<format>=<path>`.
The configuration method is the same as for the [`--clean`](#--clean) flag.
```bash
# CJS outputs to ./cjs.cjs, all other formats use ./dist
ts-project-builder ./src/index.ts --out-files cjs=./cjs.cjs
### --preserve-modules
# - CJS outputs to ./cjs/index.cjs (from --out-files)
# - ESM outputs to ./esm (from --out-dirs)
# - All others output to ./dist (default)
ts-project-builder ./src/index.ts --out-dirs cjs=./cjs-dist,esm=./esm --out-files cjs=./cjs/index.cjs
```
Refer to the [Rollup documentation](https://rollupjs.org/configuration-options/#output-preservemodules) for more details.
### `--preserve-modules`
The configuration method is the same as for the [`--clean`](#--clean) flag.
Preserves the module structure in the output (i.e., does not bundle into a single file).
### --preserve-modules-roots
See [Rollup documentation](https://rollupjs.org/configuration-options/#output-preservemodules) for details.
Refer to the [Rollup documentation](https://rollupjs.org/configuration-options/#output-preservemodulesroot) for more details.
- Uses the same configuration syntax as [`--clean`](#--clean).
**Default**: `./src`
### `--preserve-modules-roots`
The configuration method is the same as for the [`--dirs`](#--dirs) flag.
Specifies the root directory for preserved modules.
### --sourcemaps
See [Rollup documentation](https://rollupjs.org/configuration-options/#output-preservemodulesroot) for details.
Refer to the [Rollup documentation](https://rollupjs.org/configuration-options/#output-sourcemap) for more details.
- **Default**: `./src`
- Uses the same configuration syntax as [`--out-dirs`](#--out-dirs).
The configuration method is the same as for the [`--dirs`](#--dirs) flag.
### `--sourcemaps`
However, the settings are different, using true, false, inline and hidden settings.
Enables or configures sourcemap output.
See the [Rollup documentation](https://rollupjs.org/configuration-options/#output-sourcemap) for more details.
- Supports values: `true`, `false`, `inline`, and `hidden`.
- Uses the same configuration syntax as [`--out-dirs`](#--out-dirs).
- If no format is specified, the setting applies to **all formats**.
```bash
# All formats are enabled (use the 'true' setting).
# All formats use the 'true' setting (sourcemaps enabled)
ts-project-builder ./src/index.ts --sourcemaps
# In addition to ESM's use of inline, the rest of the format closure.
# ESM format uses 'inline', all others use 'false' (sourcemaps disabled)
ts-project-builder ./src/index.ts --sourcemaps false,esm=inline
# Close ESM format only.
# Only disable sourcemaps for the ESM format
ts-project-builder ./src/index.ts --sourcemaps esm=false

@@ -238,9 +266,13 @@ ```

If you need to pass options to built-in plugins, modify the output of specific formats, or use other options, you can use a config file.
If you need to customize plugin behavior, modify per-format output, or access advanced options, you can use a configuration file.
By default, the build process will attempt to read the `./ts-project-builder.config.mjs` file. You can use the [`-c`](#-c---config) flag to specify the config file path.
By default, the builder looks for `./ts-project-builder.config.mjs`.
After creating the file, fill in the following code:
You can override this using the [`-c`](#-c---config) flag.
```javascript
### Example
Create a config file and start with the following template:
```js
import { defineConfig } from 'ts-project-builder';

@@ -251,8 +283,10 @@

For detailed config instructions, please refer to the `Config` interface in [this file](./src/types.ts).
For full type definitions and configuration options, refer to the `Config` interface in [./src/types.ts](./src/types.ts).
## Direct Import Usage
You can also directly import the `Builder` class in your code, create a builder instance, and execute the `builder.build` method.
You can also use `ts-project-builder` as a library by directly importing the `Builder` class.
Create a builder instance and call the `build()` method:
```typescript

@@ -267,4 +301,4 @@ import { Builder } from 'ts-project-builder';

'esm'
])
}
]),
},
});

@@ -271,0 +305,0 @@

@@ -1,4 +0,6 @@

import { globSync } from 'node:fs';
import { rm } from 'node:fs/promises';
import {
glob,
rm,
} from 'node:fs/promises';
import {
isAbsolute,

@@ -14,2 +16,4 @@ relative,

import typescript from '@rollup/plugin-typescript';
// @ts-expect-error Ignore this error.
import isGlob from 'is-glob';
import {

@@ -60,3 +64,3 @@ cloneDeep,

export const defaultOutputPreserveModulesRoot = './src' as const;
const outputFormatToExtMap = Object.freeze<Record<ModuleFormat, string>>({
const outputFormatToExtMap: Readonly<Record<ModuleFormat, string>> = {
amd: 'amd.js',

@@ -72,3 +76,3 @@ cjs: 'cjs',

umd: 'umd.js',
});
};

@@ -106,2 +110,28 @@ export class Builder {

#prepareInputPlugins(config: Config) {
const plugins: Plugin[] = config.additionalInputPlugins?.beforeBuiltIns || [];
if (config.enableBuiltInInputPlugins?.nodeExternal !== false) {
plugins.push(nodeExternals(config.builtInInputPluginOptions?.nodeExternal));
}
if (config.enableBuiltInInputPlugins?.nodeResolve !== false) {
plugins.push(nodeResolve(config.builtInInputPluginOptions?.nodeResolve));
}
if (config.enableBuiltInInputPlugins?.commonjs !== false) {
plugins.push(commonjs(config.builtInInputPluginOptions?.commonjs));
}
if (config.enableBuiltInInputPlugins?.json !== false) {
plugins.push(json(config.builtInInputPluginOptions?.json));
}
if (config.enableBuiltInInputPlugins?.typescript !== false) {
plugins.push(typescript(config.builtInInputPluginOptions?.typescript));
}
plugins.push(...config.additionalInputPlugins?.afterBuiltIns || []);
return plugins;
}
async build() {

@@ -119,16 +149,17 @@ stderr(cyan('Starting build...'));

const inputFiles = await Promise.all(
[...new Set(this.#options.inputs)].map(async (input) => {
if (!isGlob(input, { strict: false })) return input;
const files = [];
for await (const file of glob(input)) files.push(file);
if (!files.length) console.warn(`⚠️ No files matched for glob pattern: ${input}`);
return files;
}),
);
const logOutputTargetsStrings: string[] = [];
const rollupInputPlugins: Plugin[] = [
...config.additionalInputPlugins?.beforeBuiltIns || [],
nodeExternals(config.builtInInputPluginOptions?.nodeExternal),
nodeResolve(config.builtInInputPluginOptions?.nodeResolve),
commonjs(config.builtInInputPluginOptions?.commonjs),
json(config.builtInInputPluginOptions?.json),
typescript(config.builtInInputPluginOptions?.typescript),
...config.additionalInputPlugins?.afterBuiltIns || [],
];
const rollupInputPlugins = this.#prepareInputPlugins(config);
const rollupOptions: RollupOptions = {
...config.rollupOptions,
input: [...new Set(this.#options.inputs)].map((input) => globSync(input)).flat().sort(),
input: [...new Set(inputFiles.flat())].sort(),
};

@@ -135,0 +166,0 @@

@@ -44,15 +44,2 @@ import { cli } from 'cleye';

},
dirs: {
default: defaultOutputDir,
description: 'The output directory paths.',
type: String,
},
exts: {
description: 'The output file extensions.',
type: String,
},
files: {
description: 'The output file paths.',
type: String,
},
forceClean: {

@@ -73,2 +60,15 @@ description: 'Force clean the target directory or files before output.',

},
outDirs: {
default: defaultOutputDir,
description: 'The output directory paths.',
type: String,
},
outExts: {
description: 'The output file extensions.',
type: String,
},
outFiles: {
description: 'The output file paths.',
type: String,
},
preserveModules: { type: BooleanOrModuleFormats },

@@ -98,5 +98,5 @@ preserveModulesRoots: {

clean: args.flags.clean,
dirs: parseCliArgString<NonNullableBuilderOutputOptions['dirs']>(args.flags.dirs),
exts: parseCliArgString<NonNullableBuilderOutputOptions['exts']>(args.flags.exts || ''),
files: parseCliArgString<NonNullableBuilderOutputOptions['files']>(args.flags.files || ''),
dirs: parseCliArgString<NonNullableBuilderOutputOptions['dirs']>(args.flags.outDirs),
exts: parseCliArgString<NonNullableBuilderOutputOptions['exts']>(args.flags.outExts || ''),
files: parseCliArgString<NonNullableBuilderOutputOptions['files']>(args.flags.outFiles || ''),
forceClean: args.flags.forceClean,

@@ -106,4 +106,5 @@ formats: new Set(args.flags.formats.split(',') as ModuleFormat[]),

preserveModules: args.flags.preserveModules,
// eslint-disable-next-line style/max-len
preserveModulesRoots: parseCliArgString<NonNullableBuilderOutputOptions['preserveModulesRoots']>(args.flags.preserveModulesRoots),
preserveModulesRoots: parseCliArgString<NonNullableBuilderOutputOptions['preserveModulesRoots']>(
args.flags.preserveModulesRoots,
),
sourcemaps: (() => {

@@ -110,0 +111,0 @@ if (args.flags.sourcemaps === undefined) return;

@@ -75,2 +75,32 @@ import type { RollupCommonJSOptions } from '@rollup/plugin-commonjs';

/**
* Whether to enable built-in input plugins.
*/
enableBuiltInInputPlugins?: {
/**
* @default true
*/
commonjs?: boolean;
/**
* @default true
*/
json?: boolean;
/**
* @default true
*/
nodeExternal?: boolean;
/**
* @default true
*/
nodeResolve?: boolean;
/**
* @default true
*/
typescript?: boolean;
};
/**
* Options for built-in input plugins.

@@ -77,0 +107,0 @@ */

@@ -1,39 +0,4 @@

const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
const RELATIVE_PATH_REGEX = /^\.?\.\//;
const ALL_BACKSLASHES_REGEX = /\\/g;
const ANY_SLASH_REGEX = /[/\\]/;
const EXTNAME_REGEX = /\.[^.]+$/;
export function isAbsolute(path: string): boolean {
return ABSOLUTE_PATH_REGEX.test(path);
}
export function isRelative(path: string): boolean {
return RELATIVE_PATH_REGEX.test(path);
}
export function normalize(path: string): string {
return path.replace(ALL_BACKSLASHES_REGEX, '/');
}
export function basename(path: string): string {
return path.split(ANY_SLASH_REGEX).pop() || '';
}
export function dirname(path: string): string {
const match = /[/\\][^/\\]*$/.exec(path);
if (!match) return '.';
const directory = path.slice(0, -match[0].length);
// If `directory` is the empty string, we're at root.
return directory || '/';
}
export function extname(path: string): string {
const match = EXTNAME_REGEX.exec(basename(path)!);
return match ? match[0] : '';
}
export function relative(from: string, to: string): string {
export function relative(from: string, to: string) {
const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);

@@ -61,28 +26,1 @@ const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);

}
export function resolve(...paths: string[]): string {
const firstPathSegment = paths.shift();
if (!firstPathSegment) {
return '/';
}
let resolvedParts = firstPathSegment.split(ANY_SLASH_REGEX);
for (const path of paths) {
if (isAbsolute(path)) {
resolvedParts = path.split(ANY_SLASH_REGEX);
} else {
const parts = path.split(ANY_SLASH_REGEX);
while (parts[0] === '.' || parts[0] === '..') {
const part = parts.shift();
if (part === '..') {
resolvedParts.pop();
}
}
resolvedParts.push(...parts);
}
}
return resolvedParts.join('/');
}

@@ -9,7 +9,4 @@ import { createColors } from 'colorette';

dim,
gray,
green,
red,
underline,
yellow,
} = createColors({ useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR });

@@ -13,3 +13,3 @@ import type { RollupError } from 'rollup';

export const stderr = (...parameters: readonly unknown[]) => process.stderr.write(`${parameters.join('')}\n`);
export function handleError(error: RollupError): void {
export function handleError(error: RollupError) {
const name = error.name || (error.cause as Error)?.name;

@@ -16,0 +16,0 @@ const nameSection = name ? `${name}: ` : '';

@@ -0,25 +1,5 @@

export { resolve } from 'node:path';
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
// eslint-disable-next-line regexp/no-unused-capturing-group
const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
export function isAbsolute(path: string): boolean {
return ABSOLUTE_PATH_REGEX.test(path);
}
export function isRelative(path: string): boolean {
return RELATIVE_PATH_REGEX.test(path);
}
const BACKSLASH_REGEX = /\\/g;
export function normalize(path: string): string {
return path.replace(BACKSLASH_REGEX, '/');
}
export {
basename,
dirname,
extname,
relative,
resolve,
} from 'node:path';
export const isAbsolute = (path: string) => ABSOLUTE_PATH_REGEX.test(path);
import { relative } from './browser-path';
import {
basename,
dirname,
extname,
isAbsolute,
normalize,
resolve,
} from './path';
export function getAliasName(id: string): string {
const base = basename(id);
return base.slice(0, Math.max(0, base.length - extname(id).length));
}
export function relativeId(id: string): string {
export function relativeId(id: string) {
if (!isAbsolute(id)) return id;
return relative(resolve(), id);
}
export function isPathFragment(name: string): boolean {
// starting with "/", "./", "../", "C:/"
return name.startsWith('/') || (name.startsWith('.') && (name[1] === '/' || name[1] === '.')) || isAbsolute(name);
}
// eslint-disable-next-line regexp/no-unused-capturing-group
const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
export function getImportPath(
importerId: string,
targetPath: string,
stripJsExtension: boolean,
ensureFileName: boolean,
): string {
while (targetPath.startsWith('../')) {
targetPath = targetPath.slice(3);
importerId = `_/${importerId}`;
}
let relativePath = normalize(relative(dirname(importerId), targetPath));
if (stripJsExtension && relativePath.endsWith('.js')) {
relativePath = relativePath.slice(0, -3);
}
if (ensureFileName) {
if (relativePath === '') return `../${basename(targetPath)}`;
if (UPPER_DIR_REGEX.test(relativePath)) {
return [
...relativePath.split('/'),
'..',
basename(targetPath),
].join('/');
}
}
return relativePath ? relativePath.startsWith('..') ? relativePath : `./${relativePath}` : '.';
}