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

Multiple imports from different files from one file are imported wrong with esm module #149

Closed
a-gerescher opened this issue May 26, 2020 · 2 comments

Comments

@a-gerescher
Copy link

a-gerescher commented May 26, 2020

At first, let me sincerely thank for your efforts. What an extraordinary speed in a bundler, and i have tried all of them.

Unfortunately i have found a bug.

If you define esm as output format, and are importing from different files the same method, i believe something is not like it should be.

First file app.js:

import { p as Part, h, render } from './import';
import { Internal } from './in2';
const App = () => <Part> <Internal /> T </Part>;
render(<App />, document.getElementById('app'));

Second file in2.js:

import { p as Part, h } from './import';
export const Internal = () => <Part> Test 2 </Part>;

Third file import.js:

import { h, render } from 'preact';
export const p = "p";
export { h, render }

output:

// src/import.js
import {h, render} from "preact";
const p = "p";

// src/in2.js
const Internal = () => h3(p, null, " Test 2 ");

// src/in.js
const App = () => h2(p, null, h2(Internal, null), " T ");
render2(h2(App, null), document.getElementById("app"));

Note the broken h2, render2, h3 functions.

Preact is marked as external file, output format esm. Yes i know this is an uncommon way of doing it. But, in other bundlers, output bundle is smaller, because the reexported function is only referenced once, and i am able to reuse it, and its possible to reexport it with the same name. What is important, with h and render in react/preact ...

Thank you.

@evanw
Copy link
Owner

evanw commented May 26, 2020

Thank you for the clear description of what's wrong and for the minimal test case. It looks like I'm not binding imports to re-exports. I'm surprised I haven't run into this issue yet with all of my testing. This will be fixed soon.

@evanw evanw closed this as completed in bf457c3 May 26, 2020
@a-gerescher
Copy link
Author

Thanks a lot!

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

No branches or pull requests

2 participants