Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e09e0f5e
Unverified
Commit
e09e0f5e
authored
Oct 04, 2023
by
Leah
Committed by
GitHub
Oct 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: extract edge-app-route loader template (#56424)
Closes WEB-1705
parent
00aea747
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
entries.ts
packages/next/src/build/entries.ts
+1
-0
load-entrypoint.ts
packages/next/src/build/load-entrypoint.ts
+8
-2
edge-app-route.ts
packages/next/src/build/templates/edge-app-route.ts
+9
-0
index.ts
...build/webpack/loaders/next-edge-app-route-loader/index.ts
+5
-8
No files found.
packages/next/src/build/entries.ts
View file @
e09e0f5e
...
@@ -356,6 +356,7 @@ export function getEdgeServerEntry(opts: {
...
@@ -356,6 +356,7 @@ export function getEdgeServerEntry(opts: {
layer
:
WEBPACK_LAYERS
.
reactServerComponents
,
layer
:
WEBPACK_LAYERS
.
reactServerComponents
,
}
}
}
}
if
(
isMiddlewareFile
(
opts
.
page
))
{
if
(
isMiddlewareFile
(
opts
.
page
))
{
const
loaderParams
:
MiddlewareLoaderOptions
=
{
const
loaderParams
:
MiddlewareLoaderOptions
=
{
absolutePagePath
:
opts
.
absolutePagePath
,
absolutePagePath
:
opts
.
absolutePagePath
,
...
...
packages/next/src/build/load-entrypoint.ts
View file @
e09e0f5e
...
@@ -19,12 +19,18 @@ const TEMPLATES_ESM_FOLDER = path.normalize(
...
@@ -19,12 +19,18 @@ const TEMPLATES_ESM_FOLDER = path.normalize(
* handle replacement values that are related to imports.
* handle replacement values that are related to imports.
*
*
* @param entrypoint the entrypoint to load
* @param entrypoint the entrypoint to load
* @param replacements the replacements to perform
* @param replacements string replacements to perform
* @param injections code injections to perform
* @returns the loaded file with the replacements
* @returns the loaded file with the replacements
*/
*/
export
async
function
loadEntrypoint
(
export
async
function
loadEntrypoint
(
entrypoint
:
'pages'
|
'pages-api'
|
'app-page'
|
'app-route'
,
entrypoint
:
|
'pages'
|
'pages-api'
|
'app-page'
|
'app-route'
|
'edge-app-route'
,
replacements
:
Record
<
`VAR_
${
string
}
`
,
string
>
,
replacements
:
Record
<
`VAR_
${
string
}
`
,
string
>
,
injections
?:
Record
<
string
,
string
>
injections
?:
Record
<
string
,
string
>
):
Promise
<
string
>
{
):
Promise
<
string
>
{
...
...
packages/next/src/build/templates/edge-app-route.ts
0 → 100644
View file @
e09e0f5e
import
{
EdgeRouteModuleWrapper
}
from
'../../server/web/edge-route-module-wrapper'
// Import the userland code.
// @ts-expect-error - replaced by webpack/turbopack loader
import
*
as
module
from
'VAR_USERLAND'
export
const
ComponentMod
=
module
export
default
EdgeRouteModuleWrapper
.
wrap
(
module
.
routeModule
)
packages/next/src/build/webpack/loaders/next-edge-app-route-loader/index.ts
View file @
e09e0f5e
...
@@ -4,6 +4,7 @@ import { NextConfig } from '../../../../server/config-shared'
...
@@ -4,6 +4,7 @@ import { NextConfig } from '../../../../server/config-shared'
import
{
webpack
}
from
'next/dist/compiled/webpack/webpack'
import
{
webpack
}
from
'next/dist/compiled/webpack/webpack'
import
{
WEBPACK_RESOURCE_QUERIES
}
from
'../../../../lib/constants'
import
{
WEBPACK_RESOURCE_QUERIES
}
from
'../../../../lib/constants'
import
{
MiddlewareConfig
}
from
'../../../analysis/get-page-static-info'
import
{
MiddlewareConfig
}
from
'../../../analysis/get-page-static-info'
import
{
loadEntrypoint
}
from
'../../../load-entrypoint'
export
type
EdgeAppRouteLoaderQuery
=
{
export
type
EdgeAppRouteLoaderQuery
=
{
absolutePagePath
:
string
absolutePagePath
:
string
...
@@ -15,7 +16,7 @@ export type EdgeAppRouteLoaderQuery = {
...
@@ -15,7 +16,7 @@ export type EdgeAppRouteLoaderQuery = {
}
}
const
EdgeAppRouteLoader
:
webpack
.
LoaderDefinitionFunction
<
EdgeAppRouteLoaderQuery
>
=
const
EdgeAppRouteLoader
:
webpack
.
LoaderDefinitionFunction
<
EdgeAppRouteLoaderQuery
>
=
function
(
this
)
{
async
function
(
this
)
{
const
{
const
{
page
,
page
,
absolutePagePath
,
absolutePagePath
,
...
@@ -52,13 +53,9 @@ const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQue
...
@@ -52,13 +53,9 @@ const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQue
stringifiedPagePath
.
length
-
1
stringifiedPagePath
.
length
-
1
)}
?
${
WEBPACK_RESOURCE_QUERIES
.
edgeSSREntry
}
`
)}
?
${
WEBPACK_RESOURCE_QUERIES
.
edgeSSREntry
}
`
return
`
return
await
loadEntrypoint
(
'edge-app-route'
,
{
import { EdgeRouteModuleWrapper } from 'next/dist/esm/server/web/edge-route-module-wrapper'
VAR_USERLAND
:
modulePath
,
import * as module from
${
JSON
.
stringify
(
modulePath
)}
})
export const ComponentMod = module
export default EdgeRouteModuleWrapper.wrap(module.routeModule)`
}
}
export
default
EdgeAppRouteLoader
export
default
EdgeAppRouteLoader
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment