skip generating type definitions in prep-mode

This commit is contained in:
Norbert de Langen 2022-05-25 13:10:48 +02:00
parent e02049ee38
commit 426b68e570
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
5 changed files with 53 additions and 31 deletions

18
scripts/bootstrap.js vendored
View File

@ -52,7 +52,7 @@ function run() {
const tasks = {
core: createTask({
name: `Core & Examples ${chalk.gray('(core)')}`,
defaultValue: true,
defaultValue: false,
option: '--core',
command: () => {
log.info(prefix, 'yarn workspace');
@ -60,6 +60,16 @@ function run() {
pre: ['install', 'build', 'manager'],
order: 1,
}),
prep: createTask({
name: `Prep for development ${chalk.gray('(prep)')}`,
defaultValue: true,
option: '--prep',
command: () => {
log.info(prefix, 'prepare');
spawn(`nx run-many --target="prepare" --all --parallel -- --reset`);
},
order: 2,
}),
retry: createTask({
name: `Core & Examples but only build previously failed ${chalk.gray('(core)')}`,
defaultValue: true,
@ -99,11 +109,11 @@ function run() {
defaultValue: false,
option: '--build',
command: () => {
log.info(prefix, 'prepare');
log.info(prefix, 'build');
spawn(
`nx run-many --target="prepare" --all --parallel=8 ${
process.env.CI ? `--max-parallel=${maxConcurrentTasks}` : ''
} -- --optimized`
} -- --reset --optimized`
);
},
order: 2,
@ -138,7 +148,7 @@ function run() {
};
const groups = {
main: ['core'],
main: ['prep', 'core'],
buildtasks: ['install', 'build', 'manager'],
devtasks: ['dev', 'registry', 'reset'],
};

View File

@ -138,7 +138,7 @@ async function build(options: Options) {
watcher.on('change', (event) => {
console.log(`${greenBright('changed')}: ${event.replace(path.resolve(cwd, '../..'), '.')}`);
dts(options);
// dts(options);
});
} else {
const bundler = await rollup(setting);
@ -169,10 +169,12 @@ export async function run({ cwd, flags }: { cwd: string; flags: string[] }) {
watch: flags.includes('--watch'),
};
console.log(`skipping generating types for ${process.cwd()}`);
await Promise.all([
//
build(options),
dts(options),
...(options.optimized ? [dts(options)] : []),
]);
console.timeEnd(message);

View File

@ -82,6 +82,7 @@ async function prepare({ cwd, flags }) {
errorCallback: (errorLogs) => logError('js', packageJson, errorLogs),
}),
tscfy({
optimized: flags.includes('--optimized'),
watch: flags.includes('--watch'),
errorCallback: (errorLogs) => logError('ts', packageJson, errorLogs),
}),

View File

@ -5,6 +5,8 @@ import { build } from 'tsup';
const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
const packageJson = await fs.readJson(join(cwd, 'package.json'));
console.log(`skipping generating types for ${process.cwd()}`);
await build({
entry: packageJson.bundlerEntrypoint,
watch: flags.includes('--watch'),
@ -14,10 +16,12 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
clean: true,
shims: true,
dts: {
entry: packageJson.bundlerEntrypoint,
resolve: true,
},
dts: flags.includes('--optimized')
? {
entry: packageJson.bundlerEntrypoint,
resolve: true,
}
: false,
esbuildOptions: (c) => {
/* eslint-disable no-param-reassign */
c.platform = 'node';

View File

@ -27,7 +27,7 @@ function getCommand(watch) {
args.push('-w', '--preserveWatchOutput');
}
return `yarn run -T tsc ${args.join(' ')}`;
return [`yarn run -T tsc ${args.join(' ')}`, isAngular || isStoryshots];
}
function handleExit(code, stderr, errorCallback) {
@ -40,31 +40,36 @@ function handleExit(code, stderr, errorCallback) {
}
}
async function run({ watch, silent, errorCallback }) {
async function run({ optimized, watch, silent, errorCallback }) {
return new Promise((resolve, reject) => {
const command = getCommand(watch);
const [command, tscOnly] = getCommand(watch);
const child = execa.command(command, {
buffer: false,
});
let stderr = '';
if (tscOnly || optimized) {
const child = execa.command(command, {
buffer: false,
});
let stderr = '';
if (watch) {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
if (watch) {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
} else {
child.stderr.on('data', (data) => {
stderr += data.toString();
});
child.stdout.on('data', (data) => {
stderr += data.toString();
});
}
child.on('exit', (code) => {
resolve();
handleExit(code, stderr, errorCallback);
});
} else {
child.stderr.on('data', (data) => {
stderr += data.toString();
});
child.stdout.on('data', (data) => {
stderr += data.toString();
});
}
child.on('exit', (code) => {
console.log(`skipping generating types for ${process.cwd()}`);
resolve();
handleExit(code, stderr, errorCallback);
});
}
});
}