Download tsdx/src/createBuildConfigs.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/createBuildConfigs.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/createBuildConfigs.ts
-
curl -L -o createBuildConfigs.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/createBuildConfigs.ts
2.27 kB
| import { RollupOptions, OutputOptions } from 'rollup'; | |
| import * as fs from 'fs-extra'; | |
| import { concatAllArray } from 'jpjs'; | |
| import { paths } from './constants'; | |
| import { TsdxOptions, NormalizedOpts } from './types'; | |
| import { createRollupConfig } from './createRollupConfig'; | |
| // check for custom tsdx.config.js | |
| let tsdxConfig = { | |
| rollup(config: RollupOptions, _options: TsdxOptions): RollupOptions { | |
| return config; | |
| }, | |
| }; | |
| if (fs.existsSync(paths.appConfig)) { | |
| tsdxConfig = require(paths.appConfig); | |
| } | |
| export async function createBuildConfigs( | |
| opts: NormalizedOpts | |
| ): Promise<Array<RollupOptions & { output: OutputOptions }>> { | |
| const allInputs = concatAllArray( | |
| opts.input.map((input: string) => | |
| createAllFormats(opts, input).map( | |
| (options: TsdxOptions, index: number) => ({ | |
| ...options, | |
| // We want to know if this is the first run for each entryfile | |
| // for certain plugins (e.g. css) | |
| writeMeta: index === 0, | |
| }) | |
| ) | |
| ) | |
| ); | |
| return await Promise.all( | |
| allInputs.map(async (options: TsdxOptions, index: number) => { | |
| // pass the full rollup config to tsdx.config.js override | |
| const config = await createRollupConfig(options, index); | |
| return tsdxConfig.rollup(config, options); | |
| }) | |
| ); | |
| } | |
| function createAllFormats( | |
| opts: NormalizedOpts, | |
| input: string | |
| ): [TsdxOptions, ...TsdxOptions[]] { | |
| return [ | |
| opts.format.includes('cjs') && { | |
| ...opts, | |
| format: 'cjs', | |
| env: 'development', | |
| input, | |
| }, | |
| opts.format.includes('cjs') && { | |
| ...opts, | |
| format: 'cjs', | |
| env: 'production', | |
| input, | |
| }, | |
| opts.format.includes('esm') && { ...opts, format: 'esm', input }, | |
| opts.format.includes('umd') && { | |
| ...opts, | |
| format: 'umd', | |
| env: 'development', | |
| input, | |
| }, | |
| opts.format.includes('umd') && { | |
| ...opts, | |
| format: 'umd', | |
| env: 'production', | |
| input, | |
| }, | |
| opts.format.includes('system') && { | |
| ...opts, | |
| format: 'system', | |
| env: 'development', | |
| input, | |
| }, | |
| opts.format.includes('system') && { | |
| ...opts, | |
| format: 'system', | |
| env: 'production', | |
| input, | |
| }, | |
| ].filter(Boolean) as [TsdxOptions, ...TsdxOptions[]]; | |
| } | |