rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
501 stars 126 forks source link

commonjs-proxy bug on case insensitive file system like macOS #408

Closed newset closed 4 years ago

newset commented 5 years ago

It is a rare use case, but the bug will show with the steps below on macOS (it's default filesystem is case insensitive)。

  1. use this plugin with rollup-plugin-node-resolve
  2. import two npm packages with cjs format include files the same name but different case;
  3. in rollup.config.js set preserveModules: true

then the file structure is like this

- dva
  - index.js
  - subscription.js
- redux
  - index.js
  - Subscription.js

the output bundle will be as follow

dist
    _virtual
        _commonjsHelpers.js
        subscription.js_commonjs-proxy
    js_modules
        dva
            index.js
            subscription.js
        redux
            index.js
            Subscription.js
    index.js
    page.js

the bug come with this dist/_virtual/subscription.js_commonjs-proxy file, actually there should be two subscription.js_commonjs-proxy files there。cause the filesystem treat subscription.js_commonjs-proxy and Subscription.js_commonjs-proxy as one identical file。 eventually the code will not run at all.

the right output should be

dist
    _virtual
        _commonjsHelpers.js
        Subscription.js_commonjs-proxy
        Subscription2.js_commonjs-proxy
    js_modules
        dva
            index.js
            subscription.js
        redux
            index.js
            Subscription.js
    index.js
    page.js

here is the demo repo https://github.com/newset/commonjs-proxy-bug

shellscape commented 4 years ago

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid.

We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets reopened and transferred to the new repo. :beer: