-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with cjs version of prettier-plugin-sql Cannot read properties of undefined (reading 'parse')
#332
Comments
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 |
prettier/packages/sql/shim.d.ts Line 2 in 3d85966
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 |
Yep I tried this locally when I was investigating. It seems like |
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.The text was updated successfully, but these errors were encountered: