node-resolve plugin discards this re-exported file
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- build-system, tooling
Research direction
Start with the linked StackBlitz reproduction and inspect @rollup/plugin-node-resolve's handling of the re-exported util.inspect.js file. Compare the generated vendor and index chunks with the source snippets; done when the require is preserved and the ReferenceError no longer occurs.
Written by the indexing model from the issue text.
Description
- Rollup Plugin Name:
@rollup/plugin-node-resolve - Rollup Plugin Version: 16.0.3
- Rollup Version: 4.52.0
- Operating System (or Browser): Linux
- Node Version: 20 +
- Link to reproduction (⚠️ read below): https://stackblitz.com/edit/vitejs-vite-os2s19kt?file=src%2FApp.tsx
Expected Behavior
The re-export of ./util.inspect.js by object-expect should not be discarded, causing a run time failure.
index.js contains these lines
var utilInspect = require('./util.inspect');
var inspectCustom = utilInspect.custom;
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
This require should be preserved, as './util.inspect' contains just this line:
module.exports = require('util').inspect;
Actual Behavior
The require statement is mangled at some point:
vendor chunk (Zt is equivalent to v in the index chunk):
var M = Zt // <--- error here
, B = M.custom
, re = J(B) ? B : null
index chunk
const p = {}
, h = Object.freeze(Object.defineProperty({
__proto__: null,
default: p
}, Symbol.toStringTag, {
value: "Module"
}))
, v = f(h)
so that this error is produced (see repro link above):
Uncaught ReferenceError: Cannot access 'Zt' before initialization
at _e (vendor-o4ka1zf0.js:9:5572)
at In (vendor-o4ka1zf0.js:12:15964)
at Fn (vendor-o4ka1zf0.js:12:19479)
at Tn (vendor-o4ka1zf0.js:12:30519)
at vendor-o4ka1zf0.js:12:30590
Additional Information
On my actual build (not the stack blitz) at what files are 'available' via source map, the whole 'util.inspect.js' file is missing
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 635
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rollup/plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Support js-yaml v5 Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
ecosystem wording
Difficulty 1/5 Under an hour Newbie friendliness 90/100
matrix-org/matrix.org#3649 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·