Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

build: fix arm64 mac build (#1704)

Peng Xiaodc768e0ba9c5
diff --git a/.github/workflows/client-app.yml b/.github/workflows/client-app.yml
index 278e0be421..b3cfe98332 100644
--- a/.github/workflows/client-app.yml
+++ b/.github/workflows/client-app.yml
@@ -139,7 +139,7 @@ jobs:
path: apps/electron/dist
- name: build octobase-node
- run: yarn build:octobase-node
+ run: yarn build:octobase-node --target=aarch64-apple-darwin
working-directory: apps/electron
- name: move octobase Binary
diff --git a/apps/electron/scripts/common.mjs b/apps/electron/scripts/common.mjs
index 408588561f..c46b1fc363 100644
--- a/apps/electron/scripts/common.mjs
+++ b/apps/electron/scripts/common.mjs
@@ -10,6 +10,16 @@ const { node } = JSON.parse(
)
);
+const nativeNodeModulesPlugin = {
+ name: 'native-node-modules',
+ setup(build) {
+ // Mark native Node.js modules as external
+ build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => {
+ return { path: args.path, external: true };
+ });
+ },
+};
+
/** @type {import('esbuild').BuildOptions} */
export const mainConfig = {
entryPoints: ['layers/main/src/index.ts'],
@@ -18,6 +28,7 @@ export const mainConfig = {
target: `node${node}`,
platform: 'node',
external: ['electron'],
+ plugins: [nativeNodeModulesPlugin],
};
export const preloadConfig = {
diff --git a/apps/electron/scripts/dev.mjs b/apps/electron/scripts/dev.mjs
index 11ddd07b5e..0885d8e682 100644
--- a/apps/electron/scripts/dev.mjs
+++ b/apps/electron/scripts/dev.mjs
@@ -54,6 +54,7 @@ async function main() {
const preloadBuild = await esbuild.context({
...preloadConfig,
plugins: [
+ ...(preloadConfig.plugins ?? []),
{
name: 'affine-dev:reload-app-on-preload-change',
setup(build) {
@@ -86,6 +87,7 @@ async function main() {
'process.env.DEV_SERVER_URL': `"${process.env.DEV_SERVER_URL}"`,
},
plugins: [
+ ...(mainConfig.plugins ?? []),
{
name: 'affine-dev:reload-app-on-main-change',
setup(build) {