Closed milleniumbug closed 2 years ago
Afaik this is supposed to just work, not entirely sure what's breaking here but it's probably something to do with paths stuff in whatever creates the BrowserWindow instance
Changing from
const fallbackResponse = await FileSystem.readFile("./lang/en-US.quilt", "utf8");
to
const fallbackResponse = await FileSystem.readFile("./resources/app.asar/lang/en-US.quilt", "utf8");
makes it work, but again, it's a hack.
One thing I've noticed is that this is the only "application internal" file we're trying to load with FileSystem.readFile
- everything else is either a.) user data read with FileSystem.readFile
which doesn't have any problem as we use absolute paths, b.) user config loaded/stored with whatever magic Electron is using, which is good enough as it stores the config in OS-specific user directory, c.) internal assets loaded "implicitly" with this:
mainWindow.loadURL("data:text/html;charset=UTF-8," + encodeURIComponent(`
<link rel="stylesheet" href="style/index.css">
<script>
const { webFrame } = require("electron");
webFrame.setVisualZoomLevelLimits(1, 1);
webFrame.setLayoutZoomLevelLimits(0, 0);
window.Stream = require("@wayward/goodstream").default;
require("@wayward/goodstream/apply");
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
</script>
<script src="script/vendor/require.js"></script>
<script>
requirejs(["script/init/Decorator.js"], () => {
requirejs(["script/index.js"]);
});
</script>
`), { baseURLForDataURL: `chiri://${__dirname}/out`, extraHeaders: "pragma: no-cache\n" });
The __dirname
part I can log easily and see what it is, but I have completely no idea what is going on with that /out
- There is no directory at chiri://${__dirname}/out
, and yet, it works.
Is this still broken btw? This might have been fixed recently
I think it still is, gonna check out after work.
npx gulp build
is how I try running it btw.
Building from scratch on Windows (so to eliminate of possibility of Linux-specific problems you don't have)
Your environment has been set up for using Node.js 16.15.1 (x64) and npm.
I made an experiment on how I can modify the content of win-unpacked
so it runs. So basically, two things:
lang
in the directory to the root directory, together with locales
and resources
app.asar
to a directory, removing app.asar
and renaming the new directory to app.asar
, and then copying node_modules
from out
directory, which seems to be missing in the dist
.Conclusion: the problem still appears, in addition to a new one.
Try now (on linux, I can confirm it works on windows)
Can confirm that I can build a Windows executable from Linux, so that's good.
Packaging seems to put all the scripts, resources inside
resources/app.asar
, but insideLanguage.ts
we're manually opening a file, resulting in "File not found" errors, and the application showing a blank screen.One workaround is manually copying the
lang
directory to the target, but this is ugly, adds a manual step, and doesn't work well with other targets than"dir"