-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Turbopack: fix passing project options from napi #86256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ import type { | |
| RefCell, | ||
| NapiTurboEngineOptions, | ||
| NapiSourceDiagnostic, | ||
| NapiProjectOptions, | ||
| NapiPartialProjectOptions, | ||
| } from './generated-native' | ||
|
|
||
| export type { NapiTurboEngineOptions as TurboEngineOptions } | ||
|
|
@@ -367,27 +369,8 @@ export type WrittenEndpoint = | |
| config: EndpointConfig | ||
| } | ||
|
|
||
| export interface ProjectOptions { | ||
| /** | ||
| * An absolute root path (Unix or Windows path) from which all files must be nested under. Trying | ||
| * to access a file outside this root will fail, so think of this as a chroot. | ||
| * E.g. `/home/user/projects/my-repo`. | ||
| */ | ||
| rootPath: string | ||
|
|
||
| /** | ||
| * A path which contains the app/pages directories, relative to `root_path`, always a Unix path. | ||
| * E.g. `apps/my-app` | ||
| */ | ||
| projectPath: string | ||
|
|
||
| /** | ||
| * A path where to emit the build outputs, relative to [`Project::project_path`], always a Unix | ||
| * path. Corresponds to next.config.js's `distDir`. | ||
| * E.g. `.next` | ||
| */ | ||
| distDir: string | ||
|
|
||
| export interface ProjectOptions | ||
| extends Omit<NapiProjectOptions, 'nextConfig' | 'env'> { | ||
| /** | ||
| * The next.config.js contents. | ||
| */ | ||
|
|
@@ -397,53 +380,21 @@ export interface ProjectOptions { | |
| * A map of environment variables to use when compiling code. | ||
| */ | ||
| env: Record<string, string> | ||
| } | ||
|
|
||
| defineEnv: DefineEnv | ||
|
|
||
| /** | ||
| * Whether to watch the filesystem for file changes. | ||
| */ | ||
| watch: { | ||
| enable: boolean | ||
| pollIntervalMs?: number | ||
| } | ||
|
|
||
| /** | ||
| * The mode in which Next.js is running. | ||
| */ | ||
| dev: boolean | ||
|
|
||
| /** | ||
| * The server actions encryption key. | ||
| */ | ||
| encryptionKey: string | ||
|
|
||
| /** | ||
| * The build id. | ||
| */ | ||
| buildId: string | ||
|
|
||
| /** | ||
| * Options for draft mode. | ||
| */ | ||
| previewProps: __ApiPreviewProps | ||
|
|
||
| /** | ||
| * The browserslist query to use for targeting browsers. | ||
| */ | ||
| browserslistQuery: string | ||
|
|
||
| export interface PartialProjectOptions | ||
| extends Omit<NapiPartialProjectOptions, 'nextConfig' | 'env'> { | ||
| rootPath: NapiProjectOptions['rootPath'] | ||
| projectPath: NapiProjectOptions['projectPath'] | ||
|
Comment on lines
+387
to
+388
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The View Details📝 Patch Detailsdiff --git a/packages/next/src/build/swc/index.ts b/packages/next/src/build/swc/index.ts
index c0ff835a8f..73340b1d0c 100644
--- a/packages/next/src/build/swc/index.ts
+++ b/packages/next/src/build/swc/index.ts
@@ -658,6 +658,8 @@ function bindingToApi(
...options,
nextConfig:
options.nextConfig &&
+ options.rootPath &&
+ options.projectPath &&
(await serializeNextConfig(
options.nextConfig,
path.join(options.rootPath, options.projectPath)
diff --git a/packages/next/src/build/swc/types.ts b/packages/next/src/build/swc/types.ts
index b9e0fee184..adb84156fa 100644
--- a/packages/next/src/build/swc/types.ts
+++ b/packages/next/src/build/swc/types.ts
@@ -384,8 +384,6 @@ export interface ProjectOptions
export interface PartialProjectOptions
extends Omit<NapiPartialProjectOptions, 'nextConfig' | 'env'> {
- rootPath: NapiProjectOptions['rootPath']
- projectPath: NapiProjectOptions['projectPath']
/**
* The next.config.js contents.
*/
AnalysisPartialProjectOptions incorrectly marks rootPath and projectPath as requiredWhat fails: The How to reproduce: // This should work but currently fails TypeScript type checking
const options: PartialProjectOptions = {
nextConfig: nextConfig,
};
// Error: Type '{ nextConfig: NextConfigComplete; }' is missing the following properties from type 'PartialProjectOptions': rootPath, projectPathRoot cause: The The underlying Rust types confirm this design: Fix applied:
This allows proper partial updates where callers can update individual fields like |
||
| /** | ||
| * When the code is minified, this opts out of the default mangling of local | ||
| * names for variables, functions etc., which can be useful for | ||
| * debugging/profiling purposes. | ||
| * The next.config.js contents. | ||
| */ | ||
| noMangling: boolean | ||
| nextConfig?: NextConfigComplete | ||
|
|
||
| /** | ||
| * The version of Node.js that is available/currently running. | ||
| * A map of environment variables to use when compiling code. | ||
| */ | ||
| currentNodeJsVersion: string | ||
| env?: Record<string, string> | ||
| } | ||
|
|
||
| export interface DefineEnv { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but where does the config specify the output directory to write the chunks to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's read from nextConfig