Skip to content

Migrate from a separate commonjs shim file to creating require dynamically#26

Merged
1egoman merged 2 commits intomainfrom
migrate-from-commonjs-shim-to-dynamic-created-require
Feb 5, 2026
Merged

Migrate from a separate commonjs shim file to creating require dynamically#26
1egoman merged 2 commits intomainfrom
migrate-from-commonjs-shim-to-dynamic-created-require

Conversation

@1egoman
Copy link
Collaborator

@1egoman 1egoman commented Feb 5, 2026

Background: some tools (namely esbuild) struggle to build a project with a mixed set of esm / commonjs style imports. Debugging this is proving to be particularly challenging to get to a root cause on, so instead of doubling down on this separate "commonjs shim" file like napi does it, I think dynamically creating require via the createRequire api node exposes and calling that instead inline should make the output build much less complex.

…dynamically

Background: some tools (namely esbuild) struggle to build a project with
a mixed set of esm / commonjs style imports. Debugging this is proving
to be particularly challenging to get to a root cause on, so instead of
making a separate "commonjs shim" file like napi does it, dynamically
create `require` via the `createRequire` api node exposes and call that
instead inline. I think this should make the output build much less
complex.
@1egoman 1egoman merged commit e00e0f5 into main Feb 5, 2026
3 checks passed
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.

1 participant