diff --git a/.changeset/red-news-worry.md b/.changeset/red-news-worry.md new file mode 100644 index 00000000..79f5ee42 --- /dev/null +++ b/.changeset/red-news-worry.md @@ -0,0 +1,5 @@ +--- +"prettier-plugin-sql": patch +--- + +fix: handle inconsistent exports of JSOX diff --git a/packages/sql/shim.d.ts b/packages/sql/shim.d.ts index d7d5374f..5c150d08 100644 --- a/packages/sql/shim.d.ts +++ b/packages/sql/shim.d.ts @@ -1,3 +1,5 @@ declare module 'jsox' { - export const JSOX: typeof JSON + const JSOX: typeof JSON & { JSOX?: typeof JSON } + + export = JSOX } diff --git a/packages/sql/src/index.ts b/packages/sql/src/index.ts index 9dfbc6ff..70f35be7 100644 --- a/packages/sql/src/index.ts +++ b/packages/sql/src/index.ts @@ -1,6 +1,6 @@ /// -import { JSOX } from 'jsox' +import * as _JSOX from 'jsox' import type { AST, Option } from 'node-sql-parser' import nodeSqlParser from 'node-sql-parser' import type { Options, ParserOptions, Plugin } from 'prettier' @@ -8,6 +8,9 @@ import { format, type FormatOptionsWithLanguage } from 'sql-formatter' import { languages } from './languages.js' +// see #332 for more details +const JSOX = _JSOX.JSOX || _JSOX + const parser = new nodeSqlParser.Parser() const SQL_FORMATTER = 'sql-formatter'