Skip to content

Commit

Permalink
Temporarily use @inigolabs/ffi-napi to deal with v8 issues introduced…
Browse files Browse the repository at this point in the history
… in Electron 21

When ffi-napi is fixed, we can revert this change.

Signed-off-by: Eric Promislow <[email protected]>
  • Loading branch information
ericpromislow committed Jan 3, 2023
1 parent 74f2c5f commit cd176d5
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 6 deletions.
93 changes: 87 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"dompurify": "^2.3.10",
"electron-updater": "^5.2.1",
"express": "^4.18.1",
"@inigolabs/ffi-napi": "^4.0.10",
"ffi-napi": "^4.0.3",
"fs-extra": "^11.1.0",
"http-proxy-agent": "^5.0.0",
Expand Down
14 changes: 14 additions & 0 deletions scripts/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ function downloadDependencies(context: DownloadContext, dependencies: Dependency
);
}

// TODO: Remove this function once an ffi-napi module is released that fixes
// https://github.com/nodejs/abi-stable-node/issues/441
// Until then we're using `@inigolabs/ffi-napi` to work around it.
function installPatchedFFISync(): void {
for (const dir of ['ffi-napi', 'ref-napi']) {
const src = path.join('node_modules', '@inigolabs', dir);
const dst = path.join('node_modules', dir);

fs.rmSync(dst, { force: true, recursive: true });
fs.cpSync(src, dst, { force: true, recursive: true });
}
}

async function runScripts(): Promise<void> {
// load desired versions of dependencies
const depVersions = await readDependencyVersions(path.join('pkg', 'rancher-desktop', 'assets', 'dependencies.yaml'));
Expand Down Expand Up @@ -111,6 +124,7 @@ function buildDownloadContextFor(rawPlatform: DependencyPlatform, depVersions: D

runScripts().then(() => {
execFileSync('node', ['node_modules/electron-builder/out/cli/cli.js', 'install-app-deps'], { stdio: 'inherit' });
installPatchedFFISync();
})
.catch((e) => {
console.error(e);
Expand Down

0 comments on commit cd176d5

Please sign in to comment.