Repository navigation
Upgrade bundled sort-package-json to latest #104
Description
Activity
Hi, the main issue is the ESM.
Electron back then doesn't support ESM.
Later-on it starts supporting it, but not sure if VSCode accepts ESM import yet.
Reacted by Karl HorkyOh interesting, didn't know there was an issue with ESM support in VS Code 👀 looks like it's coming in the April 2025 iteration?
Reacted by Homa WongThat's great news. Yes. This extension couldn't update to `sort-package-json' 2.0.0 because of that.
Hopefully microsoft/vscode#245214 works well.
Reacted by Karl HorkyVS Code April 2025 (1.100) is out, with "ESM support for extensions"! 🚀
Reacted by Homa Wong- changed the title
[-]Upgrade bundled sort-package-json to latest (3.2.0)[/-][+]Upgrade bundled sort-package-json to latest[/+]on Jul 10, 2025 @unional would it make sense to check the checkbox in the Renovate Dependency Dashboard issue to open the PR for
fix(deps): update dependency sort-package-json to v3?Thanks. It seems like no other extensions have issue with ESM. Will took into it hopefully this weekend.
Reacted by Karl HorkyIt doesn't work. Getting error:
Dynamic require of "path" is not supported..It needs more work to convert it to async and then try using dynamic import.
Need a lot of changes to make that happen.Still has some other issues.
Thanks for the update! I've subscribed to that microsoft/vscode#130367 issue, so I'll keep an eye on any new developments there.
@unional I saw your comment in the issue:
I'm getting
Dynamic require of "path" is not supported.when trying to convert unional/vscode-sort-package-json to ESM.Need to find out what's causing that.
microsoft/vscode#130367 (comment)
Do you think that you could push a branch / PR with your changes and a CI step showing the error (and update your comment with the link to the branch / PR)? I'm thinking maybe it would help others to assist with the problem.
Sorry I'm not likely able to look at it in the next few weeks.
I might be able to push the branch I was working on sometimes in the next 2 weeks.
I recall the problem is that there is some code in vscode loading
pathdynamically.Reacted by Karl HorkyReacted by Karl HorkyOk sounds good, looking forward to hearing more :)
@unional anything that has changed since Sep 2025?
I did see this issue related to
require(esm)is now resolved (although maybe unrelated to the problem you described above):
Actually, maybe the extension doesn't need to be converted to ESM yet? Looking again at
sort-package-json,sort-package-json@2.11.0added dual CJS/ESM release support - still exposed insort-package-json@3.6.1. The existingrequire(modulePath)invscode-sort-package-jsonshould be able to load it as CJS:https://github.com/keithamus/sort-package-json/blob/v3.6.1/package.json#L20-L32
But even sticking with CommonJS, there is one change that should be made:
sort-package-json@3.6.1requires Node.js>=20, whilevscode-sort-package-jsonstill supports VS Code>=1.77. So bumpingengines.vscodeto>= 1.90.0(first VS Code version with extension host on Node.js>= 20) seems like it would be good:https://github.com/keithamus/sort-package-json/blob/v3.6.1/package.json#L105-L107
@karlhorky Thanks. It seems like it is working now when I try it locally. Releasing a new version. Please share to see if it works or not.
Reacted by Karl HorkyReacted by Karl HorkyClosing
Hi @unional, hope you're well!
I recently contributed a fix to
sort-package-jsonto use the npm algorithm for sorting dependencies (to avoid endless diffs betweensort-package-jsonand npm):Would it be possible to get the bundled version of
sort-package-jsonupgraded from^1.57.0to latest (at least^3.2.0)?Intermediate releases with breaking changes are as follows:
sort-package-json@2.0.0: This module is now a pure ESM packagesort-package-json@3.0.0: minimum supported version is now v20.x