Dschungelabenteuer / vite-plugin-entry-shaking

Mimic tree-shaking behaviour when importing code from an entry file in development mode.
MIT License
118 stars 8 forks source link

Multiline export statements are not parsed properly #35

Closed mx-bernhard closed 5 months ago

mx-bernhard commented 10 months ago

Describe the bug When having a folder with an index.ts and a subfolder with another index.ts and using prettier the subfolder is re-exported from the parent index.ts like that:

export {
 a,
 b,
} from 'sub-folder';

This causes the logic to recognize export symbols to not see them.

To Reproduce

See my repro.

  1. cd ./examples/simple
  2. pnpm run dev
  3. Open browser on location
  4. See error browser console: main.ts:1 Uncaught SyntaxError: The requested module '/src/folder/index.ts' does not provide an export named 'a' (at main.ts:1:22)

Expected behavior

The example view is shown

Additional context It works when I change

export {
  a,
  b,
} from './subfolder';

to this

export { a, b } from './subfolder';

But, we have way more entries in that export statement and prettier reformats them into this multi-line version.