yoyo930021 / vc2c

The vc2c project can convert vue class APIs to vue composition APIs in Vue.js components written in Typescript.
https://yoyo930021.github.io/vc2c/
MIT License
87 stars 20 forks source link

Make this project compatible with webpack #10

Open stevefan1999-personal opened 4 years ago

stevefan1999-personal commented 4 years ago

Hi, I'm working on a meta-transpiler that compiles Vue SFC blocks to different languages and I see that this project is very interesting because I can chain it up with hikerpig/vue-classify to convert classic Vue components into composition API indirectly, but I have some problem how to transpile it in Webpack.

I'm also using Nuxt too and I have added vc2c to build.transpile but I still got eslint, import-modules and various dependency missing error, and all of them are pointing to the missing dependency module, which is ridiculous and very spurious since I explicitly set to transpile this project.

I saw that your project uses Parcel and I quickly come up with a hack to point to src/index.ts and use the emitted file on my Nuxt website;. Indeed it worked but the bundle size is enormous, for 5.5MB. This is clearly not acceptable, so I want to ask you about whether you would switch to rollup and allow ESM passthrough, so I can also share some of the dependencies with other projects too? The biggest problem now is compile time because webpack has to again do compilation on the Parcel bundle which is quite meaningless...

yoyo930021 commented 4 years ago

I don't need any bundled tools about main project. Parcel is only used for demo page. I don't know why webpack is breaking. Maybe I will study this problem when free.

stevefan1999-personal commented 4 years ago

But the problem is you didn't supply a ESM version for bundlers that accept modern modules...I see you defaulted to use CommonJS which webpack can barely tree-shake to escape the module resolution & re-use problem between browsers and nodejs. I made some simple tweaks and assumptions to optimize this for multiple different use, would you like to review it?

Also, I see that there are also no Vuex conversion support, that's a pity but I know Vuex 4 is not yet finalized so...may I ask if you will like to research on that ASAP when Vuex 4 comes out, at least during RC?

Don't worry; tests are still passing, and CLI should work flawless too

yoyo930021 commented 4 years ago

I just wanted to do it for node environment. The demo is doing after main code. XD

Except, this project has some capability for convert classic Vue components into composition API. But I'm not export about this.