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

CSS code-splitting with "rollup-plugin-styles" is broken by PR #4104 (Rollup v2.50.2) #4130

Closed
AurelienStebe opened this issue Jun 6, 2021 · 3 comments · Fixed by #4138
Closed

Comments

@AurelienStebe
Copy link

Expected Behavior

The output of Rollup v2.50.1, which makes CSS code-splitting with static CSS outputs possible.

Actual Behavior

Since Rollup v2.50.2 (still the same in the recent v2.51.0 release), the CSS code-splitting doesn't work. The CSS code is duplicated between outputs and the static assets overwrite each others.

I traced the change to PR #4104 and this new "if" condition in particular :

rollup/src/Module.ts

Lines 368 to 370 in 592b9fe

if (dependency instanceof ExternalModule || dependency.isIncluded()) {
relevantDependencies.add(dependency);
}

The modules are not external, so I think the issue is with isIncluded() and effectively the ast.included and namespace.included booleans are false in my logs.
Unfortunately, this is where my knowledge ends. The question is, should "rollup-plugin-styles" change something or should the lines above be changed ? ... and why (just curious) ?

I am not the maintainer of "rollup-plugin-styles", but I do use it in my frontend framework project (GladeJS).
I know this is on the hackish-side of Rollup usage, but I was about to release my CSS code-splitting feature. 😇

@lukastaegert
Copy link
Member

I will have a look

@lukastaegert
Copy link
Member

lukastaegert commented Jun 10, 2021

I created a fix at #4138, please verify that it really solves the issue and the plugin is now working as expected. Basically what is happening is that when you set a module to no-treeshake, now all imported modules will be included and may generate chunks, even empty ones.

@AurelienStebe
Copy link
Author

Yes, I can confirm that the PR works, even in the middle of my complex Rollup config.
Thanks a lot, this is exactly what I need to trace the CSS dependencies. Excellent job, as always. 👍

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

Successfully merging a pull request may close this issue.

2 participants