Skip to content

Commit

Permalink
chore: serialize bigint AST, albeit incorrectly (#14504)
Browse files Browse the repository at this point in the history
playgrounds/sandbox/run.js doesn't work for components containing bigints, because they can't be serialized to JSON. There isn't really a great fix for this issue but this at least allows the sandbox to run
  • Loading branch information
Rich-Harris authored Dec 2, 2024
1 parent abb90d8 commit aaea254
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion playgrounds/sandbox/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ for (const generate of /** @type {const} */ (['client', 'server'])) {
modern: true
});

fs.writeFileSync(`${cwd}/output/${file}.json`, JSON.stringify(ast, null, '\t'));
fs.writeFileSync(
`${cwd}/output/${file}.json`,
JSON.stringify(
ast,
(key, value) => (typeof value === 'bigint' ? ['BigInt', value.toString()] : value),
'\t'
)
);

try {
const migrated = migrate(source);
Expand Down

0 comments on commit aaea254

Please sign in to comment.