-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't hoist a server function if a compile error was emitted (#73189)
This allows us to skip unnecessary work, and also avoids generating invalid code, e.g. not allowed `super` calls in hoisted methods.
- Loading branch information
1 parent
1763f32
commit 0ab07f4
Showing
11 changed files
with
75 additions
and
156 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
12 changes: 2 additions & 10 deletions
12
crates/next-custom-transforms/tests/errors/server-actions/server-graph/16/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("x", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function foo() { | ||
export async function foo() { | ||
return 'data'; | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "foo", | ||
"writable": false | ||
}); | ||
export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
} |
12 changes: 2 additions & 10 deletions
12
crates/next-custom-transforms/tests/errors/server-actions/server-graph/17/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("x", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function foo() { | ||
export async function foo() { | ||
return 'data'; | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "foo", | ||
"writable": false | ||
}); | ||
export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
} |
12 changes: 2 additions & 10 deletions
12
crates/next-custom-transforms/tests/errors/server-actions/server-graph/20/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function fn() { | ||
export async function fn() { | ||
'use server'; | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "fn", | ||
"writable": false | ||
}); | ||
export var fn = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
} |
10 changes: 1 addition & 9 deletions
10
crates/next-custom-transforms/tests/errors/server-actions/server-graph/21/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
'use server'; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function fn() {}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "fn", | ||
"writable": false | ||
}); | ||
export var fn = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
export async function fn() {} |
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
15 changes: 6 additions & 9 deletions
15
crates/next-custom-transforms/tests/errors/server-actions/server-graph/23/output.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
20 changes: 6 additions & 14 deletions
20
crates/next-custom-transforms/tests/errors/server-actions/server-graph/26/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function bar() { | ||
// arguments is not allowed here | ||
console.log(arguments); | ||
// this is not allowed here | ||
return this.foo(); | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "bar", | ||
"writable": false | ||
}); | ||
export class MyClass { | ||
static async foo() { | ||
return fetch('https://example.com').then((res)=>res.json()); | ||
} | ||
static bar = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
static async bar() { | ||
// arguments is not allowed here | ||
console.log(arguments); | ||
// this is not allowed here | ||
return this.foo(); | ||
} | ||
} |
12 changes: 2 additions & 10 deletions
12
crates/next-custom-transforms/tests/errors/use-cache-not-allowed/1/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function Page() { | ||
export default async function Page() { | ||
return <p>hello world</p>; | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "Page", | ||
"writable": false | ||
}); | ||
export default registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
} |
12 changes: 2 additions & 10 deletions
12
crates/next-custom-transforms/tests/errors/use-cache-not-allowed/2/output.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; | ||
export var $$RSC_SERVER_CACHE_0 = $$cache__("x", "803128060c414d59f8552e4788b846c0d2b7f74743", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function Page() { | ||
export default async function Page() { | ||
return <p>hello world</p>; | ||
}); | ||
Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { | ||
"value": "Page", | ||
"writable": false | ||
}); | ||
export default registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); | ||
} |