Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alias next public api to esm on edge runtime (#42709)
Cases like `next/link` and `next/router` imports are not alias since they're not matching the existing alias pattern setting for edge runtime, which causes router-context being bundled twice (both with cjs and esm) into edge worker bundle. so we resolve their paths and alias them to esm bundle for webpack bundling. Other minor changes: * update `require` calls to `import` expressions in edge ssr loaders * remove client layer for apps without `appDir` enabled * export `type` for ts typings in next/image to avoid alias to break resolving ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md`
- Loading branch information
Showing
9 changed files
with
56 additions
and
22 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
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,4 +1 @@ | ||
module.exports = | ||
process.env.NEXT_RUNTIME === 'edge' | ||
? require('./dist/esm/client/script') | ||
: require('./dist/client/script') | ||
module.exports = require('./dist/client/script') |
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,11 @@ | ||
import { useRouter } from 'next/router' | ||
import Link from 'next/link' | ||
|
||
export default () => { | ||
useRouter() | ||
return <Link href="/">link</Link> | ||
} | ||
|
||
export const config = { | ||
runtime: 'experimental-edge', | ||
} |