Skip to content

Commit

Permalink
build: add prebuild command support
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfaith committed Feb 23, 2025
1 parent 80a1dfb commit 31abe51
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion fixtures/eslint-v6/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

exec('yarn build -r stable eslint-plugin-react-hooks', {
execSync('yarn build -r stable eslint-plugin-react-hooks', {
cwd: resolve(__dirname, '..', '..'),
stdio: 'inherit',
});
3 changes: 2 additions & 1 deletion fixtures/eslint-v7/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

exec('yarn build -r stable eslint-plugin-react-hooks', {
execSync('yarn build -r stable eslint-plugin-react-hooks', {
cwd: resolve(__dirname, '..', '..'),
stdio: 'inherit',
});
3 changes: 2 additions & 1 deletion fixtures/eslint-v8/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

exec('yarn build -r stable eslint-plugin-react-hooks', {
execSync('yarn build -r stable eslint-plugin-react-hooks', {
cwd: resolve(__dirname, '..', '..'),
stdio: 'inherit',
});
3 changes: 2 additions & 1 deletion fixtures/eslint-v9/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

exec('yarn build -r stable eslint-plugin-react-hooks', {
execSync('yarn build -r stable eslint-plugin-react-hooks', {
cwd: resolve(__dirname, '..', '..'),
stdio: 'inherit',
});
1 change: 0 additions & 1 deletion packages/eslint-plugin-react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"react"
],
"scripts": {
"dependencies": "cd ../../compiler/packages/babel-plugin-react-compiler && yarn && yarn tsc -b",
"test": "jest",
"typecheck": "tsc --noEmit"
},
Expand Down
9 changes: 9 additions & 0 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const stripBanner = require('rollup-plugin-strip-banner');
const chalk = require('chalk');
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
const fs = require('fs');
const childProcess = require('child_process');
const argv = require('minimist')(process.argv.slice(2));
const Modules = require('./modules');
const Bundles = require('./bundles');
Expand Down Expand Up @@ -829,6 +830,11 @@ function handleRollupError(error) {
}
}

function runShellCommand(command) {
console.log(chalk.dim('Running: ') + chalk.cyan(command));
childProcess.execSync(command, {stdio: 'inherit', shell: true});
}

async function buildEverything() {
if (!argv['unsafe-partial']) {
await asyncRimRaf('build');
Expand Down Expand Up @@ -876,6 +882,9 @@ async function buildEverything() {

// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const [bundle, bundleType] of bundles) {
if (bundle.prebuild) {
runShellCommand(bundle.prebuild);
}
await createBundle(bundle, bundleType);
}

Expand Down
2 changes: 2 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,8 @@ const bundles = [
wrapWithModuleBoundaries: false,
externals: [],
tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json',
prebuild:
'cd compiler/packages/babel-plugin-react-compiler && yarn && yarn tsc -b',
},

/******* React Fresh *******/
Expand Down

0 comments on commit 31abe51

Please sign in to comment.