-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eagerly bundle external ESM dependencies for pages (#42741)
One potential risk is ESM dependencies that can't be bundled will cause a build error. This also means that the `esmExternals` configuration will be affected. Closes #42249, closes #42588. Related: #1395. ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6ab52ed
commit 276533d
Showing
52 changed files
with
94 additions
and
7 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
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
'use client' | ||
import { version, useValue } from 'esm-with-react' | ||
|
||
import React from 'react' | ||
|
||
export default function Index() { | ||
const value = useValue() | ||
return ( | ||
<div> | ||
<h2>{'App React Version: ' + React.version}</h2> | ||
<h2>{'External React Version: ' + version}</h2> | ||
<h2>{'Test: ' + value}</h2> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { version } from 'esm-with-react' | ||
|
||
import React from 'react' | ||
|
||
export default function Index() { | ||
return ( | ||
<div> | ||
<h2>{'App React Version: ' + React.version}</h2> | ||
<h2>{'External React Version: ' + version}</h2> | ||
</div> | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/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 @@ | ||
import React from 'react' | ||
|
||
const Context = React.createContext ? React.createContext('hello') : null | ||
|
||
export const version = React.version | ||
export const useValue = () => React.useContext(Context) |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "esm-with-react", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"dependencies": { | ||
"react": "^18", | ||
"react-dom": "^18" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
import { version, useValue } from 'esm-with-react' | ||
|
||
import React from 'react' | ||
|
||
export default function Index() { | ||
const value = useValue() | ||
return ( | ||
<div> | ||
<h2>{'App React Version: ' + React.version}</h2> | ||
<h2>{'External React Version: ' + version}</h2> | ||
<h2>{'Test: ' + value}</h2> | ||
</div> | ||
) | ||
} |
File renamed without changes.