File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
packages/plugin-rsc/src/transforms Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff 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} )
Original file line number Diff line number Diff 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'
You can’t perform that action at this time.
0 commit comments