warframe-worldstate-parser icon indicating copy to clipboard operation
warframe-worldstate-parser copied to clipboard

feat(ESM): convert project from CJS to ESM

Open aj-rom opened this issue 4 years ago • 7 comments

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 ecmaVersion to 2021
  • Added ESLint settings for ES modules.
New Rules
  • import/no-unresolved: 2
  • import/no-commonjs: 2
  • import/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.

Example

Dependencies

  • Node: 8.9.0 -> 17.1.0
  • eslint-plugin-import: ^2.25.3
  • @babel/eslint-parser: ^7.16.5

aj-rom avatar Dec 16 '21 02:12 aj-rom

nani

TobiTenno avatar Apr 08 '22 03:04 TobiTenno

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

TobiTenno avatar Apr 08 '22 03:04 TobiTenno

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.

aj-rom avatar Apr 08 '22 03:04 aj-rom

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

TobiTenno avatar Apr 08 '22 03:04 TobiTenno

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.

aj-rom avatar Apr 08 '22 04:04 aj-rom

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.

TobiTenno avatar Apr 08 '22 14:04 TobiTenno

i've got some instructions in WFCD/eslint-config for adding the unified rules, that might help a bit

TobiTenno avatar Apr 18 '22 05:04 TobiTenno

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 :(

TobiTenno avatar Feb 04 '24 20:02 TobiTenno