Vue.jsのコンポーネントのimportをdynamic importに変換するcliコマンドを作りました。
特定のディレクトリ配下のvueファイルを全てdynamic importに変換します。
ソースはこちらで公開しています。
https://github.com/harhogefoo/dynamic-import-converter
通常のcomponentのimport文
<template><div><hoge/><piyo/></div></template><script>importHogefrom"@/components/Hoge.vue"importPiyofrom"@/components/Piyo.vue"exportdefault{components:{Hoge,Piyo}}</script>
dynamic_importに変換
<template><div><hoge/><piyo/></div></template><script>exportdefault{components:{Hoge:()=>import("@/components/Hoge.vue"),Piyo:()=>import("@/components/Piyo.vue")}}</script>
使い方
$ yarn global add dynamic-import-converter
or
$ npm install-g dynamic-import-converter
$ dynamic-import-converter ./Vueファイルが格納されたディレクトリのパス/
バグ、改善要望などは、リポジトリのissueまで!
https://github.com/harhogefoo/dynamic-import-converter/issues