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

Make css dependency graph of js modules #9407

Merged
merged 10 commits into from Dec 2, 2020

Conversation

jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Nov 27, 2020

References

This explores implementing #9375 (comment)

This depends on jupyterlab/lumino#136, which is a companion PR that adds similar style/index.js files to Lumino. This has been merged and released.

This approach avoids the problems with css-loader not deduplicating css noted in #9364

Code changes

This introduces a dependency graph for css using a new convention, style/index.js files. This way the dependency tree is in js, so it takes advantage of all of the webpack bundling, module federation sharing, etc., but doesn't hardcode a css import in the main js file. At the top application level, instead of generating an import.css with all the css imports, we generate a style.js file.

With this change, we are able to upgrade css-loader and still maintain about 100 style tags on the page with no duplicates that I saw.

Overall, I think deduplicating the actual css at runtime (#9375 (comment)) is probably a better thing to do in the end, but I'm not sure how straightforward that approach will be or how long it will take, so I opted to first do this approach for 3.0, where I could pretty clearly see what to do.

User-facing changes

Backwards-incompatible changes

@jasongrout jasongrout added this to the 3.0 milestone Nov 27, 2020
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@jasongrout
Copy link
Contributor Author

I updated the css-loader, and confirmed that we still only have about 100 style tags on the page (now that we are not relying on css-loader to do deduplication). Whether this holds out for lots of extensions is to be determined - we may still need to further automate a solution for extensions, for css-loader to do deduplication at the page level at runtime, or revert back to our old version of css-loader.

@jasongrout
Copy link
Contributor Author

I rebased and cleaned up/combined commits.

We also change to not add dependency css for theme packages. The theme css bundler cannot handle dependency imports. Explicitly specifying the dependencies to ignore for built-in themes does not solve the problem when linking a local theme extension, as happens in the usage test with the “foo” extension.
This brings in jupyterlab/lumino#136 so we can deduplicate Lumino widget css without relying on css-loader.
We can update now that we are not relying on css-loader to do deduplication of css.

This addresses a main issue of jupyterlab#9364 and paves the way to addressing jupyterlab#6542
I had to run integrity twice to percolate css changes through the dependencies.
@jasongrout jasongrout marked this pull request as ready for review December 2, 2020 07:11
@jasongrout
Copy link
Contributor Author

I think this is ready for review at this point. After review, it would be great to get another RC with this released.

@jasongrout jasongrout changed the title Make css dependency tree of js modules Make css dependency graph of js modules Dec 2, 2020
builder/src/build.ts Outdated Show resolved Hide resolved
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks (pending the suggested change above)!

@cceyda
Copy link

cceyda commented Dec 3, 2020

I'm getting mathjax error with the jlab 3.0.0rc11
image

which makes the cells become weird:
image

This is probably related to some commit that is after 3d81e1a (which didn't have this problem)

@jasongrout
Copy link
Contributor Author

Indeed, I'm also seeing very strange things happening with notebook cells in 3.0rc11. I'll open a new issue.

@jasongrout
Copy link
Contributor Author

I opened #9423 about the issue, and fixed the underlying issue in #9427.

@jasongrout
Copy link
Contributor Author

@cceyda - 3.0rc12 was released just now fixing those codemirror issues. Thanks again.

@github-actions github-actions bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jun 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design System CSS pkg:application pkg:apputils pkg:attachments pkg:cells pkg:celltags pkg:codeeditor pkg:codemirror status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. tag:CSS For general CSS related issues and pecadilloes tag:Examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants