vuejs / rollup-plugin-vue

Roll .vue files
https://vuejs.github.io/rollup-plugin-vue
MIT License
846 stars 148 forks source link

Broken Vue 3 typescript #400

Open iassasin opened 3 years ago

iassasin commented 3 years ago

Version

6.0.0-beta10

Reproduction link

https://github.com/iassasin/vue3-rollup-ts-bug

Steps to reproduce

Clone example repository and npm run build.

What is expected?

working bundle

What is actually happening?

[!] (plugin typescript) Error: Could not load .../MainView.vue?vue&type=script&lang.ts (imported by MainView.vue): Debug Failure. False expression: Expected fileName to be present in command line

What I did wrong? Looks like rollup-plugin-vue bug.

Smashman commented 3 years ago

Ensure that the rollup-plugin-vue plugin is run before @rollup/plugin-typescript.

iassasin commented 3 years ago

@Smashman, if use this order of plugins, then error changes:

    plugins: [
        alias({
            resolve: [ '.js', '.ts' ],
            entries: [
                { find: 'vue', replacement: 'node_modules/vue/dist/vue.runtime.esm-browser.js' }
            ]
        }),
        resolve(),
        Vue({ preprocessStyles: true }),
        typescript(),
        css({ output: 'dist/app.css' }),
    ],

Error:

Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (.../vue3-rollup-bug/node_modules/rollup/dist/shared/rollup.js:5215:30)

Looks like typescript doesn't recognized at all.

Btw, see issue in typescript plugin (https://github.com/rollup/plugins/issues/608), maybe this issue doesn't related to rollup-plugin-vue, because with rollup-plugin-typescript2 config from my reproduction works great.

kris-ellery commented 3 years ago

@iassasin I had the same issue, switching from @rollup/plugin-typescript to rollup-plugin-typescript2 fixed it.

iassasin commented 3 years ago

@kris-ellery, yes, I use this workaround too, but it's strange if it shouldn't work with official ts plugin.

Mister-Hope commented 3 years ago

it's strange if it shouldn't work with official ts plugin.

Agree with that, I waste 15 minutes on the official plugin before finding out the example is using rollup-plugin-typescript2

mnlipp commented 3 years ago

I think its a bug in the "official plugin" (see https://github.com/rollup/plugins/issues/608).