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

02 support only esm at first #15

Draft
wants to merge 6 commits into
base: 01-02-use-vitest
Choose a base branch
from

Conversation

Yang-33
Copy link
Owner

@Yang-33 Yang-33 commented Mar 27, 2024

テストが全く動かない点に目をつぶれば、目標はある程度達成できている...?

  • unit testを動くようにする mochaをvitestにしました
  • package.jsonをESM用に直す
  • ESM example projectを書いて、ローカルで動かしてテストできるようにする -> 3でやる

ここではESMのみサポートに切り替え、CJS対応は次の変更でやる

@Yang-33 Yang-33 changed the base branch from master to 01-stop-reading-package-json-in-code March 27, 2024 14:53
@Yang-33
Copy link
Owner Author

Yang-33 commented Mar 30, 2024

vitestにしたら全て解決した

vitejs/vite#15714 これと全く同じ問題にあたった。
vitestはviteをつかっている。viteの問題なのだけど、最新のvitest1.4.0が依存しているviteのバージョンでは治っていない。
最新のviteを明示的に依存に入れて解決した。

@Yang-33
Copy link
Owner Author

Yang-33 commented Mar 30, 2024

local publishまでして検証してないけど、依存を他のプロジェクトに入れたらちゃんとESMで動いてそう

@Yang-33 Yang-33 force-pushed the 01-stop-reading-package-json-in-code branch from 7e40057 to 2ea088a Compare April 1, 2024 02:36
@Yang-33 Yang-33 mentioned this pull request Apr 1, 2024
@Yang-33 Yang-33 force-pushed the 02-support-only-esm-at-first branch from 9c3c510 to c697249 Compare April 1, 2024 02:46
@Yang-33 Yang-33 changed the base branch from 01-stop-reading-package-json-in-code to 01-02-use-vitest April 1, 2024 02:46
@Yang-33 Yang-33 force-pushed the 02-support-only-esm-at-first branch from c697249 to 8aa376d Compare April 1, 2024 02:47
Yang-33 and others added 6 commits April 2, 2024 09:36
When line-bot-sdk-nodejs supports ESM, we will use ESM code for testing.
Vitest supports ESM+Typescript. This change will switch from using mocha
to using vitest.

Also, along with mocha, nyc will be removed from dependencies because
vitest supports coverage as well.

About the workaround:
1. Running vitest 1.4.0 results in TypeScript errors due to an issue
with vite, which vitest uses. The latest version of vite has fixed this,
so I explicitly added the latest vite to the dev dependencies.
    - vitejs/vite#15714
2. Running vite for CJS leads to TypeScript errors due to an issue with
rollup, which vite uses. There is no good workaround for CJS. I resolved
this by rewriting node_modules as a workaround. There are no problems
using vitest(?)
   * rollup/rollup#5199
   * vitest-dev/vitest#4567
a
02 a
@Yang-33 Yang-33 force-pushed the 02-support-only-esm-at-first branch from fb798c5 to 1cba2c3 Compare April 2, 2024 00:38
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.

1 participant