Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
condition('tslint', () => !argv().min),
condition('jest', () => !argv().min),
series(
argv().commonjs ? 'ts:commonjs-only' : 'ts',
condition('lint-imports', () => !argv().min),
parallel(condition('webpack', () => !argv().min), condition('verify-api-extractor', () => !argv().min))
)
)
)
);
// Special case build for the serializer, which needs to absolutely run typescript and jest serially.
task('build-jest-serializer-merge-styles', series('ts', 'jest'));
task('build-commonjs-only', series('clean', 'ts:commonjs-only'));
task('code-style', series('prettier', 'tslint'));
task('update-api', series('clean', 'copy', 'sass', 'ts', 'update-api-extractor'));
task('dev', series('clean', 'copy', 'sass', 'webpack-dev-server'));
// Utility functions
function getPackage() {
if (packageJson) {
return packageJson;
}
let packagePath = path.resolve(process.cwd(), 'package.json');
if (fs.existsSync(packagePath)) {
packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
return packageJson;
}
series(
argv().commonjs ? 'ts:commonjs-only' : 'ts',
condition('lint-imports', () => !argv().min),
parallel(condition('webpack', () => !argv().min), condition('verify-api-extractor', () => !argv().min))
)
)
)
);
// Special case build for the serializer, which needs to absolutely run typescript and jest serially.
task('build-jest-serializer-merge-styles', series('ts', 'jest'));
task('build-commonjs-only', series('clean', 'ts:commonjs-only'));
task('code-style', series('prettier', 'tslint'));
task('update-api', series('clean', 'copy', 'sass', 'ts', 'update-api-extractor'));
task('dev', series('clean', 'copy', 'sass', 'webpack-dev-server'));
// Utility functions
function getPackage() {
if (packageJson) {
return packageJson;
}
let packagePath = path.resolve(process.cwd(), 'package.json');
if (fs.existsSync(packagePath)) {
packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
return packageJson;
}
return undefined;
export function lib() {
task('clean', cleanTask());
task('ts:commonjs', tscTask({ module: 'commonjs', outDir: 'lib-commonjs' }));
task('ts:esm', tscTask({ module: 'esnext', outDir: 'lib' }));
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:commonjs', 'ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('build', series('clean', 'ts', 'jest'));
task('test', series('clean', 'jest'));
task('start', series('clean', 'ts:watch'));
task('start-test', series('clean', 'jest:watch'));
}
task('ts:esm', tscTask({ module: 'esnext', outDir: 'lib' }));
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('tslint', tslintTask());
task('webpack', webpackTask());
task('webpack:watch', webpackDevServerTask());
task('build', series('ts', 'webpack'));
task('test', series('jest'));
task('start', series('webpack:watch'));
task('start-test', series('jest:watch'));
task('rebuild', series('clean', 'build'));
}
task('ts:commonjs', tscTask({ module: 'commonjs', outDir: 'lib-commonjs' }));
task('ts:esm', tscTask({ module: 'esnext', outDir: 'lib' }));
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:commonjs', 'ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('tslint', tslintTask());
task('build', series('ts'));
task('test', series('jest'));
task('lint', series('tslint'));
task('start', series('clean', 'ts:watch'));
task('start-test', series('jest:watch'));
task('rebuild', series('clean', 'build'));
}
export function lib() {
task('clean', cleanTask());
task('ts:commonjs', tscTask({ module: 'commonjs', outDir: 'lib-commonjs' }));
task('ts:esm', tscTask({ module: 'esnext', outDir: 'lib' }));
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:commonjs', 'ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('build', series('clean', 'ts', 'jest'));
task('test', series('clean', 'jest'));
task('start', series('clean', 'ts:watch'));
task('start-test', series('clean', 'jest:watch'));
}
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('tslint', tslintTask());
task('webpack', webpackTask());
task('webpack:watch', webpackDevServerTask());
task('build', series('ts', 'webpack'));
task('test', series('jest'));
task('start', series('webpack:watch'));
task('start-test', series('jest:watch'));
task('rebuild', series('clean', 'build'));
}
task('ts:esm', tscTask({ module: 'esnext', outDir: 'lib' }));
task('ts:watch', tscTask({ module: 'esnext', outDir: 'lib', watch: true }));
task('ts', parallel('ts:esm'));
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('tslint', tslintTask());
task('webpack', webpackTask());
task('webpack:watch', webpackDevServerTask());
task('build', series('ts', 'webpack'));
task('test', series('jest'));
task('start', series('webpack:watch'));
task('start-test', series('jest:watch'));
task('rebuild', series('clean', 'build'));
}
task('ts', () => {
return tscTask({
pretty: true,
...(argv().production && { inlineSources: true, sourceRoot: path.relative(libPath, srcPath) }),
target: 'es5',
outDir: 'lib',
module: 'commonjs',
});
});
task('clean', () => {
return cleanTask(['lib', 'temp', 'dist', 'coverage'].map(p => path.join(process.cwd(), p)));
});
task(
'build',
series(
condition('clean', () => argv().clean),
'tslint',
'ts'
)
);}
task('jest', jestTask());
task('jest:watch', jestTask({ watch: true }));
task('tslint', tslintTask());
task('webpack', webpackTask());
task('webpack:watch', webpackDevServerTask());
task('build', series('ts', 'webpack'));
task('test', series('jest'));
task('start', series('webpack:watch'));
task('start-test', series('jest:watch'));
task('rebuild', series('clean', 'build'));
}