-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
build: add rollup plugin for compile-time ESM/CJS code branching #21715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6019e74
5624872
e9506b4
0a4b3f2
ddd1e16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,13 @@ import { NODE_MAJOR, NODE_MINOR } from '../nodeVersion'; | |
|
|
||
| /** Detect CommonJS. */ | ||
| export function isCjs(): boolean { | ||
| try { | ||
| // oxlint-disable-next-line typescript/prefer-optional-chain | ||
| return typeof module !== 'undefined' && typeof module.exports !== 'undefined'; | ||
| } catch { | ||
| return false; | ||
| } | ||
| /*! rollup-include-cjs-only */ | ||
| return true; | ||
| /*! rollup-include-cjs-only-end */ | ||
|
|
||
| /*! rollup-include-esm-only */ | ||
| return false; | ||
| /*! rollup-include-esm-only-end */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Source
|
||
| } | ||
|
|
||
| let hasWarnedAboutNodeVersion: boolean | undefined; | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESM/CJS strip runs after esbuild
Medium Severity
The new
remove-esm-cjs-mode-blockstransform is not pinned beforeesbuildinmergePlugins, unlikeremove-dev-mode-blocks. Format-specific blocks are stripped only after transpilation, so top-level imports used solely in a removed branch can remain in the module graph and ship in the wrong format bundle.Reviewed by Cursor Bugbot for commit ddd1e16. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not using esbuild