evanw / evanw/esbuild

Incorrect CJS import with `esmoduleInterop: true`

Open
#1,971 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Repro: https://github.com/BeeeQueue/esbuild-cjs-no-default

TL;DR: `import core from "@actions/core"` generates invalid code which fails when running, presumably because it does something funky with the exports somewhere.

I tried to look around a bit to see if I could find what they're doing weird but couldn't find anything myself.

It can be worked around with `import * as`, but if that is the intended behavior there should probably be a warning about it.

Maybe related to #1079?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked reproduction at https://github.com/BeeeQueue/esbuild-cjs-no-default and inspect the generated code for `import core from "@actions/core"` with `esModuleInterop: true`. Compare its runtime behavior with the `import * as` workaround and determine whether the expected outcome is valid execution or a warning for this import pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, javascript, typescript
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.