Dschungelabenteuer / vite-plugin-entry-shaking

Mimic tree-shaking behaviour when importing code from an entry file in development mode.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unsupported syntax in files that are not target files - export { Foo as Bar } from "..."

fdc-viktor-luft opened this issue · comments

When using export { Foo as Bar } from "..." and then re-exporting "Bar" from a target file, then "Foo" will be tree-shaken even if "Bar" is used.

When changing this:

export { Foo as Bar } from "...";

to that

import { Foo as Bar } from "...";
export { Bar };

then it works all fine.

commented

Thanks for reporting! Could you by any chance provide a minimal repro?
I may need a small clarification, especially around that part of your description:

then "Foo" will be tree-shaken even if "Bar" is used

I've just set up a documented example to illustrate how I actually understood your issue's description, it may help you understand where's the confusing part for me.

From what you created, you got the idea right, but I can see that in your repro it works. I will try to figure out the difference to my project setup that might be missing here.

Update: I found the difference. Will try to narrow it down even further now.

I've created a PR with an example that demonstrates the issue: #32

commented

Thank's a lot, I'll take a look this week-end!

commented

@fdc-viktor-luft just to keep you posted, I did not forget about this and I've already fixed the issue on my side; but I'm also working on several other issues/features I'd like to deploy at once. Unfortunately I didn't have much spare time lately, please let me know if this can still wait a bit on your side. I may still deploy a dedicated patch if this takes too much time

Thanks again for digging the differences between our two cases, it was definitely helpful!

I'm not sure if this is the same issue, but i get error when there is an aliased import in a file and that file has a declaration which has the same name as the original import.
Example:

import {Flyout as FlyoutBase} from '@monorepo/package-one';

export const Flyout = () => {
   return <FlyoutBase />
}

The code throws error Duplicate identifier Flyout :(