mirror of
https://github.com/LukeHagar/electron-vite.git
synced 2025-12-09 12:27:43 +00:00
feat: config file supports "type": "module" in package.json
This commit is contained in:
11
src/utils.ts
11
src/utils.ts
@@ -73,3 +73,14 @@ export function loadPackageData(root = process.cwd()): PackageData | null {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function isFilePathESM(filePath: string): boolean {
|
||||
if (/\.m[jt]s$/.test(filePath) || filePath.endsWith('.ts')) {
|
||||
return true
|
||||
} else if (/\.c[jt]s$/.test(filePath)) {
|
||||
return false
|
||||
} else {
|
||||
const pkg = loadPackageData()
|
||||
return pkg?.type === 'module'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user