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

Tree-shaking not working as expected #1

Open
AndreasMaros opened this issue Oct 27, 2021 · 1 comment
Open

Tree-shaking not working as expected #1

AndreasMaros opened this issue Oct 27, 2021 · 1 comment
Labels
bug Something isn't working on hold Things that have to wait

Comments

@AndreasMaros
Copy link
Member

When using the library in a project and importing the frontend factory from the default module entrypoint:

import { LightboxFactory } from '@gebruederheitz/wp-block-video-overlay'

const lb = new LightboxFactory();

the resulting rollup bundles (both ESM and IIFE) include the backend modules.

Importing the the frontend module directly fixes the issue, but is inconvenient:

import { LightboxFactory } from '@gebruederheitz/wp-block-video-overlay/dist/frontend'
@AndreasMaros AndreasMaros added bug Something isn't working miniprojekt Support stuff that isn't done quickly labels Oct 27, 2021
@yellowled
Copy link

yellowled commented Jan 10, 2022

If imported from the default module entry point, rollups says:

rollup v2.63.0
bundles src/js/main.js → _site/js/main.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
wp (imported by node_modules/@gebruederheitz/wp-block-video-overlay/dist/editor.js)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
wp (guessing 'wp')

(Which I guess is more a consequence of the tree shaking not working than anything else.)

And, by the way, the same for wp-block-slideshow – need to import { SlideshowFactory } from '@gebruederheitz/wp-block-slideshow/frontend/slideshow-factory'; instead of import { SlideshowFactory } from '@gebruederheitz/wp-block-slideshow';

I'm rather sure this is an issue with the rollup config. Maybe we need to set a name? Is Rollup confused because we have an index.js as well as a src/index.js?

@yellowled yellowled assigned yellowled and unassigned yellowled Jan 10, 2022
@AndreasMaros AndreasMaros added on hold Things that have to wait and removed miniprojekt Support stuff that isn't done quickly labels Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working on hold Things that have to wait
Projects
None yet
Development

No branches or pull requests

2 participants