You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// For invalid named exports only, similar to how Node.js errors for top-level imports.
41
+
// But since we transform as dynamic imports, we need to emulate the error manually.
42
+
if(moduleType==='module'){
43
+
thrownewSyntaxError(
44
+
`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`,
45
+
)
46
+
}else{
47
+
// For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
48
+
// Copied from Node.js
49
+
thrownewSyntaxError(`\
42
50
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
43
51
CommonJS modules can always be imported via the default export, for example using:
44
52
45
53
import pkg from '${rawId}';
46
54
const {${missingBindings.join(', ')}} = pkg;
47
55
`)
56
+
}
48
57
}
49
58
}
50
59
}
51
-
52
-
/**
53
-
* Guard invalid named exports only, similar to how Node.js errors for top-level imports.
54
-
* But since we transform as dynamic imports, we need to emulate the error manually.
55
-
*/
56
-
exportfunctionproxyGuardOnlyEsm(
57
-
mod: any,
58
-
rawId: string,
59
-
metadata?: SSRImportBaseMetadata,
60
-
): any{
61
-
// If the module doesn't import anything explicitly, e.g. `import 'foo'` or
62
-
// `import * as foo from 'foo'`, we can skip the proxy guard.
63
-
if(!metadata?.importedNames?.length)returnmod
64
-
65
-
returnnewProxy(mod,{
66
-
get(mod,prop){
67
-
if(prop!=='then'&&!(propinmod)){
68
-
thrownewSyntaxError(
69
-
`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`,
0 commit comments