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 Mar 2, 2025
1 parent b635ff8 commit b483c78
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
5 changes: 3 additions & 2 deletions fixtures/eslint-v6/build.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node

import {exec} from 'node:child_process';
import {execSync} from 'node:child_process';
import {dirname, resolve} from 'node:path';
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',
});
5 changes: 3 additions & 2 deletions fixtures/eslint-v7/build.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node

import {exec} from 'node:child_process';
import {execSync} from 'node:child_process';
import {dirname, resolve} from 'node:path';
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',
});
5 changes: 3 additions & 2 deletions fixtures/eslint-v8/build.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node

import {exec} from 'node:child_process';
import {execSync} from 'node:child_process';
import {dirname, resolve} from 'node:path';
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',
});
5 changes: 3 additions & 2 deletions fixtures/eslint-v9/build.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node

import {exec} from 'node:child_process';
import {execSync} from 'node:child_process';
import {dirname, resolve} from 'node:path';
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 @@ -812,6 +813,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 @@ -859,6 +865,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 b483c78

Please sign in to comment.