Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable esm resolving for appDir and alias react (#41687)
When esm package that depending on react is used between `pages/` and `app/`, it's loading the user installed react through esm loader which doesn't go through require hook, so we cannot intercept it with require-hook. Disable esm resolving when `appDir` is enabled for now, prefering to pick the cjs bundle so that react import is intercepted by require hook and pointing to the built-in react Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
Showing
10 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { | ||
loadRequireHook, | ||
overrideBuiltInReactPackages, | ||
} from '../build/webpack/require-hook' | ||
|
||
loadRequireHook() | ||
|
||
const isPrebundled = false | ||
|
||
if (isPrebundled) { | ||
overrideBuiltInReactPackages() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
import useSWR from 'swr' | ||
import styles from '../styles/shared.module.css' | ||
|
||
export default function Page(props) { | ||
const { data } = useSWR('swr-index', (v) => v, { fallbackData: 'swr-index' }) | ||
return ( | ||
<> | ||
<b>rc:{React.Component ? 'c' : 'no'}</b> | ||
<p className={styles.content}>hello from pages/index</p> | ||
<Link href="/dashboard">Dashboard</Link> | ||
<div>{data}</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.default = () => 'esm-export' | ||
exports.named = 'named' | ||
exports.value = 123 | ||
exports.array = [4, 5, 6] | ||
exports.obj = { x: 1 } |
6 changes: 4 additions & 2 deletions
6
test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"name": "non-isomorphic-text", | ||
"type": "module", | ||
"exports": "./index.mjs", | ||
"exports": { | ||
"import": "./index.mjs", | ||
"require": "./index.js" | ||
}, | ||
"browser": "./browser.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters