You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library at the moment is using commonJS modules with require to imports other modules. You should migrate to modern ESModules to be compliant with modern bundling systems that applies three shaking techniques.
Reacted by rtritto, Tim Mensch, quirin-buechner-mdctec, Shinebayar G, Etienne Maheu, Alexander, Kisaragi, Kevin Deng and Eric
In the same vein, it would be good to separate the parse and stringify functions, so if you're only using one of them, you can tree-shake the other out of our builds.
(I recently removed stringify and am only using parse in my project -- I'd hoped that would reduce the bundle size somewhat, but it doesn't)
Thanks for the suggestion. JSON5 v3 is being written in TypeScript, and it will be ESM first (with a CommonJS bundle for backward compatibility). parse and stringify are already in different files right now, and that will be the same in v3.
Reacted by Carl Smith, Derek Vadneau, rtritto, Benny Neugebauer, Shinebayar G, Etienne Maheu and Kisaragi
I see source for a V3, but it seems to be from 3 years ago?
And is not in typescript?
Can you say more about how we can install a typescript or ESM version of JSON5?
(or even convince typescript/vscode to use the parse.d.ts that comes with the package?)
the cjs version is 'working', but webpack/angular keeps barking:
"CommonJS or AMD dependencies can cause optimization bailouts."
Done in the maintained fork @bybrave/json5: the sources are now ES modules with an exports map (the CJS entry is generated from them for the require condition). This also fixes #240 — import { parse, stringify } works and the import/require shapes match. Build moved from rollup+buble to a single esbuild step; zero runtime deps. npm i @bybrave/json5.
@bybraveHQ: I'm just seeing your fork for the first time. Love to see it! Would you be interested in becoming a maintainer here and bringing your changes back here? Or are you happy and would prefer to keep to your own fork instead? No pressure either way, and thank you for your work.
Hello @aseemk, I'm on the Prettier core team. As you can see from the links above, we already switched to bybraveHQ's fork. I'm willing to help with the migration if bybraveHQ is busy.
@aseemk Sorry for the slow reply, and thank you — yes, I'd be glad to become a maintainer and bring the changes back here.
I've opened #370 with the packaging part (fixes #240 and this issue): ES module sources, an exports map so import {parse, stringify} and require resolve to the same shape, a single esbuild build step, bundled types, node:test instead of tap, and GitHub Actions CI. The behavior changes from the fork (opt-in BigInt parsing from #292 and lone-surrogate escaping from #192) are deliberately not included; I'll send them as separate PRs once this lands.
@fisker Thanks for the offer — a review from the Prettier side would be very welcome, since you're already running this in production. Once it ships as json5 v3 I'll deprecate @bybrave/json5 in favor of it.
@fisker Quick status check on #370: all review threads are addressed, the PR is mergeable, but CI still hasn't run because the workflow needs a maintainer's approval, and there's been no response from @aseemk since my ping on Sept 23. Looking at the repo, #371 is also waiting on him.
Since you offered to help with the migration — do you have a way to reach Aseem directly, or any suggestion on how to move this forward? I'm happy to keep the PR up to date and split out the follow-ups (BigInt, lone surrogates) as separate PRs once this one lands.
Hey, all. Sorry for the lack of response on this repo. I'll be connecting with @aseemk to discuss future maintainers for JSON5. I don't want JSON5 to continue to languish under my care because I haven't had the time to focus on it.
In the meantime, I'm going to go through the existing issues (starting with this one) and prioritize what can be updated for v2 and work on a plan for v3.
Activity
CarlosNZ commentedon Jun 23, 2024
In the same vein, it would be good to separate the
parseandstringifyfunctions, so if you're only using one of them, you can tree-shake the other out of our builds.(I recently removed
stringifyand am only usingparsein my project -- I'd hoped that would reduce the bundle size somewhat, but it doesn't)jordanbtucker commentedon Jun 23, 2024
Thanks for the suggestion. JSON5 v3 is being written in TypeScript, and it will be ESM first (with a CommonJS bundle for backward compatibility).
parseandstringifyare already in different files right now, and that will be the same in v3.DraTeots commentedon Jul 26, 2024
Hello! Couldn't find the JSON5 v3 in typescript. Could you point out if one can use it?
jackpunt commentedon Feb 24, 2025
I see source for a V3, but it seems to be from 3 years ago?
And is not in typescript?
Can you say more about how we can install a typescript or ESM version of JSON5?
(or even convince typescript/vscode to use the parse.d.ts that comes with the package?)
the cjs version is 'working', but webpack/angular keeps barking:
"CommonJS or AMD dependencies can cause optimization bailouts."
bybraveHQ commentedon Jul 5, 2026
Done in the maintained fork
@bybrave/json5: the sources are now ES modules with anexportsmap (the CJS entry is generated from them for therequirecondition). This also fixes #240 —import { parse, stringify }works and theimport/requireshapes match. Build moved from rollup+buble to a single esbuild step; zero runtime deps.npm i @bybrave/json5.aseemk commentedon Jul 21, 2026
@bybraveHQ: I'm just seeing your fork for the first time. Love to see it! Would you be interested in becoming a maintainer here and bringing your changes back here? Or are you happy and would prefer to keep to your own fork instead? No pressure either way, and thank you for your work.
fisker commentedon Sep 17, 2026
Hello @aseemk, I'm on the Prettier core team. As you can see from the links above, we already switched to bybraveHQ's fork. I'm willing to help with the migration if bybraveHQ is busy.
bybraveHQ commentedon Sep 17, 2026
@aseemk Sorry for the slow reply, and thank you — yes, I'd be glad to become a maintainer and bring the changes back here.
I've opened #370 with the packaging part (fixes #240 and this issue): ES module sources, an
exportsmap soimport {parse, stringify}andrequireresolve to the same shape, a single esbuild build step, bundled types,node:testinstead of tap, and GitHub Actions CI. The behavior changes from the fork (opt-in BigInt parsing from #292 and lone-surrogate escaping from #192) are deliberately not included; I'll send them as separate PRs once this lands.@fisker Thanks for the offer — a review from the Prettier side would be very welcome, since you're already running this in production. Once it ships as json5 v3 I'll deprecate
@bybrave/json5in favor of it.fisker commentedon Sep 17, 2026
Great!
feat: esm sources with exports map, esbuild build and bundled types
feat: esm sources with exports map, esbuild build and bundled types
bybraveHQ commentedon Oct 13, 2026
@fisker Quick status check on #370: all review threads are addressed, the PR is mergeable, but CI still hasn't run because the workflow needs a maintainer's approval, and there's been no response from @aseemk since my ping on Sept 23. Looking at the repo, #371 is also waiting on him.
Since you offered to help with the migration — do you have a way to reach Aseem directly, or any suggestion on how to move this forward? I'm happy to keep the PR up to date and split out the follow-ups (BigInt, lone surrogates) as separate PRs once this one lands.
Thanks again for the reviews.
fisker commentedon Oct 13, 2026
Sorry, I don't.
Guess we'll have to wait. Hope we can get the repo and NPM access once @aseemk come back, so we don't have to wait for him again.
jordanbtucker commentedon Oct 14, 2026
Hey, all. Sorry for the lack of response on this repo. I'll be connecting with @aseemk to discuss future maintainers for JSON5. I don't want JSON5 to continue to languish under my care because I haven't had the time to focus on it.
In the meantime, I'm going to go through the existing issues (starting with this one) and prioritize what can be updated for v2 and work on a plan for v3.
feat: esm sources with exports map, esbuild build and bundled types
ESM-first sources with an exports map, esbuild build, bundled types (…