Skip to content

Commit 42fc0bc

Browse files
Merge remote-tracking branch 'upstream/main' into chore-rsc-nightly
2 parents 6386c95 + 4b2768f commit 42fc0bc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/plugin-rsc/src/transforms/hoist.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,20 @@ export async function kv() {
447447
"
448448
`)
449449
})
450+
451+
it('no ending new line', async () => {
452+
const input = `\
453+
export async function test() {
454+
"use server";
455+
}`
456+
expect(await testTransform(input)).toMatchInlineSnapshot(`
457+
"export const test = /* #__PURE__ */ $$register($$hoist_0_test, "<id>", "$$hoist_0_test");
458+
459+
;export async function $$hoist_0_test() {
460+
"use server";
461+
};
462+
/* #__PURE__ */ Object.defineProperty($$hoist_0_test, "name", { value: "test" });
463+
"
464+
`)
465+
})
450466
})

packages/plugin-rsc/src/transforms/hoist.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export function transformHoistInlineDirective(
2727
output: MagicString
2828
names: string[]
2929
} {
30+
// ensure ending space so we can move node at the end without breaking magic-string
31+
if (!input.endsWith('\n')) {
32+
input += '\n'
33+
}
3034
const output = new MagicString(input)
3135
const directive =
3236
typeof options.directive === 'string'

0 commit comments

Comments
 (0)