Skip to content
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

Exporting as ES Module Syntax (ESM) #8

Open
abdonrd opened this issue Sep 26, 2019 · 9 comments
Open

Exporting as ES Module Syntax (ESM) #8

abdonrd opened this issue Sep 26, 2019 · 9 comments

Comments

@abdonrd
Copy link

abdonrd commented Sep 26, 2019

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

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

@justinfagnani
Copy link

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

@epoberezkin
Copy link
Owner

epoberezkin commented Dec 19, 2020

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?

@abdonrd
Copy link
Author

abdonrd commented Dec 19, 2020

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

@epoberezkin
Copy link
Owner

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

@abdonrd
Copy link
Author

abdonrd commented Dec 22, 2020

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/

@tirithen
Copy link

tirithen commented Mar 9, 2021

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!

@thescientist13
Copy link

thescientist13 commented Mar 9, 2021

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

Keeping my eyes on those at the moment 👀 🤞

@tirithen
Copy link

tirithen commented Dec 14, 2022

@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.

@mateusrachid
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants