Open Colisan opened 2 years ago
Having this issue as well.
You probably should use appendTsSuffixTo: [/\.vue$/]
in the ts-loader to avoid the problem.
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/]
},
exclude: /node_modules/,
},
{
test: /\.vue$/i,
loader: "vue-loader",
options: {
esModule: true,
},
},
@jbruwes Well found! It indeed solve the problem.
Maybe we should add this critical information somewhere in the vue-loader documentation?
There is a mention in the documentation related to the issue: https://github.com/TypeStrong/ts-loader#appendtssuffixto
Just as it has been written in the documentation: "This is useful for *.vue file format for now. (Probably will benefit from the new single file format in the future.)"
Um, no this is a bug. The @vue/cli-plugin-babel broke this going from V4.5 to ~V5.0 for re-exporting components.
Version
16.8.3
Reproduction link
github.com
Steps to reproduce
Hi, I encounter the following, very puzzling, build&runtime error :
index.ts
test.ce.vue
webpack.config.js
tsconfig.json
What is expected?
No error
What is actually happening?
When building, somehow the loader think that the exports from the vue file are instead the exports from the index.ts file. The same happen in another big project where the .vue export seems to be confused from any random exports in any random .ts file. It's not only a type warning, the actual imported object at runtime is wrong too!
Maybe there's a conflit between vue-loader and ts-loader? Maybe my configuration is wrong?
Workaround
If I replace the script with a non-Typescript one:
It works fine and without error. However, not using Ts is not an option in my context and I'd prefer if we could fix the causes instead of dodging the consequences =)