Skip to content

fix(vite): keep require calls in ESM file#3433

Merged
marvinhagemeister merged 1 commit into
mainfrom
fix-require-in-esm
Sep 15, 2025
Merged

fix(vite): keep require calls in ESM file#3433
marvinhagemeister merged 1 commit into
mainfrom
fix-require-in-esm

Conversation

@marvinhagemeister

Copy link
Copy Markdown
Contributor

Detect if a file is ESM based on file extension or finding ESM-only statements. When we know that it's an ESM file we should keep require() calls as is, because some libraries use it as a conditional check like npm:motion.

Fixes #3429

@marvinhagemeister marvinhagemeister merged commit b31f362 into main Sep 15, 2025
15 of 16 checks passed
@marvinhagemeister marvinhagemeister deleted the fix-require-in-esm branch September 15, 2025 08:40
fry69 pushed a commit to fry69/fresh that referenced this pull request Sep 15, 2025
Detect if a file is ESM based on file extension or finding ESM-only
statements. When we know that it's an ESM file we should keep
`require()` calls as is, because some libraries use it as a conditional
check like `npm:motion`.

Fixes freshframework#3429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fresh v2 + Motion fails with Cannot bundle built-in module "node:module"

1 participant