Skip to content

Commit 238bd24

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Add error when running build script after prepack (facebook#55914)
Summary: Pull Request resolved: facebook#55914 Introduce a clear error message if running `yarn build` again after `yarn prepack` (which will have applied the `"publishConfig"` field to each `package.json`, just ahead of publishing to npm). This state should never happen in CI or local dev, but can occur if repeat-running `yarn test-release-local` without `yarn test-release-local-clean`. Introducing a validation error is preferable over making this idempotent (logic would be complex + fragile) for this rare + out-of-design edge case. Changelog: [Internal] Reviewed By: alanleedev Differential Revision: D95215735 fbshipit-source-id: 5a9be44f0d0ae1f2721eed2b11088466a4ff7f72
1 parent 7f7dbe7 commit 238bd24

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scripts/build/build.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ async function build() {
8585

8686
async function buildPackage(packageName /*: string */, prepack /*: boolean */) {
8787
try {
88+
process.stdout.write(
89+
`${packageName} ${styleText('dim', '.').repeat(72 - packageName.length)} `,
90+
);
91+
8892
const {emitTypeScriptDefs} = getBuildOptions(packageName);
8993
const entryPoints = await getEntryPoints(packageName);
9094

@@ -98,10 +102,6 @@ async function buildPackage(packageName /*: string */, prepack /*: boolean */) {
98102
!entryPoints.has(file.replace(/\.js$/, '.flow.js')),
99103
);
100104

101-
process.stdout.write(
102-
`${packageName} ${styleText('dim', '.').repeat(72 - packageName.length)} `,
103-
);
104-
105105
// Build regular files
106106
for (const file of files) {
107107
await buildFile(path.normalize(file), {
@@ -299,6 +299,15 @@ async function getEntryPoints(
299299
continue;
300300
}
301301

302+
if (target.startsWith('./' + BUILD_DIR + '/')) {
303+
throw new Error(
304+
`Found ./${BUILD_DIR}/* entry in package.json exports for ` +
305+
`${packageName}. This is either a misconfiguration, or the ` +
306+
`prepack script was previously run and the package.json state ` +
307+
`is dirty. Please re-run against a clean working copy.`,
308+
);
309+
}
310+
302311
if (target.includes('*')) {
303312
console.warn(
304313
`${styleText('yellow', 'Warning')}: Encountered subpath pattern ${subpath}` +

0 commit comments

Comments
 (0)