electron **功能请求** :支持在asar归档文件中导入

66bbxpm5  于 2个月前  发布在  Electron
关注(0)|答案(3)|浏览(43)

预检清单

问题描述

我正在尝试将 next.js 应用打包到 electron 中。在加载运行时配置时出现了错误

。我使用 asar 打包构建了 electron 二进制文件。"Require" 在绝对路径下工作正常,但 "import" 不行。
抱怨的代码链接:https://github.com/vercel/next.js/blob/67853aa8cdc649cc35a6b7efc033bf262ff4ba87/packages/next/src/server/config.ts#L734

建议的解决方案

支持 electron node bindings 中的 "import"。

考虑过的替代方案

  • 对 next.js 的 load config 进行猴子补丁 --> 代码库中有太多 "import" 调用。你永远无法完成
  • 使用webpack和babel进行转换 --> 从理论上讲可行。但是 node_modules 中有太多需要转换的模块,需要大量的路径hacking
  • 解压 asar --> 需要手动更改所有从 'app.asar' 到 'app.asar.unpacked' 的 require 路径,而且它毫无必要地简单,我从未使其正常工作过。

其他信息

  • 没有回复
apeeds0o

apeeds0o1#

这已经在进行中,将由 #37535 关闭。

lzfw57am

lzfw57am2#

@addlistener Can you please help me packing the Next.JS app into Electron? actually I'm searching for it since many weeks but could not find any solution. Would appreciate guidance on this.

e0bqpujr

e0bqpujr3#

@addlistener Can you please help me packing the Next.JS app into Electron? actually I'm searching for it since many weeks but could not find any solution. Would appreciate guidance on this.
If you are trying to run next.js server in electron. Honestly I never made it work. I listed the reasons in the OP. Unless electron natively supports "import"
I guess one thing you could try is do not pack the source code at all.

相关问题