Skip to content

Commit dd025bd

Browse files
ci: skip CJS api-extractor checks on PR builds
CJS api-extractor output is byte-for-byte identical to ESM. On PR builds, skip CJS api-extractor invocations (~22 min CPU, ~2 min wall-clock) and defer CJS-dependent checks to main/release CI. When SKIP_CJS_CHECKS=true (set for PR builds via pipeline variable): - api-extractor:commonjs removed from build:test, build:test:cjs, api - check:exports becomes a no-op (concurrently script would fail without CJS entry points) - check:are-the-types-wrong becomes a no-op (attw checks CJS+ESM) - AreTheTypesWrong pipeline job excluded from PR runs Non-PR builds are unaffected — full CJS+ESM checks run as before. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8fa20de commit dd025bd

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

fluidBuild.config.cjs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const releaseGroupPackageJsonGlobs = [
1919
"tools/markdown-magic/package.json",
2020
];
2121

22+
const skipCjsChecks = process.env.SKIP_CJS_CHECKS === "true";
23+
2224
/**
2325
* The settings in this file configure the Fluid build tools, such as fluid-build and flub. Some settings apply to the
2426
* whole repo, while others apply only to the client release group.
@@ -90,11 +92,17 @@ module.exports = {
9092
// Generic build:test script should be replaced by :esm or :cjs specific versions.
9193
// "tsc" would be nice to eliminate from here, but plenty of packages still focus
9294
// on CommonJS.
93-
"build:test": ["typetests:gen", "tsc", "api-extractor:commonjs", "api-extractor:esnext"],
94-
"build:test:cjs": ["typetests:gen", "tsc", "api-extractor:commonjs"],
95+
"build:test": skipCjsChecks
96+
? ["typetests:gen", "tsc", "api-extractor:esnext"]
97+
: ["typetests:gen", "tsc", "api-extractor:commonjs", "api-extractor:esnext"],
98+
"build:test:cjs": skipCjsChecks
99+
? ["typetests:gen", "tsc"]
100+
: ["typetests:gen", "tsc", "api-extractor:commonjs"],
95101
"build:test:esm": ["typetests:gen", "build:esnext", "api-extractor:esnext"],
96102
"api": {
97-
dependsOn: ["api-extractor:commonjs", "api-extractor:esnext"],
103+
dependsOn: skipCjsChecks
104+
? ["api-extractor:esnext"]
105+
: ["api-extractor:commonjs", "api-extractor:esnext"],
98106
script: false,
99107
},
100108
"api-extractor:commonjs": ["tsc"],
@@ -126,12 +134,29 @@ module.exports = {
126134
script: true,
127135
},
128136
"depcruise": [],
129-
"check:exports": ["api"],
137+
// When skipping CJS checks, skip check:exports entirely. The package's concurrently
138+
// script would fail because CJS entry points aren't generated, and forcing
139+
// check:exports:bundle-release-tags to run individually surfaces pre-existing
140+
// api-extractor lint errors in packages that have disabled check:exports via
141+
// "echo skip". All export checks are deferred to main CI.
142+
"check:exports": skipCjsChecks
143+
? {
144+
dependsOn: [],
145+
script: false,
146+
}
147+
: ["api"],
130148
"check:exports:bundle-release-tags": ["build:esnext"],
131149
// The package's local 'api-extractor-lint.json' may use the entrypoint from either CJS or ESM,
132150
// therefore we need to require both before running api-extractor.
133151
"check:release-tags": ["tsc", "build:esnext"],
134-
"check:are-the-types-wrong": ["tsc", "build:esnext", "api"],
152+
// attw packs the package and checks CJS+ESM type resolution. With CJS entry
153+
// points missing, it fails. Defer to main CI where api generates both.
154+
"check:are-the-types-wrong": skipCjsChecks
155+
? {
156+
dependsOn: [],
157+
script: false,
158+
}
159+
: ["tsc", "build:esnext", "api"],
135160
"check:format": {
136161
dependencies: [],
137162
script: true,

tools/pipelines/build-client.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ extends:
220220
- { name: "ci:test:jest", jobName: "JestTest" }
221221
- { name: "ci:test:realsvc:tinylicious", jobName: "RealsvcTinyliciousTest" }
222222
- { name: "ci:test:stress:tinylicious", jobName: "StressTinyliciousTest" }
223-
- { name: "ci:check:are-the-types-wrong", jobName: "AreTheTypesWrong" }
223+
# attw checks CJS+ESM type resolution; skip on PRs where CJS api-extractor is skipped
224+
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
225+
- { name: "ci:check:are-the-types-wrong", jobName: "AreTheTypesWrong" }
224226
coverageTests:
225227
- { name: "ci:test:mocha", jobName: "MochaTest" }
226228
- { name: "ci:test:realsvc:local", jobName: "RealsvcLocalTest" }

tools/pipelines/templates/include-build-lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ steps:
3131
# a transitive dependency of browserslist. Without this, the warning fires once
3232
# per package during builds, producing 100+ identical warnings in build logs.
3333
BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA: 1
34+
# Skip CJS api-extractor checks on PR builds to reduce build time.
35+
# CJS output is byte-for-byte identical to ESM; full CJS checks run on main/release CI.
36+
SKIP_CJS_CHECKS: $(skipCjsChecks)
3437
inputs:
3538
command: 'custom'
3639
workingDir: $(Pipeline.Workspace)/${{ parameters.buildDirectory }}
@@ -42,6 +45,7 @@ steps:
4245
env:
4346
# Suppress baseline-browser-mapping staleness warnings during lint as well.
4447
BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA: 1
48+
SKIP_CJS_CHECKS: $(skipCjsChecks)
4549
inputs:
4650
command: 'custom'
4751
workingDir: $(Pipeline.Workspace)/${{ parameters.buildDirectory }}

tools/pipelines/templates/include-vars.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ variables:
122122
value: ${{ ne(variables['Build.Reason'], 'PullRequest') }}
123123
readonly: true
124124

125+
- name: skipCjsChecks
126+
value: ${{ lower(eq(variables['Build.Reason'], 'PullRequest')) }}
127+
readonly: true
128+
125129
- template: /tools/pipelines/templates/include-vars-telemetry-generator.yml@self
126130

127131
# The way 1ES pipeline templates determine the default branch of a repository only works for repos hosted in ADO.

0 commit comments

Comments
 (0)