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

Add ESM Support. #36

Open
wants to merge 2 commits into
base: latest
Choose a base branch
from
Open

Add ESM Support. #36

wants to merge 2 commits into from

Conversation

LJNeon
Copy link

@LJNeon LJNeon commented Jul 5, 2020

This PR adds full ESM support for all viable versions (Node 12-14 and above), while also maintaining full CommonJS support in every version. This is achieved through a very simple wrapper file that re-exports CommonJS code as ESM, but only when an import statement is used instead of require().

Node 12-13 have highly experimental ESM support that may require a flag and/or a subpath (import "@iarna/toml/esm") in order to function. If you don't wish to support this, or if you find the /esm subpath messy, you could easily remove the "./esm": "./toml-esm.mjs" line from the package.json file, while still maintaining full ESM support in Node 14 and all later versions.

I was unsure if any documentation is necessary for this change, but I would think at most a small note would be enough. Feel free to let me know if (and ideally what kind of) documentation is necessary.

Fixes #32

Copy link

@jsejcksn jsejcksn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking forward to ESM support in this package! I added some suggestions to the commits in this PR.

package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
toml-esm.mjs Outdated Show resolved Hide resolved
@LJNeon
Copy link
Author

LJNeon commented Aug 24, 2020

@iarna any ETA on this getting merged?

@mustafa0x
Copy link

Related: trying to use with vite gives global is not defined error. ESM support would be nice.

@newproplus
Copy link

newproplus commented Dec 19, 2022

I use vite, got error: Uncaught ReferenceError: global is not defined. ESM support would be nice.So I made an ESM verion,works well with vite

@lizy0329-biubiubiu
Copy link

use iarna-toml-esm

@mustafa0x
Copy link

Probably makes sense to use https://github.com/squirrelchat/smol-toml

@lizy0329-biubiubiu
Copy link

lizy0329-biubiubiu commented Nov 13, 2023

Probably makes sense to use squirrelchat/smol-toml使用 squirrelchat/smol-toml 可能有意义

Yes, I find it in TOML offical repo. But iarna-toml repo is the first search result when I search "TOML" key word by github search bar

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

Successfully merging this pull request may close these issues.

Outdated Node.js version support
6 participants