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

feat: support esm file loader #3045

Merged
merged 17 commits into from
Aug 13, 2023
Merged

feat: support esm file loader #3045

merged 17 commits into from
Aug 13, 2023

Conversation

czy88840616
Copy link
Member

@czy88840616 czy88840616 commented Jun 22, 2023

有比较大量的改动,esm 和 cjs 有较大的差距,主要体现在文件加载方式中

  • 1、通过 package.json 来判断是否走 esm 还是 commonjs,影响 bootstrap 和 mock 包的启动逻辑
  • 2、调整加载文件的方式,不能再使用 safeRequre,换成 loadModule,这将导致启动逻辑变为异步,不支持 egg
  • 3、不能在代码中出现 __dirname,__filename 逻辑,esm 不支持
  • 4、不能使用动态 require 方式加载包,得用 loadModule
  • 5、影响数据库之类的组件 models 加载
  • 6、为了简化组件中加载文件,增加当前使用的是 esm 还是 commonjs 的 API
  • 7、移除 node14 的 ci 环境

related: #1416

@czy88840616 czy88840616 added pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: new feature This PR adds a new API or behavior. labels Jun 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2023

Codecov Report

Patch coverage: 75.00% and project coverage change: +2.33% 🎉

Comparison is base (c6d8317) 81.83% compared to head (d9abd97) 84.17%.
Report is 18 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3045      +/-   ##
==========================================
+ Coverage   81.83%   84.17%   +2.33%     
==========================================
  Files         438      469      +31     
  Lines       15936    44064   +28128     
  Branches     3773     5312    +1539     
==========================================
+ Hits        13042    37091   +24049     
- Misses       2626     6936    +4310     
+ Partials      268       37     -231     
Files Changed Coverage Δ
packages/bootstrap/src/index.ts 100.00% <ø> (ø)
packages/bootstrap/src/util.ts 82.00% <ø> (-5.10%) ⬇️
packages/bootstrap/src/bootstrap.ts 22.70% <16.66%> (+14.51%) ⬆️
packages/info/src/utils.ts 80.39% <20.00%> (-15.77%) ⬇️
packages/core/src/common/fileDetector.ts 70.09% <33.69%> (-29.91%) ⬇️
packages/mock/src/utils.ts 64.70% <60.00%> (-0.61%) ⬇️
packages/mock/src/creator.ts 76.39% <76.36%> (+5.60%) ⬆️
packages/core/src/util/index.ts 85.01% <80.64%> (+1.23%) ⬆️
packages/core/src/setup.ts 66.07% <87.34%> (-29.08%) ⬇️
packages/core/src/context/container.ts 95.01% <95.00%> (+0.02%) ⬆️
... and 14 more

... and 392 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@czy88840616 czy88840616 changed the title feat: support mjs file loader feat: support esm file loader Jun 22, 2023
@waitingsong
Copy link
Member

开始做 esm 支持了哇。
feat 功能完成后能不能提供一个(页面)文档的链接方便了解此功能

@czy88840616
Copy link
Member Author

@waitingsong minor 版本有发布介绍,文档也会更新。

@czy88840616 czy88840616 force-pushed the support_mjs branch 2 times, most recently from b0298d0 to a4a57b3 Compare July 10, 2023 11:50
@czy88840616 czy88840616 added this to the 3.12 milestone Jul 30, 2023
@czy88840616 czy88840616 merged commit 10f96d4 into main Aug 13, 2023
6 checks passed
@czy88840616 czy88840616 deleted the support_mjs branch August 13, 2023 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: new feature This PR adds a new API or behavior.
Development

Successfully merging this pull request may close these issues.

3 participants