We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://zenn.dev/teppeis/articles/2021-10-typescript-45-esm
ここまでだとtsconfig.jsonに記載したpath解決をできなくなるため、実行時にパッケージを読み込むことができない
tsconfig.json
Cannot find package '@/modules' imported from C:\xxxxx
現状の解消方法としてはpath解決での読み込み自体をなくして、相対パスで各種ソースを読み込むものとする
"baseUrl": "./", "paths": { "@/*": ["src/*"] },
※ 例外としてts-node の実行時にloaderで個別ファイルを挟めば可能ではある https://kimuson.dev/blog/typescript/ts_node_esm_paths/
監視ツールとしてts-node-devを利用していたがesmに対応していないと思われるためnodemonに変更した ts-node-devの方が動作が早いとのことで導入したがソースが小規模であることからnodemonでも問題ないだろうと判断
ts-node-dev
nodemon
jestやeslintなどのconfig.jsファイルはconfig.cjsに変更し設定も変更する必要がある
config.js
config.cjs
The text was updated successfully, but these errors were encountered:
Merge pull request #2 from /issues/1-to-esm-from-cjs
bef5af1
migrate to esm
Successfully merging a pull request may close this issue.
commonjs => esm への移行
ソースコードの変更
https://zenn.dev/teppeis/articles/2021-10-typescript-45-esm
ここまでだと
tsconfig.json
に記載したpath解決をできなくなるため、実行時にパッケージを読み込むことができない現状の解消方法としてはpath解決での読み込み自体をなくして、相対パスで各種ソースを読み込むものとする
※ 例外としてts-node の実行時にloaderで個別ファイルを挟めば可能ではある
https://kimuson.dev/blog/typescript/ts_node_esm_paths/
開発ツールのesm対応
監視ツールとして
ts-node-dev
を利用していたがesmに対応していないと思われるためnodemon
に変更したts-node-dev
の方が動作が早いとのことで導入したがソースが小規模であることからnodemon
でも問題ないだろうと判断jestやeslintなどの
config.js
ファイルはconfig.cjs
に変更し設定も変更する必要があるThe text was updated successfully, but these errors were encountered: