Skip to content

Commit a25049b

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Remove build package.json dirty state check (#55420)
Summary: Pull Request resolved: #55420 After #54857 (use of the "publishConfig" field), this check is no longer necessary, since `yarn build` will no longer make changes to any checked in files. In the (expectedly) rare case that `yarn build --prepack` changes are committed (only intended for CI), Flow will also fail independently. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D92397786 fbshipit-source-id: 872cc91b62295cdb6d8c2799cffb8a4cadc4106e
1 parent 11e257c commit a25049b

3 files changed

Lines changed: 7 additions & 58 deletions

File tree

.github/actions/lint/action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ runs:
2929
- name: Lint file structure
3030
shell: bash
3131
run: ./.github/workflow-scripts/lint_files.sh
32-
- name: Verify not committing repo after running build
33-
shell: bash
34-
run: yarn run build --validate
3532
- name: Run flowcheck
3633
shell: bash
3734
run: yarn flow-check

scripts/build/build.js

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ const config = {
3737
allowPositionals: true,
3838
options: {
3939
prepack: {type: 'boolean'},
40-
validate: {type: 'boolean'},
4140
help: {type: 'boolean'},
4241
},
4342
};
4443

4544
async function build() {
4645
const {
4746
positionals: packageNames,
48-
values: {prepack, validate, help},
47+
values: {prepack, help},
4948
/* $FlowFixMe[incompatible-type] Natural Inference rollout. See
5049
* https://fburl.com/workplace/6291gfvu */
5150
} = parseArgs(config);
@@ -62,47 +61,28 @@ async function build() {
6261
Options:
6362
--prepack Run the ./prepack.js script after building, applying
6463
package.json "publishConfig" changes to the working copy.
65-
This is usually run before npm publish.
66-
--validate Validate that no build artifacts have been accidentally
67-
committed.
64+
(This is usually run later in CI before npm publish).
6865
`);
6966
process.exitCode = 0;
7067
return;
7168
}
7269

73-
if (!validate) {
74-
console.log(
75-
'\n' + styleText(['bold', 'inverse'], 'Building packages') + '\n',
76-
);
77-
}
70+
console.log(
71+
'\n' + styleText(['bold', 'inverse'], 'Building packages') + '\n',
72+
);
7873

7974
const packagesToBuild = packageNames.length
8075
? packageNames.filter(packageName => packageName in buildConfig.packages)
8176
: Object.keys(buildConfig.packages);
8277

8378
let ok = true;
8479
for (const packageName of packagesToBuild) {
85-
if (validate) {
86-
ok &&= await checkPackage(packageName);
87-
} else {
88-
await buildPackage(packageName, prepack);
89-
}
80+
await buildPackage(packageName, prepack);
9081
}
9182

9283
process.exitCode = ok ? 0 : 1;
9384
}
9485

95-
async function checkPackage(packageName /*: string */) /*: Promise<boolean> */ {
96-
const artifacts = await exportedBuildArtifacts(packageName);
97-
if (artifacts.length > 0) {
98-
console.log(
99-
`${styleText('bgRed', packageName)}: has been built and the ${styleText('bold', 'build artifacts')} committed to the repository. This will break Flow checks.`,
100-
);
101-
return false;
102-
}
103-
return true;
104-
}
105-
10686
async function buildPackage(packageName /*: string */, prepack /*: boolean */) {
10787
try {
10888
const {emitTypeScriptDefs} = getBuildOptions(packageName);
@@ -248,33 +228,6 @@ type PackageJson = {
248228
};
249229
*/
250230

251-
function isStringOnly(entries /*: mixed */) /*: entries is string */ {
252-
return typeof entries === 'string';
253-
}
254-
255-
async function exportedBuildArtifacts(
256-
packageName /*: string */,
257-
) /*: Promise<string[]> */ {
258-
const packagePath = path.resolve(PACKAGES_DIR, packageName, 'package.json');
259-
const pkg /*: PackageJson */ = JSON.parse(
260-
await fs.readFile(packagePath, 'utf8'),
261-
);
262-
if (pkg.exports == null) {
263-
throw new Error(
264-
packageName +
265-
' does not define an "exports" field in its package.json. As part ' +
266-
'of the build setup, this field must be used in order to rewrite ' +
267-
'paths to built files in production.',
268-
);
269-
}
270-
271-
return Object.values(pkg.exports)
272-
.filter(isStringOnly)
273-
.filter(filepath =>
274-
path.dirname(filepath).split(path.sep).includes(BUILD_DIR),
275-
);
276-
}
277-
278231
/**
279232
* Get the set of Flow entry points to build.
280233
*

scripts/run-ci-javascript-tests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ try {
5353

5454
describe('Test: feature flags codegen');
5555
execAndLog(`${YARN_BINARY} run featureflags --verify-unchanged`);
56+
5657
describe('Test: eslint');
5758
execAndLog(`${YARN_BINARY} run lint`);
58-
describe('Test: No JS build artifacts');
59-
execAndLog(`${YARN_BINARY} run build --validate`);
6059

6160
describe('Test: Validate JS API snapshot');
6261
execAndLog(`${YARN_BINARY} run build-types --validate`);

0 commit comments

Comments
 (0)