Repository navigation
turbopack support - #1639
turbopack support#1639
Conversation
🦋 Changeset detectedLatest commit: bf149ba The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@mattcompiles @askoufis Can anyone take a look at this? This is a pretty important feature for next.js users. Or should we consider the project dead? Last PR was merged in early August, basically no activity from maintainers since then. Not meaning to bash anyone, I know it's thankless work maintaining open source software, but it would be nice to know what we can expect from this project. Thanks in advance! |
A PR was merged in September. Reviews take time and ongoing work is often slow. All current maintainers have professional commitments and/or families. I try to look at PRs when I have spare time/motivation, which is often quite sporadic. I'm currently on holiday, but I intend to make some headway on open PRs and repo maintenance in when I get back in early November. |
|
Thanks for your reply! I was a bit too dramatic, sorry about that. Enjoy your holiday, and let me know if I can help with anything to get this PR going. |
|
I see there have been some recent commits pushed up to this PR. Are there any bits that you need help with that could be provided to speed up getting this merged in? Appreciate that it's been a holiday period, but a lot of apps have performance issues with Next which has various potential solutions but the main recommendation seems to boil down to "just use Turbopack" vercel/next.js#48748. Obviously, the lack of support for Turbopack with Vanilla is effectively blocking us from getting those gains, which would be greatly appreciated ahead of Black Friday. It would be great if there were a list of tasks that I or people within my company could help out with to speed this up, whether that's commits or just QAing. Cheers and thanks for the work on this so far! |
This reverts commit 568bd26.
|
If you're interested in trying this out, I've been using a You can install that temporary build with a link: Although, you probably want to pin to a specific commit instead of the branch for the sake of stability: Feedback or issues appreciated! I haven't seen many stats yet on speed or size of builds (compared to webpack) so if you have those I'd love to see some details. The biggest issue with this at the moment is I'm gonna do a quick cleanup pass this week to prep this for merge, it's basically ready at this point but is still a bit messy while I'm experimenting with some stuff. TLDR:
|
|
Hmmm, strange, I followed your steps and got this error That seemed to point at this specific line in the dist It's probably worth saying that we don't have a pages dir at all, we're fully on app dir. To be fair as well, I'm not sure that this would work for us anyway as we make heavy use of When you say it's basically ready, do you mean basically ready minus support for next modules due to dependency on things turbopack isn't yet providing to help you preprocess styles? If you have a solution to the above error, more than happy to give it a whirl |
|
The error looks like resolution error in the webpack plugin setup. Should've seen that coming. As far as next/image support, you're free to style next images as this doesn't route through the plugin: The specific scenario that doesn't work is importing an image into a This is unlikely to change until we get better tools from turbopack. For The specific scenario that doesn't work is extending font classNames in your styles: This is also unlikely to change until we get better tools from turbopack. TLDR using next modules is fine, but using next modules in your styles themselves is likely to fail unless I've specifically worked around it. |
For me is fine, thanks, I also had next font issues with webpack so I don't mind this approach, thank you very much for your work, I'll try this ASAP |
@zecka I wasn't able to reproduce the issue on this repository when I cloned it. I would presume the issue is caused by the way things are linked on your filesystem. Just guessing here, but one potential issue that I have seen before is that you may need to configure Since you're using |
Implements Turbopack compatibility based on PR vanilla-extract-css#1639 by @RJWadley: - packages/compiler: add `splitCssPerRule` option, `invalidateAllModules()` method, and update `cssImportSpecifier` to accept CSS content + return Promise<string> - packages/css: add `vanilla.virtual.css` noop file for virtual CSS imports, update package.json exports and files list - packages/next-plugin: auto-detect Next >= 16 and configure Turbopack rules; add `turbopackMode` ('auto'|'on'|'off') and `turbopackGlob` options; add semver + @vanilla-extract/turbopack-plugin dependencies - packages/turbopack-plugin: new package — Turbopack webpack loader that compiles *.css.ts files via @vanilla-extract/compiler, encodes CSS into virtual query-param imports on vanilla.virtual.css, and handles next/font stubs via SWC transform https://claude.ai/code/session_0145VazPBZC9Q6nKK8gfjrXf
You’re right, it’s probably related to my local system configuration. |
askoufis
left a comment
There was a problem hiding this comment.
I've got a few questions and suggestions but overall this looks good. I'll do another review once the feedback has been addressed and I get more time to run the fixtures locally.
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
|
@askoufis thanks for the review! addressed feedback and replied to comments, I will leave resolving them up to you at your satisfaction. |
| if ( | ||
| type === 'next-12-pages-router' || | ||
| type === 'next-13-app-router' || | ||
| type === 'next-16-app-pages-router' |
There was a problem hiding this comment.
Probably worth addressing in a separate PR, but this change alone isn't enough to run the next 16 fixture.
next.config.js is hardcoded as the config file because next 12 and 13 don't support TypeScript config, but next 16 does.
But even when I hardcode .ts config, the next 16 fixture starts but navigating to the sprinkles page results in Styles were unable to be assigned to a file errors.
Another thing I noticed when running the built next 16 app was that navigating to a fixture page then going back and navigating to another page accumulated stylesheets from both pages. You can keep doing this for all the pages in the app, resulting in some broken styles.
The most obvious way to see this to go to the duplication test page, then back, and then the sprinkles back and then back again. You end up with body styles from both pages.
There was a problem hiding this comment.
I actually had lots of issues trying to use the start-fixture CLI with next. Since I don't think it's really representative of the way folks run next in reality, I didn't invest much time in trying to fix it and opted instead to use the official tooling. See tests/servers.ts for more details. I actually quite liked doing it this way, and am considering reworking the fixture system in a follow-up to make testing VE more consistent across all the supported bundlers.
With respect to the global styles "leaking" across pages, this is currently expected behavior per the next docs and the react docs. React makes no attempt to clean up stylesheets when components that use them unmount. I have invested a lot of time and energy into trying to fix that in upstream react, but it is actually quite complex to do universally with good performance. I imagine it won't be fixed until some youtuber makes a clickbait video with a title like "I made react's styles 40 billion times faster" at which point the facebook geniuses will take notice and write some really good code to fix it for real
I wouldn't mind attempting to fix this for vanilla extract specifically, but it definitely belongs in a future PR (if at all).
There was a problem hiding this comment.
Fair enough. I think it makes more sense to handle Next.js separately from the rest of the bundler integrations, so happy for more effort to be put into that in the future.
I do want to make the fixture CLI much better for all bundlers at some point.
Re: react - I'm not sure how much framework-specific stuff we want to put into Vanilla Extract, if any. If there's a need for it then maybe it's worth working on in the future.
|
Turbopack support has been released in v2.5.0 of the next plugin. |
adds turbopack support to
@vanilla-extract/next-pluginturbopack doesn't have any sort of external API yet, so in order to evaluate the contents of our
*.css.tsfiles we need to compile it separately using@vanilla-extract/compiler. To avoid import resolution mismatches, we defer module resolution to turbopack via its webpack-compatible api.next/fontdoesn't work out of the box because turbopack has custom logic for it, so we transform any modules that use it in a css context to contain static references to the generated font family, style, and weight.next/imagegets a similar treatment. most other next modules won't work incss.tsfiles for now.fixes #1367