Closed zq0904 closed 2 years ago
// vite.config.ts
import dynamicImport from 'vite-plugin-dynamic-import'
plugins: [
// @ts-expect-error
- dynamicImport.default(), // Does not match the document, and the TS prompt is incorrect
+ dynamicImport(),
]
// vite.config.ts
const dynamicImport = require('vite-plugin-dynamic-import').default;
plugins: [
dynamicImport(),
]
ESM 导入
// vite.config.ts import dynamicImport from 'vite-plugin-dynamic-import' plugins: [ // @ts-expect-error - dynamicImport.default(), // Does not match the document, and the TS prompt is incorrect + dynamicImport(), ]
CJS 要求
// vite.config.ts const dynamicImport = require('vite-plugin-dynamic-import').default; plugins: [ dynamicImport(), ]
An error is reported when esm is introduced in this version // package.json "Vite" : "^ 3.0.0", "Vite - plugin - dynamic - import" : "^ 1.0.0",
dynamicImport is not a function
That's why I had to use it // @ts-expect-error dynamicImport.default(),
I don't know. Possible cause?