rsnext/test/e2e/app-dir/app-external/app
Jiachi Liu a035224dc3
Pick esm main fields and condition names first for RSC server layer (#50548)
For RSC server layer so far we bundle all dependencies, ESM format is the better one rather than CJS to analyze and tree-shake out the unused parts. This PR changes pick the condition names that are in ESM format first for server layer.

Also fixes the misorder of condition names of edge runtime, `conditionNames` should only contain either ESM or CJS, previously the main fields are mixed with conditon names which is not expected for webpack, we separate them now.

Since we're picking ESM instead CJS now, the error of require `exports * from` doesn't exist anymore, but if you're using a CJS dependency which require a ESM package, it will error. This is the existing behavior for our webpack configuration but could happen on server layer bundling

Other related changes:

* Imports are hoisted in ESM, so migrate`enhanceGlobals` to a imported module
* Use `...` to pick the proper imports by import expression, and prefer the `react-server` / `edge-light` condition names for corresponding cases
* Remove edge SSR duplicated `middleware` export checking
2023-06-08 16:24:03 +00:00
..
client-dep Fix package resolution issue in app dir (#43349) 2022-11-25 01:19:21 +00:00
css Eagerly bundle external ESM dependencies for pages (#42741) 2022-11-10 18:11:38 +01:00
esm Pick esm main fields and condition names first for RSC server layer (#50548) 2023-06-08 16:24:03 +00:00
esm-client-ref Fix client boundary defined in a module (#46171) 2023-02-21 15:20:45 +00:00
external-imports Fix resolving for esm package with only exports.import condition (#42767) 2022-11-11 00:50:46 +00:00
font Eagerly bundle external ESM dependencies for pages (#42741) 2022-11-10 18:11:38 +01:00
react-server Eagerly bundle external ESM dependencies for pages (#42741) 2022-11-10 18:11:38 +01:00
shared-esm-dep Eagerly bundle external ESM dependencies for pages (#42741) 2022-11-10 18:11:38 +01:00
wildcard Fix conflict when re-exporting multiple Client References (#49468) 2023-05-16 12:35:12 +02:00
layout.js Eagerly bundle external ESM dependencies for pages (#42741) 2022-11-10 18:11:38 +01:00