Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin-virtual: fails for imports via require #248

Closed
danimoh opened this issue Mar 9, 2020 · 1 comment
Closed

plugin-virtual: fails for imports via require #248

danimoh opened this issue Mar 9, 2020 · 1 comment

Comments

@danimoh
Copy link
Contributor

danimoh commented Mar 9, 2020

  • Rollup Plugin Name: @rollup/plugin-virtual
  • Rollup Plugin Version: 2.0.1
  • Rollup Version: 2.0.2
  • Operating System (or Browser): Fedora
  • Node Version: 12.13.1

How Do We Reproduce?

https://repl.it/repls/RegalIdioticMicrokernel

Expected Behavior

Should replace import regardless of whether es6 import or require is used.

Actual Behavior

Error: 'virtual:the-answer' is imported as an external by virtual:the-answer?commonjs-proxy, but is already an existing non-external module id.

When using an es6 import everything works fine, but not when using require.
Additionally, when using both at the same time, it compiles but the result is unexpected.

Potentially related to rollup/rollup-plugin-commonjs#315 and rollup/rollup-plugin-commonjs#327.

Use case

A lib I wanted to import contains a conditional require('crypto') for Node. This require was converted to a non-conditional import by commonjs (I assume). I wanted to get rid of that import by defining a mock module via @rollup/plugin-virtual.

@shellscape
Copy link
Collaborator

Hey folks. This issue hasn't received any traction for more than 90 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

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

No branches or pull requests

2 participants