Skip to content
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

WIP: refactor: migrate to ESM #130

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

yoshinorin
Copy link
Member

@yoshinorin yoshinorin commented Jun 14, 2022

WIP

@yoshinorin yoshinorin marked this pull request as draft June 14, 2022 14:53
@stevenjoezhang
Copy link
Member

We could change typescript settings to generate ESM now.

Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although some of Node.js community members stated that the cost of transition is minimum, but unfortunately this isn't true for Hexo. We can (and we should) experimenting with ESM, but I will block this PR from being merged, since ESM is still not ready yet. Here are why:

  • Import Map does not work as expected for most of Node.js versions.
  • Inconsistent default import/export behavior across runtime/bundler.
  • We can't replace dynamic require with dynamic import. Hexo uses dynamic require for lazy-loading modules in order to improve cold boot performance and reduce the memory usage. While dynamic require is synchronous, dynamic import is asynchronous and we will have to make huge change to our existing code bases (mostly plugin loading, themes' scripts loading, extensions loading, etc.), and eventually we will have to introduce breaking changes that will break most of existing themes and plugins.

@D-Sketon
Copy link
Member

I think this PR can be closed

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.

4 participants