feat(ESM): convert project from CJS to ESM
Convert Project from CJS to ESM
closes #335
This PR includes many file changes and dependency updates.
Some important notes:
- Switched project type to
"module". - Updated node to support ES modules.
ES Lint
- Switched source type for ESLint to module.
- Set
ecmaVersionto2021 - Added ESLint settings for ES modules.
New Rules
import/no-unresolved: 2import/no-commonjs: 2import/extensions: [ 2, "ignorePackages" ]import/no-named-as-default: "off"import/no-named-as-default-member: "off"
Testing
Currently we monkey patch using rewire, which seems to no longer work for ESM. For the time being tests using dependency injections have been commented out.
Dependencies
- Node:
8.9.0 -> 17.1.0 - eslint-plugin-import:
^2.25.3 - @babel/eslint-parser:
^7.16.5
nani
i was actually gonna bug you soon that i think the non-assert way of importing json might work for a bit as long as we keep it to the one file, and i saw a way to do it async but expose them asynchronously
i was actually gonna bug you soon that i think the non-assert way of importing json might work for a bit as long as we keep it to the one file, and i saw a way to do it async but expose them asynchronously
Ah I was assuming we were going to wait for the native support to role out later this year, but I'll re-open for now.
i was actually gonna bug you soon that i think the non-assert way of importing json might work for a bit as long as we keep it to the one file, and i saw a way to do it async but expose them asynchronously
Ah I was assuming we were going to wait for the native support to role out later this year, but I'll re-open for now.
i think i've found decent enough reason to use the workaround that until the native support in, it's definitely workable to use the weird-ish require imports, as long as you're cool rebasing and giving that a go
i think i've found decent enough reason to use the workaround that until the native support in, it's definitely workable to use the weird-ish require imports, as long as you're cool rebasing and giving that a go
Oh yeah I could put in some work on this over the weekend.
Awesome. I've spent a bit more time hammering about with esm and got a pretty decent setup with linting on genesis, set up a shared lint config if you wanna try adding it with your esm work, since there's a specific esm config that can always use more definition.
i've got some instructions in WFCD/eslint-config for adding the unified rules, that might help a bit
sorry, @aj-rom, enough got moved around in the 2 years it took to get asserts to even be part of the non-experimental stuff that almost all the files have conflicts, so too much for me to rebase :(