Commit graph

9 commits

Author SHA1 Message Date
Tobias Koppers
512539821d fix runtime code for server rendered content source (vercel/turbo#315)
move transition into turbopack
2022-09-07 15:56:10 +02:00
Alex Kirszenberg
e55a098efd CSS HMR (vercel/turbo#296)
Implements HMR for CSS chunks and paves the way for accepting HMR updates for the HTML entry point as well.
2022-09-03 11:38:14 +00:00
Alex Kirszenberg
1e8d63d10d Postfix join and try_join (vercel/turbo#300)
Instead of dropping back to prefix calling form in `try_join_all(iterator_of_intofutures).await?`, we now use postfix form `iterator_of_intofutures.try_join().await?`.
2022-08-30 15:15:06 +00:00
Alex Kirszenberg
8f54f35e90 HMR support + React Refresh (vercel/turbo#252)
This PR implements HMR support with React Refresh built-in.

For now, in order for React Refresh to be enabled, you'll need the `@next/react-refresh-utils` package to be resolveable: `yarn add @next/react-refresh-utils` in your app folder.

* Depends on vercel/turbo#266 
* Integrated both HMR-and-React-Refresh-specific logic directly into the ES chunks' runtime. Webpack has more complex setup here, but for now this makes the logic much more easy to follow since everything is in one place. I have yet to implement the "dependencies" signature for `hot.accept`/`hot.dispose`, since React Refresh does not depend on them. We'll have to see if they're even used in the wild or if we should deprecate them.
* Only implemented the [module API](https://webpack.js.org/api/hot-module-replacement/#module-api), not the [management API](https://webpack.js.org/api/hot-module-replacement/#management-api). We apply all updates as soon as we receive them.
* Added support for "runtime entries" to ES chunks. These are assets that will be executed *before* the main entry of an ES chunk. They'll be useful for polyfills in the future, but for now they're here to evaluate the react refresh runtime before any module is instantiated.

Next steps for HMR:
* Implement CSS HMR
* Implement (or decide to deprecate) the [dependencies form](https://webpack.js.org/api/hot-module-replacement/#accept) of `hot.accept`/`hot.dispose`
* Clean up `runtime.js` some more: switch to TypeScript, split into multiple files, etc. It'd be nice if all of this could be done at compile time, but how to achieve this is unclear at the moment. _Can we run turbopack to compile turbopack?_
2022-08-26 16:30:04 +00:00
Tobias Koppers
32d10a037a resolve entrypoint to allow it to select jsx automatically (vercel/turbo#278) 2022-08-26 11:26:58 +00:00
Tobias Koppers
44eec9b9e0 only create pages for .js etc. files in pages (vercel/turbo#255) 2022-08-23 13:24:25 +00:00
Tobias Koppers
078f4d8191 Do not execute .css during server rendering (vercel/turbo#254)
Ignore any non-code chunks for server rendering
2022-08-23 11:47:39 +00:00
Leah
c867a32ba1 fix: fs errors when running next-dev with pages (vercel/turbo#253) 2022-08-18 14:12:40 +00:00
Tobias Koppers
eab61f3c65 add basic next pages support (vercel/turbo#223)
Server Rendering:

* This adds an additional ContentSource to next-dev which takes care of handling the `pages` directory.
* The content source creates a ServerRenderedAsset from each file in the `src/pages` or `pages` directory and a AssetGraphContentSource for that.
* The ServerRenderedAsset will reference an underlying asset for the node.js context which will be passed to the node executable for rendering. It uses a WrapperAsset to add additional communication logic.

Client Transition:

* When annotating `import`s with `transition: "next-client"` the NextClientTransition is used
* This transition changes the environment to browser
* It wraps the referenced asset with a next-hyrdation wrapper asset
* It leaves a little module in the previous context which exports a list of URLs for chunks needed.
* The NextClientTransition takes a client_chunking_context as argument which specifies how the client code is chunked.
2022-08-15 17:26:37 +00:00