refactor(core): split web entry from core (#6082)

This pr is trying to split `web` and `electron` entries from `core`. It allows more platform-related optimization to be addressed in each entry.
We should remove all browser/electron only codes from `core` eventually, this is the very first step for that.
This commit is contained in:
LongYinan
2024-03-19 07:48:56 +00:00
parent 26925c96e4
commit 332cd3b380
54 changed files with 963 additions and 800 deletions

View File

@@ -266,8 +266,8 @@ jobs:
path: ./packages/backend/storage/storage.node
if-no-files-found: error
build-core:
name: Build @affine/core
build-web:
name: Build @affine/web
runs-on: ubuntu-latest
steps:
@@ -277,15 +277,15 @@ jobs:
with:
electron-install: false
full-cache: true
- name: Build Core
- name: Build Web
# always skip cache because its fast, and cache configuration is always changing
run: yarn nx build @affine/core --skip-nx-cache
- name: zip core
run: tar -czf dist.tar.gz --directory=packages/frontend/core/dist .
- name: Upload core artifact
run: yarn nx build @affine/web --skip-nx-cache
- name: zip web
run: tar -czf dist.tar.gz --directory=packages/frontend/web/dist .
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: core
name: web
path: dist.tar.gz
if-no-files-found: error
@@ -485,7 +485,7 @@ jobs:
test: true,
}
needs:
- build-core
- build-web
- build-native
steps:
- uses: actions/checkout@v4
@@ -516,8 +516,8 @@ jobs:
shell: bash
run: yarn workspace @affine/electron vitest
- name: Download core artifact
uses: ./.github/actions/download-core
- name: Download web artifact
uses: ./.github/actions/download-web
with:
path: packages/frontend/electron/resources/web-static

View File

@@ -38,8 +38,8 @@ jobs:
name: server-dist
path: ./packages/backend/server/dist
if-no-files-found: error
build-core:
name: Build @affine/core
build-web:
name: Build @affine/web
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.flavor }}
steps:
@@ -50,7 +50,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Build Core
run: yarn nx build @affine/core --skip-nx-cache
run: yarn nx build @affine/web --skip-nx-cache
env:
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
@@ -64,15 +64,15 @@ jobs:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
PERFSEE_TOKEN: ${{ secrets.PERFSEE_TOKEN }}
- name: Upload core artifact
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: core
path: ./packages/frontend/core/dist
name: web
path: ./packages/frontend/web/dist
if-no-files-found: error
build-core-selfhost:
name: Build @affine/core selfhost
build-web-selfhost:
name: Build @affine/web selfhost
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.flavor }}
steps:
@@ -83,7 +83,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Build Core
run: yarn nx build @affine/core --skip-nx-cache
run: yarn nx build @affine/web --skip-nx-cache
env:
BUILD_TYPE: ${{ github.event.inputs.flavor }}
SHOULD_REPORT_TRACE: false
@@ -91,11 +91,11 @@ jobs:
SELF_HOSTED: true
- name: Download selfhost fonts
run: node ./scripts/download-blocksuite-fonts.mjs
- name: Upload core artifact
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: selfhost-core
path: ./packages/frontend/core/dist
name: selfhost-web
path: ./packages/frontend/web/dist
if-no-files-found: error
build-storage:
@@ -143,16 +143,16 @@ jobs:
packages: 'write'
needs:
- build-server
- build-core
- build-core-selfhost
- build-web
- build-web-selfhost
- build-storage
steps:
- uses: actions/checkout@v4
- name: Download core artifact
uses: actions/download-artifact@v4
with:
name: core
path: ./packages/frontend/core/dist
name: web
path: ./packages/frontend/web/dist
- name: Download server dist
uses: actions/download-artifact@v4
with:
@@ -218,14 +218,14 @@ jobs:
registry-url: https://npm.pkg.github.com
scope: '@toeverything'
- name: Remove core dist
run: rm -rf ./packages/frontend/core/dist
- name: Remove web dist
run: rm -rf ./packages/frontend/web/dist
- name: Download selfhost core artifact
- name: Download selfhost web artifact
uses: actions/download-artifact@v4
with:
name: selfhost-core
path: ./packages/frontend/core/dist
name: selfhost-web
path: ./packages/frontend/web/dist
- name: Install Node.js dependencies
run: |

View File

@@ -60,10 +60,10 @@ jobs:
SKIP_PLUGIN_BUILD: 'true'
SKIP_NX_CACHE: 'true'
- name: Upload core artifact
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: core
name: web
path: packages/frontend/electron/resources/web-static
make-distribution:
@@ -110,7 +110,7 @@ jobs:
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: core
name: web
path: packages/frontend/electron/resources/web-static
- name: Build Desktop Layers
@@ -188,7 +188,7 @@ jobs:
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: core
name: web
path: packages/frontend/electron/resources/web-static
- name: Build Desktop Layers
@@ -317,7 +317,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: core
name: web
path: web-static
- name: Zip web-static
run: zip -r web-static.zip web-static