-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flow, pages-manifest.json, defaultPathMap for export (minor) (#4066)
* Initial implementation of next export without exportPathMap * Shorter message * Set up flow * Create pages manifest * Use pagesManifest for next export * Fix tests * Document defaultPathMap * Replacing the path is no longer needed * Use posix normalize for consistent behaviour * Remove second instance of examples * Add comment about what pages-manifest does * Make windows path a route
- Loading branch information
1 parent
136dabc
commit e90f896
Showing
15 changed files
with
104 additions
and
62 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,7 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
"react" | ||
"react", | ||
"flow" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
|
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,2 @@ | ||
[ignore] | ||
<PROJECT_ROOT>/examples/.* |
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,30 @@ | ||
// @flow | ||
import { RawSource } from 'webpack-sources' | ||
import { MATCH_ROUTE_NAME } from '../../utils' | ||
import {PAGES_MANIFEST} from '../../../lib/constants' | ||
|
||
// This plugin creates a pages-manifest.json from page entrypoints. | ||
// This is used for mapping paths like `/` to `.next/dist/bundles/pages/index.js` when doing SSR | ||
// It's also used by next export to provide defaultPathMap | ||
export default class PagesManifestPlugin { | ||
apply (compiler: any) { | ||
compiler.plugin('emit', (compilation, callback) => { | ||
const {entries} = compilation | ||
const pages = {} | ||
|
||
for (const entry of entries) { | ||
const pagePath = MATCH_ROUTE_NAME.exec(entry.name)[1] | ||
|
||
if (!pagePath) { | ||
continue | ||
} | ||
|
||
const {name} = entry | ||
pages[`/${pagePath.replace(/\\/g, '/')}`] = name | ||
} | ||
|
||
compilation.assets[PAGES_MANIFEST] = new RawSource(JSON.stringify(pages)) | ||
callback() | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
test: '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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"/index": "bundles/pages/index.js", | ||
"/world": "bundles/pages/world.js", | ||
"/_error": "bundles/pages/_error.js", | ||
"/non-existent-child": "bundles/pages/non-existent-child.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
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