Skip to content

Commit

Permalink
feat: added ability to filter files for each build
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrison Ifeanyichukwu authored and Harrison Ifeanyichukwu committed Mar 21, 2020
1 parent 18b121f commit dfabab0
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 230 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@rollup/plugin-json": "4.0.0",
"@rollup/plugin-node-resolve": "7.0.0",
"@teclone/node-utils": "1.0.4",
"@teclone/utils": "2.14.3",
"@teclone/utils": "2.16.1",
"args": "5.0.1",
"chalk": "3.0.0",
"rollup": "1.27.9",
Expand Down
157 changes: 30 additions & 127 deletions src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ export interface CommonConfig {
*/
outDir?: string;

/**
* defines specific string of file patterns to process for the build
*/
include?: (string | RegExp)[];

/**
* defines specific string of file patterns to ignore for the build.
*/
exclude?: (string | RegExp)[];

/**
* defines specific string of file patterns to copy over for the builds.
*/
assets?: (string | RegExp)[];

/**
* boolean indicating if the interop rollup setting should be enabled for the build
*/
Expand All @@ -26,21 +41,21 @@ export interface CJSConfig extends CommonConfig {
/**
* build format to use. must be 'cjs'
*/
format: 'cjs';
format?: 'cjs';
}

export interface ESMConfig extends CommonConfig {
/**
* build format to use. must be 'esm'
*/
format: 'esm';
format?: 'esm';
}

export interface DistConfig extends CommonConfig {
/**
* build format to use. defaults to 'iife'
*/
format: 'iife' | 'umd';
format?: 'iife' | 'umd';

/**
* list of modules to regard as external, defaults to empty array
Expand All @@ -49,116 +64,6 @@ export interface DistConfig extends CommonConfig {
}

export interface Config {
/**
* plugins to apply
*/
plugins: Plugin[];

/**
* defines code src directory, defaults to 'src'
*/
srcDir: string;

/**
* defaults to index.js
*/
entryFile: string;

/**
* defaults to project package name camel-cased
*/
moduleName: string;

/**
* allowed file extensions. defaults to .js, .ts
*/
extensions: string[];

/**
* defines specific string of file patterns to process for all builds
*/
include: (string | RegExp)[];

/**
* defines specific string of file patterns to ignore for all builds.
*/
exclude: (string | RegExp)[];

/**
* defines specific string of file patterns to copy over for all builds.
*/
assets: (string | RegExp)[];

/**
* boolean indicating if the interop rollup setting should be enabled for all builds
*/
interop: boolean;

/**
* boolean indicating if sourcemap should be generated for all builds,
* can be true, false, or 'inline'
*/
sourcemap: true | false | 'inline';

/**
* boolean indicating if rollup plugin terser should be applied to the build, when in production mode
* default to false
*/
uglify: boolean;

/**
* rollup watch config
*/
watch: object;

/**
* rollup globals config
*/
globals: object;

/**
* defines config settings for generating distributed codes
*/
distConfig: DistConfig;

/**
* defines config settings for generating cjs files
*/
cjsConfig: CJSConfig;

/**
* defines config settings for generating esm files
*/
esmConfig: ESMConfig;
}

interface UserDistConfig extends CommonConfig {
/**
* build format to use. defaults to 'iife'
*/
format?: 'iife' | 'umd';

/**
* list of modules to regard as external, defaults to empty array
*/
externals?: string[];
}

interface UserCJSConfig extends CommonConfig {
/**
* build format to use. must be 'cjs'
*/
format?: 'cjs';
}

interface UserESMConfig extends CommonConfig {
/**
* build format to use. must be 'esm'
*/
format?: 'esm';
}

export interface UserConfig {
/**
* plugins to apply
*/
Expand All @@ -175,23 +80,22 @@ export interface UserConfig {
entryFile?: string;

/**
* defaults to project package.json name camel-cased
* defaults to project package name camel-cased
*/
moduleName?: string;

/**
* allowed file extensions. defaults to .js, .ts, .jsx, .tsx
* allowed file extensions. defaults to .js, .ts
*/
extensions?: string[];

/**
* defines specific string of file patterns to process for all builds. defaults to everything matching the file extensions within
* the src directory
* defines specific string of file patterns to process for all builds
*/
include?: (string | RegExp)[];

/**
* defines specific string of file patterns to ignore for all builds. defaults to nothing
* defines specific string of file patterns to ignore for all builds.
*/
exclude?: (string | RegExp)[];

Expand All @@ -218,8 +122,7 @@ export interface UserConfig {
uglify?: boolean;

/**
* rollup watch config, you must pass in the --watch command line argument for this to
* work
* rollup watch config
*/
watch?: object;

Expand All @@ -229,19 +132,19 @@ export interface UserConfig {
globals?: object;

/**
* defines config settings for generating distributed codes.
* defines config settings for generating distributed codes
*/
distConfig?: UserDistConfig;
distConfig?: DistConfig;

/**
* defines config settings for generating cjs codes.
* defines config settings for generating cjs files
*/
cjsConfig?: UserCJSConfig;
cjsConfig?: CJSConfig;

/**
* defines config settings for generating esm codes.
* defines config settings for generating esm files
*/
esmConfig?: UserESMConfig;
esmConfig?: ESMConfig;
}

export interface Module {
Expand Down Expand Up @@ -286,7 +189,7 @@ export interface ModuleFiles {
}

export interface GeneralConfig {
config?: UserConfig;
config?: Config;
babelConfig?: {
presets?: any[];
plugins?: any[];
Expand Down
20 changes: 16 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ export const config: Config = {
*/
enabled: true,

exclude: [],

include: [],

/**
* defines output directory
*/
outDir: 'build',

format: 'cjs'
format: 'cjs',
},

/**
Expand All @@ -81,12 +85,16 @@ export const config: Config = {
*/
enabled: true,

exclude: [],

include: [],

/**
* defines output directory
*/
outDir: 'build/esm',

format: 'esm'
format: 'esm',
},

/**
Expand All @@ -98,6 +106,10 @@ export const config: Config = {
*/
enabled: false,

exclude: [],

include: [],

/**
* defines output directory
*/
Expand All @@ -108,6 +120,6 @@ export const config: Config = {
*/
format: 'iife',

externals: []
}
externals: [],
},
};
Loading

0 comments on commit dfabab0

Please sign in to comment.