rsnext/test/e2e/app-dir/rsc-basic
Jan Nicklas 9e1e9bf311
Fix/match resource (#53796)
### Bug Fix
fixes #53366



### Change

Add `query` and [`matchResource`](https://webpack.js.org/api/loaders/#inline-matchresource) to the module mapping. 



### Why

`mod.resource` and all other paths inside `packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts` are already using the query:

e127c51327/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts (L506-L507)

e127c51327/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts (L584-L585)



### Motivation

We are using a static extraction css-in-js solution which uses the [inline match resource feature](https://webpack.js.org/api/loaders/#inline-matchresource) (see more in #53366)

As a css-in-js file contains the TSX and the CSS code we have to split the file into two modules which share the same `resource.path`.  

This works well however there is a problem in the mapping inside `.next/server/app/page_client-reference-manifest.js`.
The `ssrModuleMapping` from `addSSRIDMapping` in 
e127c51327/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts (L270) links to the latest module (the css part) and not the the initial one (the js part).

Therefore the css module is rendered [react-server-dom-webpack](https://www.npmjs.com/package/react-server-dom-webpack/v/0.0.1?activeTab=versions) and breaks.

The SSR/SSG fails with the error `Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.`

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-08-11 17:36:58 +00:00
..
app Fix/match resource (#53796) 2023-08-11 17:36:58 +00:00
components Drop object config export support for app dir (#48489) 2023-04-17 20:02:32 +00:00
lib Handle dynamic css-in-js styles under suspense (#42293) 2022-11-02 14:18:08 +01:00
pages Fix pages react alias (#50128) 2023-05-22 23:37:27 +00:00
public Migrate rsc integration tests to e2e tests (#38460) 2022-07-09 14:02:30 +02:00
next.config.js Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
rsc-basic.test.ts Fix/match resource (#53796) 2023-08-11 17:36:58 +00:00