docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.47k stars 5.67k forks source link

Get rid of CommonJS module format, use only ES Modules. #2102

Closed trusktr closed 1 year ago

trusktr commented 1 year ago

Feature request

The future is already here, and it is ES Modules. We currently build SSR to CommonJS, for example. CommonJS is outdated now, and we should move onto ES Modules and simplify our setup for all possible tooling that now understand the ES Module standard.

What problem does this feature solve?

We have legacy complexity. Move to modern standard.

What does the proposed API look like?

Remove any CommonJS (CJS) outputs, ensure everything is ES Modules (ESM).

Note, .eslintrc.cjs remains as CommonJS because current ESLint v8 doesn't support ESM in eslintrc. ESLint 9 will require the new "flat config" format, which will require ESM.

How should this be implemented in your opinion?

F.e. open rollup configs, don't output to cjs, output to esm.

Are you willing to work on this yourself?

Yes (PR https://github.com/docsifyjs/docsify/pull/2106)

Is this a breaking change?

Yes, this update can possibly break any dev's tooling relying on old CJS. This will not break people who import Docsify with script tag, only people who build Docsify source code. We should provide a clear path in the release notes.

trusktr commented 1 year ago

This change requires bumping the major version.

I strongly suggest we stop "saving a bunch of stuff" for a 5.0 release. We should organically perform the changes we need to perform to keep the project modern, and if that means we release this and it is the only reason to bump to version 5.0, then we release other breaking changes later to bump to 6.0, 7.0, etc, later, that would be totally fine.

We don't have the manpower and resources to coordinate a huge single breaking release, and IMO that has been holding us back.

Also, without making too many breaking changes at once, it will be easier for people to follow a migration path over time.

trusktr commented 1 year ago

I will re-place the original PR that I'd started at https://github.com/docsifyjs/docsify/pull/1689 with a new one that maintains backwards compat.

trusktr commented 1 year ago

PR: https://github.com/docsifyjs/docsify/pull/2106