Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Convert package to ESM #70

Closed
9 tasks
nzakas opened this issue May 7, 2021 · 6 comments · Fixed by #71 · May be fixed by OKEAMAH/remix-project#10
Closed
9 tasks

Convert package to ESM #70

nzakas opened this issue May 7, 2021 · 6 comments · Fixed by #71 · May be fixed by OKEAMAH/remix-project#10

Comments

@nzakas
Copy link
Member

nzakas commented May 7, 2021

To convert this package from CommonJS to ECMAScript modules (ESM):

  • Add type: module to package.json
  • Convert files in lib to ESM
  • Convert files in tests/lib to ESM
  • Upgrade Mocha
  • Create build script in package.json to generate CommonJS file (.cjs) in dist directory (use Rollup)
  • Add dist to .gitignore
  • Run build in prepare script in package.json to ensure build is run at key moments
  • Update package.json so that main points in the CJS file in dist and exports provides both require and import options
  • Update README instructions
@brettz9
Copy link
Contributor

brettz9 commented Jun 24, 2021

Would you like to change to named exports here too?

@nzakas
Copy link
Member Author

nzakas commented Jun 25, 2021

Sure, I'm open to that.

@brettz9
Copy link
Contributor

brettz9 commented Jun 25, 2021

FWIW, in my PR I've kept some single item files as default exports, but for the main one (the one being exported) and others, they are named.

@aladdin-add
Copy link
Member

as I mentioned here, eslint-scope was used by webpack, too. the change would stop webpack upgrading to the latest eslint-scope. // @sokra

@nzakas
Copy link
Member Author

nzakas commented Jun 25, 2021

@aladdin-add would it stop them from upgrading, or would they just wait a bit longer? I assume with a breaking change that it would probably go through a more thorough evaluation before upgrading regardless.

@aladdin-add
Copy link
Member

yes, they will drop Node.js < 12 at some point, it's just a bit longer.

nzakas added a commit that referenced this issue Jul 22, 2021
* Chore: Update devDeps.

* Chore: Lint according to latest config

* Breaking: Switch to ESM; also adds eslint-plugin-jsdoc for linter

* Fix: Sync with eslint-visitor-keys, including fixing cjs linting

* Update package.json

Co-authored-by: Nicholas C. Zakas <[email protected]>

* Test: Drop Node 13, 10, 8 tests, and add 16, 12.22.0

* Docs: Add comment to explain shelljs command

* Refactor: Apply new API and ESM changes

* Chore: Update devDeps.

* Docs: Update espree usage in README

* Test: Add CJS file

* Update README.md

Co-authored-by: Nicholas C. Zakas <[email protected]>

* Fix: Avoid named imports of CJS modules

* Fix: For browser compatibility, avoid package.json file-reading attempt

* Refactor: Drop `fs` from Rollup now that not in use

* Fix: Stop re-exporting Scope child classes and only export `Scope`

* Fix: Re-export Reference, Definition, and PatternVisitor

* Update Makefile.js

Co-authored-by: Milos Djermanovic <[email protected]>

* Update tests/commonjs.cjs

Co-authored-by: Brandon Mills <[email protected]>

Co-authored-by: Nicholas C. Zakas <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Brandon Mills <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
3 participants