TypeError: mpa is not a function
I have no idea why mpa is an object containing default function rather than the function itself.

Obviously, using mpa.default() can apply the correct function, but it's definitely not what we want.
Here is my tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
This error happens for me too.
Same here
I fix this with mpa.default(), not mpa()
plugins: [
vue(),
mpa.default(),
],
mpa.default() 这样子确实可以跑通,但会报 TS 类型错误,如下图,

其实,只需要修改 /node_modules/vite-plugin-mpa/dist/index.js 源码导出模块的方式,不仅 TS 类型错误可以被解决,也可以正常以 mpa() 的形式使用,
-exports.default = mpa;
+module.exports = mpa;
修改完源码后,用 patch-package 打个补丁后,在 vite-plugin-mpa 修复前都不会有啥后顾之忧了。
@kifuan 是不是在package.json中使用了type: 'module'
@kifuan Did you use type: 'module' in package.json
Yes, I use.
But when I try to use path module in vite.config.ts, I've got an error, I can't use __dirname, and mpa()
I removed type: "module" from package.json, and fixed the error. Now I can use __dirname, path, and mpa()
But, I should fixed tsconfig
"moduleResolution": "bundler",
And install @types/node
Getting this error after updating to Vite 5 and after adding type=""module" in package.json as required in Vite 5 . Is there workaround this ?
mpa.default()这样子确实可以跑通,但会报 TS 类型错误,如下图,其实,只需要修改
/node_modules/vite-plugin-mpa/dist/index.js源码导出模块的方式,不仅 TS 类型错误可以被解决,也可以正常以mpa()的形式使用,-exports.default = mpa; +module.exports = mpa;修改完源码后,用 patch-package 打个补丁后,在 vite-plugin-mpa 修复前都不会有啥后顾之忧了。
令人遗憾,一年多了这个问题还没有被修复 😪