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

🐛 Incorrect module resolution when one import name matches along the parent path (only on build) #793

Closed
jsiebern opened this issue Feb 12, 2018 · 1 comment
Labels

Comments

@jsiebern
Copy link
Contributor

jsiebern commented Feb 12, 2018

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

{
  "scripts": {
    "build": "parcel build src/index.js"
  }
}
{
    "presets": [
        [
            "env",
            {
                "modules": false
            }
        ]
    ]
}

I have a directory structure of imports like so:

index.js
sub/test/index.js
sub/test/tabs.js
sub/test.landscape/index.js
sub/test.landscape/tabs.js

The top index.js imports both lower index.js and each of them have the content:

export { default } from './tabs';

🤔 Expected Behavior

In the outputted file I expect the ids for "./sub/test" and "./sub/test.landscape" to be different, wich they even are when not using the build command.

For example:

{"./sub/test":3,"./sub/test.landscape":4}

😯 Current Behavior

Using the build command it outputs:

{"./sub/test":2,"./sub/test.landscape":2}

So the same id, that causes my code to break in production where in development it runs fine.

💁 Possible Solution

I only had a brief glance at the code debugging this, it might have something todo with the common ancestor search? Totally not sure on that one, sorry.

🔦 Context

As this is only a "beautification" for filenames (putting the main file of the subfolder as tabs.tsx for example instead of index.tsx, its not a big deal to work around. I still believe it to be a bug though.

💻 Code Sample

I have attached some example code, just run yarn; yarn build and check the dist/index.js for the faulty result.

error_example.zip

@jeyj0
Copy link

jeyj0 commented Aug 24, 2018

Hi, I was just looking into this, and tried to reproduce it using your given example.

  • Using the Version in the example I can indeed verify that there is the described, buggy behavior.
  • However, using the newest version of parcel-bundler (1.9.7) I got: {"./sub/test":"C2SW","./sub/test.landscape":"BZFw"} which seems to be correct as far as I understand the issue.

I would therefore suggest closing this issue as being resolved. 😄

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

No branches or pull requests

3 participants