update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
40
electron/node_modules/app-builder-lib/helpers/dynamic-import.js
generated
vendored
Normal file
40
electron/node_modules/app-builder-lib/helpers/dynamic-import.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const url = require("url")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
// Resolve a module specifier to a file:// URL using CJS resolution, which
|
||||
// adds .js extensions automatically and follows pnpm's symlinked node_modules.
|
||||
// Returns null for Node built-ins (require.resolve returns a bare string, not
|
||||
// an absolute path) and for any specifier that cannot be resolved, so callers
|
||||
// fall back to importing the raw specifier and get the normal error.
|
||||
function resolveToFileUrl(modulePath) {
|
||||
try {
|
||||
const resolved = require.resolve(modulePath)
|
||||
// Built-in modules (e.g. "fs", "path") resolve to their bare name, not a
|
||||
// filesystem path. Passing a bare name to pathToFileURL produces a bogus URL.
|
||||
return path.isAbsolute(resolved) ? url.pathToFileURL(resolved).href : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
exports.dynamicImport = async function dynamicImport(modulePath) {
|
||||
if (fs.existsSync(modulePath)) {
|
||||
return import(url.pathToFileURL(modulePath).href)
|
||||
}
|
||||
const fileUrl = resolveToFileUrl(modulePath)
|
||||
return import(fileUrl !== null ? fileUrl : modulePath)
|
||||
}
|
||||
|
||||
exports.dynamicImportMaybe = async function dynamicImportMaybe(modulePath) {
|
||||
try {
|
||||
return require(modulePath)
|
||||
} catch (e1) {
|
||||
try {
|
||||
return await exports.dynamicImport(modulePath)
|
||||
} catch (e2) {
|
||||
e1.message = "\n1. " + e1.message + "\n2. " + e2.message
|
||||
throw e1
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue