vue-loader icon indicating copy to clipboard operation
vue-loader copied to clipboard

Module has no default export

Open shameleo opened this issue 4 years ago • 6 comments
trafficstars

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.

shameleo avatar Oct 11 '21 13:10 shameleo

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).

LinusBorg avatar Oct 11 '21 14:10 LinusBorg

@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.

shameleo avatar Oct 11 '21 20:10 shameleo

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

haoqunjiang avatar Oct 12 '21 06:10 haoqunjiang

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.

kkuegler avatar Oct 31 '21 17:10 kkuegler

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

HelloHxz avatar Nov 23 '21 10:11 HelloHxz

~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.

shameleo avatar Dec 27 '21 11:12 shameleo