Git Product home page Git Product logo

Comments (7)

Brookke avatar Brookke commented on July 29, 2024 1

Good idea, I'm happy to open a pr tomorrow with those changes (it's late UK time right now)

from prettier.

JounQin avatar JounQin commented on July 29, 2024

Would you like to raise a PR which will be appreciated!

from prettier.

Brookke avatar Brookke commented on July 29, 2024

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

from prettier.

JounQin avatar JounQin commented on July 29, 2024

export const JSOX: typeof JSON

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.

from prettier.

JounQin avatar JounQin commented on July 29, 2024

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

from prettier.

Brookke avatar Brookke commented on July 29, 2024

export const JSOX: typeof JSON

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

from prettier.

JounQin avatar JounQin commented on July 29, 2024

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

from prettier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.