Skip to content

Full Esm Support #72

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open

Conversation

axmad386
Copy link

@axmad386 axmad386 commented Mar 8, 2022

Pure ESM Mode

Refer to this for more information about pure esm https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Changes

  • chore: change builder to rollup
  • chore: remove unused files and folder
  • fix(esm): make rules extensible in esm

This PR is change builder to rollup to make life easier. Before using rollup, the esm code generated by tsc is not fully supported in esm (package with type: "module"). For example

import Something from "../folder/module" //this is invalid in pure esm without flag

With rollup our code will automatically compiled to single code index.js and imported file will automatically transformed to explicit extension like this

import Something from "../folder/module.js" //YEAY, this is valid in pure esm without flag

This PR also refactor some code that not work in esm, for example

import * as Rules from "./rules"
Rules[x] = something // this will throw ERR: cannot add property unique, object is not extensible

So I make separate file rules.ts for list all rules and rules/index.ts to export object containing list of rules. Tested in my internal project

(PS: I was submit PR before to fix this extensible esm issue, but that PR break niv extend function, I guarantee this method is work and not break extend function)

@axmad386
Copy link
Author

axmad386 commented Mar 8, 2022

I think this PR is not 100% ok. date after unit testing is still break. I don't know why. But this PR is good to start to make fully supported esm mode

@bitnbytesio
Copy link
Owner

esm support
release: 5.0.0-beta.6

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.

2 participants