Anber / wyw-in-js

MIT License
191 stars 8 forks source link

`export * from 'xxx'` statements are incorrectly omitted by wyw #82

Open hjkcai opened 2 months ago

hjkcai commented 2 months ago

Environment

Description

As the issue title said. I tried to debug the webpack loader. I am sure that wyw's loader has omitted the export * statement.

image

Reproducible Demo

Source Code:

// main.js
import { foo, bar } from './a';
console.log(foo, bar); // cannot find 'foo'

// a.js
export * from './b';
export const bar = 'baz';

// b.jsx
export const foo = 42;

Configuration File (wyw-in-js.config.js):

module.exports = {
  extensions: ['.js'],
};
layershifter commented 2 months ago

Can you please provide a complete example on Stackblitz?

hjkcai commented 1 month ago

https://stackblitz.com/edit/webpack-5-react-starter-sywkqd

I found the key problem: If b.jsx was ignored from wyw, and a.js has export * from './b', the statement will be removed by wyw in explodeReexports.ts Line 98.

image

In my project, all .ts files are ignored to make compliation faster. Only .tsx files are processed by wyw. Then this issue occurs.

hjkcai commented 1 month ago

@layershifter Hi! Any thoughts?