fast-json-stable-stringify icon indicating copy to clipboard operation
fast-json-stable-stringify copied to clipboard

Exporting as ES Module Syntax (ESM)

Open abdonrd opened this issue 6 years ago • 9 comments

Please, export "module" entry point in the package.json as ES Module Syntax (ESM).

More info about it here: https://www.pikapkg.com/about/

abdonrd avatar Sep 26 '19 14:09 abdonrd

I just this problem when trying to use Apollo. It wouldn't load because fast-json-stable-stringify isn't published as JS modules.

justinfagnani avatar Dec 18 '20 20:12 justinfagnani

I think it can be loaded either using esModuleInterop setting or with import stringify = require(“...”), same as most nodejs modules. I am probably missing something - why is it important to have default export in addition to it?

epoberezkin avatar Dec 19 '20 11:12 epoberezkin

Because you can't use require / module.exports (CJS) directly in the browser. But you can use the standard import / export (ESM).

abdonrd avatar Dec 19 '20 11:12 abdonrd

Interesting... Wouldn’t it get bundled together anyway? Or you just load them as separate files?

epoberezkin avatar Dec 19 '20 11:12 epoberezkin

Interesting... Wouldn’t it get bundled together anyway? Or you just load them as separate files?

During development I don't use any bundler.

Reference: https://modern-web.dev/guides/going-buildless/getting-started/

abdonrd avatar Dec 22 '20 15:12 abdonrd

Has there been any progress on getting this package ready for use as standard ESM module? I have projects that are still on a fork from this package, it would be great if it was possible to get the ESM version released as most recent projects will use ESM over CJS.

Thanks for an otherwise great package!

tirithen avatar Mar 09 '21 08:03 tirithen

@tirithen et all, There are a couple PRs open around advancing this forward

  • #10
  • #20

Keeping my eyes on those at the moment 👀 🤞

thescientist13 avatar Mar 09 '21 20:03 thescientist13

@epoberezkin has there been any progress on getting the ESM export in place, I have a working fork of this at https://github.com/tirithen/fast-json-stable-stringify/blob/master/esm.js , but it really would be much better to get ESM support built into this repo as that is the one that is published as an npm package.

It has now been around 3 years since this issue was opened and I believe that the change is not that hard to make. CJS is okay for older projects but most new projects and frameworks need the standard ecmascript modules.

There is a good guide over at modern web on how to work with es modules https://modern-web.dev/guides/going-buildless/es-modules/ . There is also a more in depth guide over at Mozilla Developer Network https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules .

Fingers crossed that this can be resolved.

tirithen avatar Dec 14 '22 15:12 tirithen

Is anyone here maintaining a fork with ESM support? I believe many people would be interested.

mateusrachid avatar Aug 28 '23 16:08 mateusrachid