vite-plugin / vite-plugin-dynamic-import

Enhance Vite builtin dynamic import
https://www.npmjs.com/package/vite-plugin-dynamic-import
MIT License
193 stars 11 forks source link

[vite-plugin-dynamic-import] Generated runtime code has redundant judgment rules in some cases #66

Open jiadesen opened 1 year ago

jiadesen commented 1 year ago

For the following dynamic import

import(`./components/${singlePathName}/index.vue`)

If singlePathName is "A" or "B", in the following generated code, case "./components/A" and case "./components/A/index" are not necessary

switch (n) {
    case "./components/A":
    case "./components/A/index":
    case "./components/A/index.vue":
        return ...;
    case "./components/B":
    case "./components/B/index":
    case "./components/B/index.vue":
        return ...;
    default:
        ....
caoxiemeihao commented 1 year ago

Okay! thanks for your feedback :)