forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alias all client, shared, pages dist assets for esm (vercel#41034)
Alias all existing imports from `next/dist/..` to `next/dist/esm` for edge compiler. So that we don't need checking for `process.env.NEXT_RUNTIME === 'edge'` or passing down `nextRuntime` to decide wether the esm or cjs asset to require This will also fix the issue that some layouts hook are been included twice into the bundle with cjs and esm bundle in edge runtime, now only esm chunk will be bundled in server.
- Loading branch information
Showing
18 changed files
with
46 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
module.exports = | ||
process.env.NEXT_RUNTIME === 'edge' | ||
? require('./dist/esm/shared/lib/amp') | ||
: require('./dist/shared/lib/amp') | ||
module.exports = require('./dist/shared/lib/amp') |
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/pages/_app') | ||
: require('./dist/pages/_app') | ||
module.exports = require('./dist/pages/_app') |
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/index') | ||
: require('./dist/client/index') | ||
module.exports = require('./dist/client/index') |
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/shared/lib/runtime-config') | ||
: require('./dist/shared/lib/runtime-config') | ||
module.exports = require('./dist/shared/lib/runtime-config') |
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/shared/lib/constants') | ||
: require('./dist/shared/lib/constants') | ||
module.exports = require('./dist/shared/lib/constants') |
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/pages/_document') | ||
: require('./dist/pages/_document') | ||
module.exports = require('./dist/pages/_document') |
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/shared/lib/dynamic') | ||
: require('./dist/shared/lib/dynamic') | ||
module.exports = require('./dist/shared/lib/dynamic') |
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/pages/_error') | ||
: require('./dist/pages/_error') | ||
module.exports = require('./dist/pages/_error') |
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/shared/lib/head') | ||
: require('./dist/shared/lib/head') | ||
module.exports = require('./dist/shared/lib/head') |
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/image') | ||
: require('./dist/client/image') | ||
module.exports = require('./dist/client/image') |
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/link') | ||
: require('./dist/client/link') | ||
module.exports = require('./dist/client/link') |
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/router') | ||
: require('./dist/client/router') | ||
module.exports = require('./dist/client/router') |
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,13 @@ | ||
'client' | ||
|
||
import { useSelectedLayoutSegment } from 'next/dist/client/components/hooks-client' | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
// useSelectedLayoutSegment should not be thrown | ||
useSelectedLayoutSegment() | ||
return children | ||
} | ||
|
||
export const config = { | ||
runtime: 'experimental-edge', | ||
} |
This file was deleted.
Oops, something went wrong.