Build fails on main after picomatch 2.3.2 upgrade
Describe the bug
A clean build of the current main branch fails after running npm ci.
The TypeScript transform skips plain .ts files, causing untransformed TypeScript syntax to reach Babel:
Support for the experimental syntax 'flow' isn't currently enabled
src/patterns.ts:
export type {Reproduction
git checkout c92ca435c7e1827e0fd55c539080ef1bfd6fe3f0
rm -rf node_modules dist
npm ci
npm run buildExpected behavior
npm run build should successfully generate the package bundles in dist.
Actual behavior
The build fails while Babel is parsing src/patterns.ts.
Bisect result
I used git bisect between the last release and the current main.
- Good:
v5.9.0(0e15315) - Bad:
c92ca435c7e1827e0fd55c539080ef1bfd6fe3f0 - First bad commit:
8d4b56c8fb4f04e0a33be7679a9f8b15e9e2dcfe
build(deps): bump picomatchThe parent of this commit builds successfully in the same environment.
Root cause
Commit 8d4b56c8fb4f04e0a33be7679a9f8b15e9e2dcfe upgrades picomatch from 2.3.1 to 2.3.2.
[email protected] depends on an older version of rollup-plugin-typescript2, whose default TypeScript include pattern uses:
*.ts+(|x)
**/*.ts+(|x)With [email protected], this pattern no longer matches plain .ts files. As a result, TypeScript files bypass the TypeScript transform and reach Babel untransformed.
[email protected] fixes this compatibility issue by using:
*.ts{,x}
**/*.ts{,x}Verified solution
Overriding Microbundle's rollup-plugin-typescript2 dependency to version 0.37.0 restores the build:
"overrides": {
"microbundle": {
".": "$microbundle",
"rollup-plugin-typescript2": "0.37.0"
}
}The solution was verified from a clean installation:
rm -rf node_modules dist
npm ci
npm run buildThe build completed successfully and generated the expected bundles.
Environment
- Node.js:
20.15.0 - npm:
10.7.0 - ts-pattern commit:
c92ca435c7e1827e0fd55c539080ef1bfd6fe3f0 - Package version:
5.9.0 - Operating system: macOS
Source: gvergnaud/ts-pattern