Skip to content

node-resolve plugin discards this re-exported file #1946

Open

Description

@AncientSwordRage

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

Activity

  1. AncientSwordRage commented on Nov 25, 2025

    @AncientSwordRage
    Author

    It looks like this is a known compatibility issue: object-inspect/issues/18

    Which has been reported and 'fixed' before: rollup-plugin-node-resolve/pull/183

    And I found this part of the docs: Resolving Built-Ins (like fs).

    But I haven't gotten it to work, but I've updated the repro link to reflect what that doc says

    edit: You need to call npm run build && npm run preview to see this

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

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