Closed Brookke closed 6 months ago
Would you like to raise a PR which will be appreciated!
Happy to help, however I don't have a proper fix yet other than directly modifying the bundled code. I think it might be a rollup config issue, I will spend some more time looking into how rollup is setup here
It needs to be changed to
const JSOX = typeof JSON
export = JSOX
And the ESM version should be changed accordingly.
You can juat raise the PR and I'll review and guide to finish.
https://github.com/d3x0r/JSOX/blob/44d2c55a1f0cfaf60f4b7f07f8565420f05498d0/package.jsox#L20-L24
https://github.com/d3x0r/JSOX/blob/44d2c55a1f0cfaf60f4b7f07f8565420f05498d0/lib/jsox.mjs#L3018
Interesting. This means it's an upstream issue actually...
cc @d3x0r
It needs to be changed to
const JSOX = typeof JSON export = JSOX
And the ESM version should be changed accordingly.
You can juat raise the PR and I'll review and guide to finish.
Yep I tried this locally when I was investigating. It seems like import { JSOX } from 'jsox'
is valid and in CommonJS it's var jsox = require('jsox')
. I assumed they'd be something in roll up that could fix this for us. But you're right ideally it'd be fixed upstream
We need to support both of them at the same time.
// shim.d.ts
const JSOX: typeof JSON & { JSOX?: typeof JSON}
expot = JSOX
// index.ts
import * as _JSOX from 'jsox'
// workaround for inconsistent cjs/esm exports
const JSOX = _JSOX.JSOX || _JSOX
Good idea, I'm happy to open a pr tomorrow with those changes (it's late UK time right now)
I am getting the following error when trying to use this plugin prettier on save in vscode:
I have established that the commonjs version of the plugin does not import JSOX correctly. The bundled code is as follows:
Swapping,
jsox.JSOX.parse
tojsox.parse
fixes the issue.