Skip to content

rollup --config re-computes imported import.meta.url #3758

@ctjlewis

Description

@ctjlewis
  • Rollup Version: Latest
  • Operating System (or Browser): Linux
  • Node Version (if applicable): Latest
  • Link to reproduction (IMPORTANT, read below): https://repl.it/repls/DaringRoughHypertalk
    Clicking RUN will print url as seen by node rollup.config.js and rollup -c rollup.config.js.

Expected Behavior

When exporting via:

// index.js
export const url = import.meta.url;

And importing in a Rollup config that will be executed with rollup -c:

// rollup.config.js
import { url } from './index.js'

url should equal the import.meta.url for the file in which it is exported, in this case, file:///path/to/index.js.

Actual Behavior

Rollup seems to rewrite import.meta.url source in the config file such that import.meta.url is re-computed at runtime, and url is equal to file:///path/to/rollup.config.js. This conflicts with Node's output, and causes errors in compiled bundles.

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