使用 Vue CLI 插件 Electron Builder 构建电子应用程序(初始化前无法访问 'fa')- TypeORM 协会 ManyToOne

building electron app with Vue CLI Plugin Electron Builder (cannot access 'fa' before initialization) - TypeORM association ManyToOne

我有一个 electron 应用程序项目,运行 在 webpack 开发服务器和 vue-cli-service 的开发模式下完美运行。

现在我想打包我的应用程序以进行生产分发。

为此,我使用 Vue CLI 插件 Electron Builder 库并启动此命令:

  "electron:build": "vue-cli-service electron:build"

一切似乎都很好。没有错误或中断过程。但是当我启动我的新应用程序安装时,我在启动时遇到这样的错误:

     A JavaScript error occurred in the main process

    Uncaught Exception:
    ReferenceError: Cannot access 'fa' before initialization
    at Module.<anonymous> (/Applications/electrony.app/Contents/Resources/app.asar/background.js:2:1550520)
    at n (/Applications/electrony.app/Contents/Resources/app.asar/background.js:2:110)
    at Object.<anonymous> (/Applications/electrony.app/Contents/Resources/app.asar/background.js:2:110880)
    at n (/Applications/electrony.app/Contents/Resources/app.asar/background.js:2:110)
    at /Applications/electrony.app/Contents/Resources/app.asar/background.js:2:902
    at Object.<anonymous> (/Applications/electrony.app/Contents/Resources/app.asar/background.js:2:913)
    at Module._compile (internal/modules/cjs/loader.js:967:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Module._load (internal/modules/cjs/loader.js:727:14)

如果检查 background.js 文件,我可以看到:

S([Object(z.ManyToOne)(()=>fa,a=>a.association,{nullable:!0,cascade:["insert","update"],eager:!0}),x("design:type","function"==typeof(b=void 0!==fa&&fa)?b:Object)]

好像是处理TypeORM实体关联ManyToOne声明。但我不明白 'fa' 是什么,因为该实体文件中不存在任何 'fa' 库或对象的声明。

你已经用 TypeORM 库打包了 electron 应用程序了吗?

我通过更改 tsconfig.json 文件解决了我的问题

来自这个:

  "lib": ["es5", "es6", "dom"],
  "module": "esnext",
  "target": "es6",
  "moduleResolution": "node",
  "noImplicitAny": true,
  "removeComments": true,
  "preserveConstEnums": true,
  "sourceMap": true,
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true,
  "esModuleInterop": true,

对此:

  "lib": ["es5", "es6", "dom"],
  "module": "commonjs",
  "target": "esnext",
  "types": ["node", "jest"]
  "moduleResolution": "node",
  "noImplicitAny": true,
  "removeComments": true,
  "preserveConstEnums": true,
  "sourceMap": true,
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true,
  "esModuleInterop": true,

现在生成的文件实体没有循环声明问题了。