Skip to content

Commit

Permalink
fix: handle esm config syntax error in Node 12
Browse files Browse the repository at this point in the history
close #1635
  • Loading branch information
yyx990803 committed Jan 22, 2021
1 parent 037e1e5 commit 20cf718
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vite/src/node/config.ts
Expand Up @@ -457,7 +457,14 @@ export async function loadConfigFromFile(
userConfig = require(resolvedPath)
debug(`cjs config loaded in ${Date.now() - start}ms`)
} catch (e) {
const ignored = /Cannot use import statement|Unexpected token 'export'|Must use import to load ES Module/
const ignored = new RegExp(
[
`Cannot use import statement`,
`Unexpected token 'export'`,
`Must use import to load ES Module`,
`Unexpected identifier` // #1635 Node <= 12.4 has no esm detection
].join('|')
)
if (!ignored.test(e.message)) {
throw e
}
Expand Down

0 comments on commit 20cf718

Please sign in to comment.