vueuse / vue-demi

🎩 Creates Universal Library for Vue 2 & 3
MIT License
3.01k stars 158 forks source link

refactor: use typescript #256

Closed tmg0 closed 8 months ago

tmg0 commented 8 months ago

Linked Issue

Resolves #255

Description

Refactor with typescript and used tsup as the project bundler. Do not need to manually ensure consistency in the logic of different types of JavaScript files like cjs or mjs.

Remove the updateVue2API of postinstall script, and do the ESM replace /**VCA-EXPORTS**/ by a bundler plugin. But I am not quite sure about If do the replacement during bundle instead of postinstall script is a good way.

I have tried to run the test script under .github/test.js, It seems passed under following environment:

OS: windows Node.js: v18.19.1 Package manager: npm (10.2.4) / pnpm (8.15.3)

Test commands:

And there is a iife file under root output dir for jsdelivr and unpkg, to minimize the impact of refactoring, I have temporarily disabled TypeScript checking width // @ts-nocheck and largely copied the code from index.iife.js.

But I'm still not quite sure because I haven't found how to test it.

This is a relatively significant change, and I hope it won't affect the original logic. If there are any problems that need to be edited, please let me know.

antfu commented 8 months ago

In a way I kinda did not pick TypeScript (or actually any deps) on purpose to keep the workflow simple and predictable - as this library works quite well, and is rather small that doesn't really need much maintenance, I don't see the benefit of introducing TS would justify the risk of breaking stuff, I tend to keep it as-is. Thank you for your effort but I am sorry I don't think we will take it.