Skip to content

Commit

Permalink
Load next config (vercel#2955)
Browse files Browse the repository at this point in the history
Load next.config.js via turbopack-node

Closes WEB-158

Co-authored-by: Justin Ridgewell <[email protected]>
Co-authored-by: Tobias Koppers <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2022
1 parent 3d69b0c commit 82446c8
Show file tree
Hide file tree
Showing 45 changed files with 1,183 additions and 366 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __generated__/

# crates
crates/next-core/js/src/compiled
crates/turbopack-node/js/src/compiled
crates/turbopack/bench.json
# This file has intentional trailing commas
crates/turbopack/tests/node-file-trace/integration/ts-package/tsconfig.json
2 changes: 1 addition & 1 deletion crates/next-core/js/src/compiled/anser/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/next-core/js/src/compiled/css.escape/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/next-core/js/src/compiled/platform/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/next-core/js/src/compiled/source-map/index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions crates/next-core/js/src/entry/app-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Ipc } from "@vercel/turbopack-next/internal/ipc";

// Provided by the rust generate code
type FileType =
| "layout"
Expand All @@ -21,6 +19,7 @@ declare global {
const IPC: Ipc<unknown, unknown>;
}

import type { Ipc } from "@vercel/turbopack-next/ipc/index";
import type { IncomingMessage, ServerResponse } from "node:http";
import type {
FlightCSSManifest,
Expand Down
9 changes: 9 additions & 0 deletions crates/next-core/js/src/entry/config/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const loadConfig = require("next/dist/server/config").default;
const { PHASE_DEVELOPMENT_SERVER } = require("next/dist/shared/lib/constants");

module.exports = (async () => {
const nextConfig = await loadConfig(PHASE_DEVELOPMENT_SERVER, process.cwd());
nextConfig.rewrites = await nextConfig.rewrites?.();
nextConfig.redirects = await nextConfig.redirects?.();
return nextConfig;
})();
5 changes: 4 additions & 1 deletion crates/next-core/js/src/entry/server-api.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import IPC, { Ipc } from "@vercel/turbopack-next/internal/ipc";
// IPC need to be the first import to allow it to catch errors happening during
// the other imports
import { IPC } from "@vercel/turbopack-next/ipc/index";

import type { Ipc } from "@vercel/turbopack-next/ipc/index";
import type { ClientRequest, IncomingMessage, Server } from "node:http";
import http, { ServerResponse } from "node:http";
import type { AddressInfo, Socket } from "node:net";
Expand Down
Loading

0 comments on commit 82446c8

Please sign in to comment.