diff --git a/crates/next-custom-transforms/tests/fixture.rs b/crates/next-custom-transforms/tests/fixture.rs index f3cdba596998e..c4c05b78258c3 100644 --- a/crates/next-custom-transforms/tests/fixture.rs +++ b/crates/next-custom-transforms/tests/fixture.rs @@ -916,6 +916,36 @@ fn test_edge_assert(input: PathBuf) { ); } +#[fixture("tests/fixture/source-maps/**/input.js")] +fn test_source_maps(input: PathBuf) { + let output = input.parent().unwrap().join("output.js"); + test_fixture( + syntax(), + &|_tr| { + ( + resolver(Mark::new(), Mark::new(), false), + server_actions( + &FileName::Real("/app/item.js".into()), + server_actions::Config { + is_react_server_layer: true, + dynamic_io_enabled: true, + hash_salt: "".into(), + cache_kinds: FxHashSet::from_iter([]), + }, + _tr.comments.as_ref().clone(), + ), + ) + }, + &input, + &output, + FixtureTestConfig { + module: Some(true), + sourcemap: true, + ..Default::default() + }, + ); +} + fn lint_to_fold(r: R) -> impl Pass where R: Visit, diff --git a/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/input.js b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/input.js new file mode 100644 index 0000000000000..447c7775ed121 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/input.js @@ -0,0 +1,9 @@ +'use cache' + +const foo = async () => { + 'use cache' +} + +export async function bar() { + return foo() +} diff --git a/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.js b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.js new file mode 100644 index 0000000000000..87cc49a329dc4 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.js @@ -0,0 +1,17 @@ +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","80951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ 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, async function() {}); +Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { + "value": "foo", + "writable": false +}); +const foo = /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); +export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "80951c375b4a6a6e89d67b743ec5808127cfde405d", 0, /*#__TURBOPACK_DISABLE_EXPORT_MERGING__*/ async function bar() { + return foo(); +}); +Object.defineProperty($$RSC_SERVER_CACHE_1, "name", { + "value": "bar", + "writable": false +}); +export var bar = registerServerReference($$RSC_SERVER_CACHE_1, "80951c375b4a6a6e89d67b743ec5808127cfde405d", null); diff --git a/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.map b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.map new file mode 100644 index 0000000000000..01088c723f8d9 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/source-maps/use-cache/1/output.map @@ -0,0 +1 @@ +{"version":3,"sources":["input.js"],"sourcesContent":["'use cache'\n\nconst foo = async () => {\n 'use cache'\n}\n\nexport async function bar() {\n return foo()\n}\n"],"names":[],"mappings":";;;0HAIA;;;;;AAFA,MAAM,MAAM,uCACC,GADD;wGAIL,uCACO,GADP,eAAe;IACpB,OAAO;AACT;;;;;AAFA,WAAsB,MAAf"}