-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ESmodulesに移行 #7658
Comments
ESMだとディレクトリインポートができないみたい 例えば import boot from './boot'; は import boot from './boot/index.js'; に書き換える必要がある |
(そんなのTypeScriptコンパイラーがよしなにやってほしい) |
あー、あとそもそも拡張子省略できない |
死ぬほど大変じゃん |
とても大変ということが分かったので、ESMに移行するのは一旦諦め、CJSに対応している古いバージョンのライブラリを使い続けていくことにする |
なんか単純置換でいけそうな気もする |
ふーむ |
あるインポートがローカルのファイルを指しているのかパッケージを指しているのか区別が難しい場合もあるかもしれないけど、ほとんどは置換でいけるか…? |
多分ほとんどのローカルのインポートは./とかで始まってる気がするからいけるかも |
ローカルのファイルは基本 @/ or ./ or ../ から始まるはず |
例えばどれだわ? |
pureimageとかis-rootとか |
jsonをrequireしてる箇所ってどう置き換えれば良いんだろ https://stackoverflow.com/questions/34944099/how-to-import-a-json-file-in-ecmascript-6 によると将来的には出来るようになるらしいけど |
|
いや嘘 |
現時点での移行は難しいかも |
あんまりCommonJSで動かないモジュールって記憶になくて pureimageは 0.3.3 >= は本当にdistフォルダがないから単に壊れてるだけかも is-rootはESM要求してるけど、そもそもrootチェックっていらないのではと。 |
というか is-root 中身は process.getuid() === 0 だしわざわざパッケージ使わなくてもよさそう |
is-rootたった3行しかなかった |
|
|
将来ESMに移行しやすいように Related: #7658 なんかmochaが起動しなくなってるけど理由不明 すぐ直したい
あー、拡張子を.jsにするとts-nodeで直接ts動かす時にエラーになるな |
うーんヨクワカラン |
これ止めといたほうが良い気がする |
npmでインストールしたライブラリがCJSでもESMは使えるよね?そんなことない? |
もし依存ライブラリもすべてESMでないといけないとしたらESM移行は不可能そう |
ESMで出力したら |
|
が出るわね |
:tasukete: |
ライブラリによっては型として正しいimport方法と実際に動くimport方法が異なる場合が発生するな |
autobind消したら出なくなった |
起動しようとするとエラーは出なくなったけど起動しない |
直った |
一応起動するとこまでは来た |
autobind消したから、this周りの不具合が発生するはずなので何か対策考えないと |
おとなしく |
テストが動かない問題を解決した人に¥3000進呈 |
A lot of calls to |
Is this a standard feature of esmodules...? @Johann150 |
Summary
node向けのライブラリもes modulesを使用するものが増えてきて、commonjsだと使えないため
やることリスト
--experimental-json-modules
__dirname
を置き換えるref. https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
The text was updated successfully, but these errors were encountered: