vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

Module has no default export #1886

Open shameleo opened 3 years ago

shameleo commented 3 years ago

Version

16.6.0 and later

Reproduction link

github.com

Steps to reproduce

npm install
npm run dev

What is expected?

No errors

What is actually happening?

Module '"...Page.vue"' has no default export


Maybe it has something to do with shims-vue.d.ts file content. To be honest I don't quite understand things like this yet.

LinusBorg commented 3 years ago

https://www.typescriptlang.org/tsconfig#include

If a glob pattern doesn’t include a file extension, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).

shameleo commented 3 years ago

@LinusBorg, I didn't get it. Page.vue is missing in tsconfig include? Shouldn't appendTsSuffixTo: [/\.vue$/] line in ts-loader options fix it? Anyway, I tried my best to include this file. Like: "include": ["src/**/*.ts", "src/**/*.vue"] "include": ["src/**/*.+(ts,vue)"] "include": ["src/**/*.{ts,vue}"] "files": ["src/index.ts", "src/Page.vue", "src/shims-vue.d.ts"] None of this works And it worked with previous versions of vue-loader, after all.

haoqunjiang commented 3 years ago

Looks similar to https://github.com/vuejs/vue-loader/issues/1882

kkuegler commented 3 years ago

I could not get this to work with a tsconfig that worked well in other contexts. There might be an order problem, as any changes during Webpack watch (e.g. changing some text in the .vue file) make Webpack work after it initially reported an error.

Updating ts-loader to 9.2.6 properly resolved this for me. In fact any of the 9.x versions seems to work.

HelloHxz commented 3 years ago

我也遇到了相关问题,但是webpack运行没有问题,打包就会失败,偶尔成功。TS2345: Argument of type '{ new (): { $props: VNodeProps; }; __isFragment: true; }' is not assignable to parameter of type 'string'. 求解

shameleo commented 2 years ago

~Updating ts-loader to 9.x.x indeed solves the issue with sample project, but now I have error in original project same as HelloHxz mentioned. (only if I'm updating vue-loader as well). This blocks me from updating vue-loader and using script setup feature. We still need fix.~

My bad, of course I should have tried update @vue/compiler-sfc and vue as well. Seems to work fine now.