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

🐛 Importing two different modules results in them exporting identical object #551

Closed
yunyu opened this issue Jan 12, 2018 · 5 comments
Closed

Comments

@yunyu
Copy link

yunyu commented Jan 12, 2018

🎛 Configuration (.babelrc, package.json, cli command)

.babelrc:

{
    "presets": ["env"],
    "plugins": ["inferno"]
}

🤔 Expected Behavior

If I do the following:

import Inferno from 'inferno';
import Component from 'inferno-component';
console.log(Inferno === Component);

I expect it to log false in the console.

😯 Current Behavior

Instead, it logs true. The same occurs if I reverse the ordering of the imports, and Component still doesn't export correctly (instead it exports what Inferno should export) even if I remove the inferno import. This does not happen with Rollup.

💁 Possible Solution

Not sure ;(

🔦 Context

I am trying to import inferno and inferno-component so I can use class components with my Inferno application. Unfortunately, they return the exact same object. I suspect this may be an issue with any two modules in which the name of one starts with the name of the other.

💻 Code Sample

https://github.com/vanderbilt-design-studio/site-overrides/blob/fecc54137c4e83f29ef2ab2cdb09b519e16de379/overrides.jsx

https://github.com/yunyu/parcel-duplicate-module-reprod

🌍 Your Environment

Software Version(s)
Parcel 1.4.1
Node 8.9.4
npm/Yarn NPM
Operating System Windows 10 x64
@yunyu
Copy link
Author

yunyu commented Jan 12, 2018

Here is a very minimal reproduction case:

https://github.com/yunyu/parcel-duplicate-module-reprod

To run, do yarn build && yarn start. It should print false, but it prints true instead. Minification is disabled in the build.

If you run node index-noparcel.js, it prints false as expected.

@yunyu yunyu changed the title Importing two different modules results in them exporting identical object 🐛 Importing two different modules results in them exporting identical object Jan 16, 2018
@yunyu
Copy link
Author

yunyu commented Jan 25, 2018

Would someone be able to look into this? I think this could be indicative of a deeper issue.

@DeMoorJasper
Copy link
Member

I've taken a look at it, can confirm something might be off here, but the code that's being required looks quite identical here, not sure if this is a bug (can't look further into it atm)

@yunyu
Copy link
Author

yunyu commented Jan 25, 2018

Thanks for verifying. If I do a require() without Parcel, the two modules return different types (Inferno returns an Object while Component returns a function):

const Inferno = require('inferno');
const Component = require('inferno-component');

// Should print false
console.log(Inferno === Component);
// Should print object
console.log(typeof Inferno);
// Should print function
console.log(typeof Component);

Inferno is supposed to be an object, which is correct. Source file:
https://github.com/infernojs/inferno/blob/v3.5.4/packages/inferno/src/index.ts#L58

Component is supposed to be a subclassable function. Source file: https://github.com/infernojs/inferno/blob/v3.5.4/packages/inferno-component/src/index.ts#L196

Output on my machine:

Could it be an issue with different types of exports breaking the cache?

@devongovett
Copy link
Member

Not an issue in Parcel 2

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

3 participants