Skip to content

[@rollup/plugin-commonjs] import { createRequire } from 'node:module' is injected automatically, breaking codes for edge runtimes #1924

@sapphi-red

Description

@sapphi-red

Expected Behavior

import { createRequire } from 'node:module' is not injected unless allowed by an option.

Actual Behavior

import { createRequire } from 'node:module' is injected automatically.

Additional Information

Edge runtimes like workerd and vercel edge runtime does not support module.createRequire (workers docs, vercel edge runtime docs). It isn't possible to polyfill this function as well.
This means the code generated cannot be executed by those runtimes.

related: #1909, vitejs/vite#20983, vitejs/vite-plugin-react#929 (comment), wakujs/waku#1731

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions