better const named

This commit is contained in:
草鞋没号 2022-01-24 10:01:33 +08:00
parent 1c175360cf
commit bc1865042d

View File

@ -92,11 +92,11 @@ export function resolveElectron(dict: Parameters<typeof resolve>[0] = {}): Plugi
function builtinModulesExport(modules: string[]) { function builtinModulesExport(modules: string[]) {
return modules.map((moduleId) => { return modules.map((moduleId) => {
const nodeModule = require(moduleId) const nodeModule = require(moduleId)
const requireTpl = `const __builtinModule = require("${moduleId}");` const requireModule = `const __builtinModule = require("${moduleId}");`
const exportDefault = `export default __builtinModule` const exportDefault = `export default __builtinModule`
const exportMembers = Object.keys(nodeModule).map(attr => `export const ${attr} = __builtinModule.${attr}`).join(';\n') + ';' const exportMembers = Object.keys(nodeModule).map(attr => `export const ${attr} = __builtinModule.${attr}`).join(';\n') + ';'
const nodeModuleCode = ` const nodeModuleCode = `
${requireTpl} ${requireModule}
${exportDefault} ${exportDefault}