Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Process of virtual modules #315

Closed
alex-kinokon opened this issue Apr 30, 2018 · 12 comments
Closed

Process of virtual modules #315

alex-kinokon opened this issue Apr 30, 2018 · 12 comments

Comments

@alex-kinokon
Copy link

It seems that this plugin will attempt to process virtual modules generated by other plugins, contrary to the convention. rollup-plugin-ignore uses \0empty-module as a virtual module for an empty module file, which in turns is transformed by rollup-plugin-commonjs as \0commonjs-proxy:\0empty_module.

@lukastaegert
Copy link
Member

Can you confirm that this has happened with the change from 9.1.0 to 9.1.1?

In any case, I will re-release 9.1.0 as 9.1.2 now until we get to the bottom of this.

@lukastaegert
Copy link
Member

Done

@Nicd
Copy link

Nicd commented May 17, 2018

This is still occurring with rollup-plugin-commonjs 9.1.3. See this issue for full description of my config: alex-kinokon/rollup-plugin-ignore#2

@jeffijoe
Copy link

jeffijoe commented May 29, 2018

I came here by searching for rollup Cannot read property 'forEach' of null

I'm not sure what is causing this in my code, but if I remove the commonjs plugin, the error is different (because it can't process requires otherwise), so it leads me to believe this plugin is the root cause.

I am using the following plugins

plugins: [
  typescript(), // rollup-plugin-typescript2
  resolve(),
  commonjs()
]

Stack trace

TypeError: Cannot read property 'forEach' of null
    at Module.getReexports (node_modules/rollup/dist/rollup.js:17195:31)
    at new NamespaceVariable (node_modules/rollup/dist/rollup.js:7921:79)
    at Module.getOrCreateNamespace (node_modules/rollup/dist/rollup.js:17224:42)
    at Module.traceExport (node_modules/rollup/dist/rollup.js:17286:29)
    at node_modules/rollup/dist/rollup.js:20813:40
    at <anonymous>

@alex-kinokon
Copy link
Author

@lukastaegert I don’t think the commit has anything to do with this issue. commonjs needs to skip all modules starting with \0 except \0commonjs-proxy.

@lukastaegert
Copy link
Member

lukastaegert commented May 30, 2018

@jeffijoe I agree this has probably nothing to do with the current issue. From the stack trace this very much looks like an issue with rollup itself and should be raised there. The reason removing this plugin changes the error could be because the error originates from a CJS module.

Before raising an issue for rollup itself, make sure you are using the latest rollup version 0.59.4 as well as the latest version of the plugins. It would also be EXTREMELY helpful and significantly shorten the time until it is fixed if you could add a repo exposing the error.

@aleclarson
Copy link
Contributor

@lukastaegert I've reproduced the bug for you: https://github.com/aleclarson/rollup-bugs/tree/commonjs-issue-315

Hope that helps :)

@lukastaegert
Copy link
Member

@aleclarson Thanks! I already opened an issue on rollup for this an linked your repository: rollup/rollup#2317 (comment)

@aleclarson
Copy link
Contributor

@lukastaegert The bug demonstrated by my repro is fixed by PR #327 to this plugin. :)

@lukastaegert
Copy link
Member

Ah, I might have mixed up issues here. Thanks a lot! As I am just heading off to my vacation it might be a week until I can review it properly, though.

@guybedford
Copy link
Contributor

I've improved the error output for this case in rollup/rollup#2334.

The fix at #327 seems roughly the right direction to me.

lukastaegert pushed a commit that referenced this issue Sep 18, 2018
* fix: ignore virtual modules from other plugins

Closes #315

* Add test that virtual modules are ignored
@GongT
Copy link

GongT commented Oct 10, 2019

[src] [!] Error: 'empty_module' is imported as an external by empty_module?commonjs-proxy, but is already an existing non-external module id.
[src] Error: 'empty_module' is imported as an external by empty_module?commonjs-proxy, but is already an existing non-external module id.
[src]     at error (/data/DevelopmentRoot/canaan-creative/door/admin/app/node_modules/rollup/dist/rollup.js:10162:30)
[src]     at ModuleLoader.fetchResolvedDependency (/data/DevelopmentRoot/canaan-creative/door/admin/app/node_modules/rollup/dist/rollup.js:17226:24)
[src]     at ModuleLoader.<anonymous> (/data/DevelopmentRoot/canaan-creative/door/admin/app/node_modules/rollup/dist/rollup.js:17286:25)
[src]     at Generator.next (<anonymous>)
[src]     at fulfilled (/data/DevelopmentRoot/canaan-creative/door/admin/app/node_modules/rollup/dist/rollup.js:40:28)

zebapy added a commit to middlebury/midd-frontend that referenced this issue Nov 14, 2019
upgrades were causing rollup/rollup-plugin-commonjs#315

so removing rollup plugin ignore in favor of commonjs' ignore option works instead ONLY in this case because pikaday handles the check for momentjs with a try/catch
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants