Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// The hoist transform must preserve `function*` / `async function*` syntax.
// Previously the `*` was dropped, making `yield` a SyntaxError.
function outer() {
const items = [1, 2, 3]

async function* stream() {
'use server'
for (const item of items) {
yield item
}
}

return stream
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// The hoist transform must preserve `function*` / `async function*` syntax.
// Previously the `*` was dropped, making `yield` a SyntaxError.
function outer() {
const items = [1, 2, 3]

const stream = /* #__PURE__ */ $$register($$hoist_0_stream, "<id>", "$$hoist_0_stream").bind(null, __enc([items]));

return stream
}

;export async function* $$hoist_0_stream($$hoist_encoded) {
const [items] = __dec($$hoist_encoded);
'use server'
for (const item of items) {
yield item
}
};
/* #__PURE__ */ Object.defineProperty($$hoist_0_stream, "name", { value: "stream" });
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// The hoist transform must preserve `function*` / `async function*` syntax.
// Previously the `*` was dropped, making `yield` a SyntaxError.
function outer() {
const items = [1, 2, 3]

const stream = /* #__PURE__ */ $$register($$hoist_0_stream, "<id>", "$$hoist_0_stream").bind(null, items);

return stream
}

;export async function* $$hoist_0_stream(items) {
'use server'
for (const item of items) {
yield item
}
};
/* #__PURE__ */ Object.defineProperty($$hoist_0_stream, "name", { value: "stream" });
2 changes: 1 addition & 1 deletion packages/plugin-rsc/src/transforms/hoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function transformHoistInlineDirective(
node.body.start,
`\n;${options.noExport ? '' : 'export '}${
node.async ? 'async ' : ''
}function ${newName}(${newParams}) `,
}function${node.generator ? '*' : ''} ${newName}(${newParams}) `,
)
output.appendLeft(
node.end,
Expand Down
Loading