Skip to content

Commit

Permalink
feat: Upgrade Next.js to Webpack 5
Browse files Browse the repository at this point in the history
Enabling module federation & suspense SSR
  • Loading branch information
ScriptedAlchemy committed Mar 28, 2020
1 parent be2c65b commit 6ec9246
Show file tree
Hide file tree
Showing 70 changed files with 9 additions and 1,581 deletions.
5 changes: 4 additions & 1 deletion packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ export default async function build(dir: string, conf = null): Promise<void> {
pagesManifest[page] = bundleRelative.replace(/\\/g, '/')

const nonReservedPage = !page.match(/^\/(_app|_error|_document|api)/)

if (nonReservedPage && customAppGetInitialProps === undefined) {
customAppGetInitialProps = hasCustomGetInitialProps(
isLikeServerless
Expand Down Expand Up @@ -633,6 +632,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
'utf8'
)
}

// Since custom _app.js can wrap the 404 page we have to opt-out of static optimization if it has getInitialProps
// Only export the static 404 when there is no /_error present
const useStatic404 =
Expand Down Expand Up @@ -669,8 +669,11 @@ export default async function build(dir: string, conf = null): Promise<void> {
const tbdPrerenderRoutes: string[] = []

if (staticPages.size > 0 || ssgPages.size > 0 || useStatic404) {
console.log({ staticPages, ssgPages })
// const combinedPages = [...staticPages, ...ssgPages]
const combinedPages = [...staticPages, ...ssgPages]
const exportApp = require('../export').default

const exportOptions = {
silent: true,
buildExport: true,
Expand Down
1 change: 0 additions & 1 deletion packages/next/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export default async function(
}),
'utf8'
)

// Copy static directory
if (!options.buildExport && existsSync(join(dir, 'static'))) {
log(' copying "static" directory')
Expand Down
3 changes: 1 addition & 2 deletions packages/next/export/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default async function({
)
}
}

// Check if the page is a specified dynamic route
if (isDynamicRoute(page) && page !== path) {
params = getRouteMatcher(getRouteRegex(page))(path)
Expand Down Expand Up @@ -117,7 +116,7 @@ export default async function({
let html
let curRenderOpts = {}
let renderMethod = renderToHTML

console.log(path)
const renderedDuringBuild = getStaticProps => {
return !buildExport && getStaticProps && !isDynamicRoute(path)
}
Expand Down
5 changes: 4 additions & 1 deletion packages/next/next-server/server/require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export function pageNotFoundError(page: string): Error {
err.code = 'ENOENT'
return err
}

function requireUncached(module) {
delete require.cache[require.resolve(module)]
return require(module)
}
export function getPagePath(
page: string,
distDir: string,
Expand Down
2 changes: 0 additions & 2 deletions test/integration/404-page/pages/404.js.bak

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/api-support/next.config.js

This file was deleted.

8 changes: 0 additions & 8 deletions test/integration/api-support/pages/api/child-process.js

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/bigint/next.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/integration/conformance/components/one.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/integration/conformance/next.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/integration/conformance/pages/index.js

This file was deleted.

14 changes: 0 additions & 14 deletions test/integration/conformance/pages/page1.js

This file was deleted.

24 changes: 0 additions & 24 deletions test/integration/conformance/pages/page2.js

This file was deleted.

15 changes: 0 additions & 15 deletions test/integration/conformance/pages/page3.js

This file was deleted.

33 changes: 0 additions & 33 deletions test/integration/conformance/test/index.test.js

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/custom-error/next.config.js

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/custom-routes/pages/api/dynamic/[slug].js

This file was deleted.

36 changes: 0 additions & 36 deletions test/integration/custom-routes/server.js

This file was deleted.

7 changes: 0 additions & 7 deletions test/integration/dist-dir/next.config.js

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/dist-dir/pages/index.js

This file was deleted.

65 changes: 0 additions & 65 deletions test/integration/dist-dir/test/index.test.js

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/dynamic-route-rename/pages/[pid].js

This file was deleted.

53 changes: 0 additions & 53 deletions test/integration/dynamic-route-rename/test/index.test.js

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions test/integration/error-load-fail/pages/broken.js

This file was deleted.

Loading

0 comments on commit 6ec9246

Please sign in to comment.