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

sideEffects and export * from #2795

Open
nkroe opened this issue Jan 5, 2023 · 5 comments
Open

sideEffects and export * from #2795

nkroe opened this issue Jan 5, 2023 · 5 comments

Comments

@nkroe
Copy link

nkroe commented Jan 5, 2023

Hi,
I have that simple structure:

package.json
...
"sideEffects": false,
...
src/components/modal/index.tsx
import { ModalBody } from './components';
import { SomeComponent } from './someComponent';

export const Modal = () => <div></div>;

Modal.SomeComponent = SomeComponent;
Modal.Body = ModalBody;
src/components/modal/components/index.ts
export * from './body';
src/components/modal/components/body/index.tsx
import './style.less';

export const ModalBody = () => <div></div>;
src/components/modal/someComponent/index.tsx
import './style.less';

export const SomeComponent = () => <div></div>;

As you can see src/components/modal/components/index.ts has export * from
After build i has that result

Result with export * from
{
  'components/modal/index.js': {
    'src/components/modal/components/body/style.less': {}, 
    'src/components/modal/components/body/index.tsx': {},
    'src/components/modal/someComponent/style.less': {},   
    'src/components/modal/someComponent/index.tsx': {},  
    'src/components/modal/index.tsx': {}
  },
  'components/modal/index.css': {
    'src/components/modal/someComponent/style.less': {}
  }
}

components/modal/index.js has:

  1. src/components/modal/components/body/index.tsx
  2. src/components/modal/components/body/style.less

But components/modal/index.css have only src/components/modal/someComponent/style.less


If we change src/components/modal/components/index.ts to this

Changed src/components/modal/components/index.ts
export { ModalBody } from './body';

Now we got this result:

Result with export { ModalBody } from
{
  'components/modal/index.js': {
    'src/components/modal/components/body/style.less': {},  
    'src/components/modal/components/body/index.tsx': {}, 
    'src/components/modal/components/index.ts': {},
    'src/components/modal/someComponent/style.less': {},    
    'src/components/modal/someComponent/index.tsx': {},   
    'src/components/modal/index.tsx': {}
  },
  'components/modal/index.css': {
    'src/components/modal/components/body/style.less': {},
    'src/components/modal/someComponent/style.less': {}
  }
}

Now components/modal/index.js has

  1. src/components/modal/components/body/index.tsx
  2. src/components/modal/components/body/style.less
  3. src/components/modal/components/index.ts !!!

And components/modal/index.css now has src/components/modal/components/body/style.less !!!

How i can fix that without change export * from to export {...} from or it is bug?

Thanks.

@nkroe
Copy link
Author

nkroe commented Jan 7, 2023

@evanw any thoughts here?

@majo44
Copy link

majo44 commented Jan 10, 2023

We have same issue. Replacing export * from by export {...} from is working workaround.

@nkroe
Copy link
Author

nkroe commented Jan 10, 2023

@majo44 We temporary solved this by marks of index.ts files as sideEffects , waiting for @evanw response

@PrzemyslawMikos
Copy link

Hi!
I also face this issue in my project. We use export {...} from 'x'; as workaround, however it would be really beneficial to have this issue solved as it affects runtime.
In order to help identify the issue I've made a simple example repository (CLICK ME!) which visualises the issue.
I've also checked the output of build files and I've noticed the difference between working and non working version:
Difference

I hope above example will help with solving that issue. In case of any question in regard of this please don't hesitate to contact me.

@wsuwt
Copy link

wsuwt commented Jun 23, 2023

We are facing the same issue as well. It would be great to be able to leverage export * from 'module' with esbuild.

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

4 participants