build(build-infrastructure): switch from ESM to CJS output#26895
Draft
tylerbutler wants to merge 1 commit intomicrosoft:mainfrom
Draft
build(build-infrastructure): switch from ESM to CJS output#26895tylerbutler wants to merge 1 commit intomicrosoft:mainfrom
tylerbutler wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Remove "type": "module" so tsc with module: Node16 emits CJS to lib/. This avoids the dual package hazard: build-cli (ESM) and build-tools (CJS) both consume build-infrastructure, and if both ran in the same process with separate ESM/CJS copies, instanceof and identity checks would break across the module boundary. With CJS output, both consumers get the same CJS copy — ESM can import CJS without hazard. The .mjs bin files remain ESM (always ESM regardless of package type).
b838878 to
cf98db0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Switch
@fluid-tools/build-infrastructurefrom ESM ("type": "module") to CJS output by removing thetypefield frompackage.json. Withmodule: Node16, tsc now reads the package type as CommonJS and emits CJS tolib/.Why not dual ESM/CJS? Both
build-cli(ESM) andbuild-tools(CJS) consumebuild-infrastructure. If both run in the same Node process — which they do, sincebuild-cliimports frombuild-tools— a dual-build package would load two separate module instances (one ESM, one CJS). This causes the dual package hazard:instanceofchecks, identity comparisons, and shared state break across the boundary. CJS-only avoids this because ESM can import CJS without creating a second copy.Changes:
"type": "module"frompackage.jsonexportsto a single entry (no import/require conditions)/distfromfilesandcleanscript (no dual output).mjsbin files are unchanged (always ESM regardless of package type)Reviewer Guidance
The review process is outlined on this wiki page.
All dependencies were already pinned to CJS-compatible versions (
execa@^5,globby@^11,detect-indent@^6,read-pkg-up@^7). Noimport.metaor top-levelawaitin source. 52 tests pass.