Skip to content

Commit 2f9c8d0

Browse files
committed
build: add prebuild command support
1 parent 80a1dfb commit 2f9c8d0

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

fixtures/eslint-v6/build.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
22

3-
import {exec} from 'node:child_process';
3+
import {execSync} from 'node:child_process';
44
import {dirname, resolve} from 'node:path';
55
import {fileURLToPath} from 'node:url';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
99

10-
exec('yarn build -r stable eslint-plugin-react-hooks', {
10+
execSync('yarn build -r stable eslint-plugin-react-hooks', {
1111
cwd: resolve(__dirname, '..', '..'),
12+
stdio: 'inherit',
1213
});

fixtures/eslint-v7/build.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
22

3-
import {exec} from 'node:child_process';
3+
import {execSync} from 'node:child_process';
44
import {dirname, resolve} from 'node:path';
55
import {fileURLToPath} from 'node:url';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
99

10-
exec('yarn build -r stable eslint-plugin-react-hooks', {
10+
execSync('yarn build -r stable eslint-plugin-react-hooks', {
1111
cwd: resolve(__dirname, '..', '..'),
12+
stdio: 'inherit',
1213
});

fixtures/eslint-v8/build.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
22

3-
import {exec} from 'node:child_process';
3+
import {execSync} from 'node:child_process';
44
import {dirname, resolve} from 'node:path';
55
import {fileURLToPath} from 'node:url';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
99

10-
exec('yarn build -r stable eslint-plugin-react-hooks', {
10+
execSync('yarn build -r stable eslint-plugin-react-hooks', {
1111
cwd: resolve(__dirname, '..', '..'),
12+
stdio: 'inherit',
1213
});

fixtures/eslint-v9/build.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
22

3-
import {exec} from 'node:child_process';
3+
import {execSync} from 'node:child_process';
44
import {dirname, resolve} from 'node:path';
55
import {fileURLToPath} from 'node:url';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
99

10-
exec('yarn build -r stable eslint-plugin-react-hooks', {
10+
execSync('yarn build -r stable eslint-plugin-react-hooks', {
1111
cwd: resolve(__dirname, '..', '..'),
12+
stdio: 'inherit',
1213
});

packages/eslint-plugin-react-hooks/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"react"
2222
],
2323
"scripts": {
24-
"dependencies": "cd ../../compiler/packages/babel-plugin-react-compiler && yarn && yarn tsc -b",
2524
"test": "jest",
2625
"typecheck": "tsc --noEmit"
2726
},

scripts/rollup/build.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const stripBanner = require('rollup-plugin-strip-banner');
1212
const chalk = require('chalk');
1313
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
1414
const fs = require('fs');
15+
const childProcess = require('child_process');
1516
const argv = require('minimist')(process.argv.slice(2));
1617
const Modules = require('./modules');
1718
const Bundles = require('./bundles');
@@ -829,6 +830,11 @@ function handleRollupError(error) {
829830
}
830831
}
831832

833+
function runShellCommand(command) {
834+
console.log(chalk.dim('Running: ') + chalk.cyan(command));
835+
childProcess.execSync(command, {stdio: 'inherit', shell: true});
836+
}
837+
832838
async function buildEverything() {
833839
if (!argv['unsafe-partial']) {
834840
await asyncRimRaf('build');
@@ -876,6 +882,9 @@ async function buildEverything() {
876882

877883
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
878884
for (const [bundle, bundleType] of bundles) {
885+
if (bundle.prebuild) {
886+
runShellCommand(bundle.prebuild);
887+
}
879888
await createBundle(bundle, bundleType);
880889
}
881890

scripts/rollup/bundles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,8 @@ const bundles = [
11971197
wrapWithModuleBoundaries: false,
11981198
externals: [],
11991199
tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json',
1200+
prebuild:
1201+
'cd compiler/packages/babel-plugin-react-compiler && yarn && yarn tsc -b',
12001202
},
12011203

12021204
/******* React Fresh *******/

0 commit comments

Comments
 (0)