Open abdonrd opened 5 years ago
I just this problem when trying to use Apollo. It wouldn't load because fast-json-stable-stringify isn't published as JS modules.
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?
Because you can't use require
/ module.exports
(CJS) directly in the browser.
But you can use the standard import
/ export
(ESM).
Interesting... Wouldn’t it get bundled together anyway? Or you just load them as separate files?
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/
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 et all, There are a couple PRs open around advancing this forward
Keeping my eyes on those at the moment 👀 🤞
@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.
Is anyone here maintaining a fork with ESM support? I believe many people would be interested.
Please, export
"module"
entry point in thepackage.json
as ES Module Syntax (ESM).More info about it here: https://www.pikapkg.com/about/