ts-project-builder
Version:
Rollup-based TypeScript builder with multi-format output and built-in common plugins.
1 lines • 19.2 kB
Source Map (JSON)
{"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';\nimport * as _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 isGlob = 'default' in _isGlob ? _isGlob.default as typeof _isGlob : _isGlob;\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((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":";;;;;;;;;;;;;;;;;AA6CA,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,MAAM,GAAG,SAAS,IAAI,OAAO,GAAG,OAAO,CAAC,OAAyB,GAAG,OAAO;AACjF,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;AAChB,IAAA,eAAe;AACf,IAAA,QAAQ;AAER,IAAA,WAAA,CAAY,OAAuB,EAAA;AAC/B,QAAA,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;AAC5B,QAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;AAClE,QAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;A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