From 485ed4a1ace855b0219c29b8e442ddc4f3ebabb7 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Mon, 8 Jul 2024 15:17:47 +0800 Subject: [PATCH 1/3] chore: update ci action of pnpm (#6938) --- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/version.yml | 2 +- .github/workflows/website.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b0df192ed..cc91aa6007 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ - name: Install pnpm - uses: pnpm/action-setup@v2.2.2 + uses: pnpm/action-setup@v4 with: run_install: false - name: Get pnpm store directory diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 897bb367b4..6ed68113bf 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: node-version: [16.x] - + steps: - uses: actions/checkout@v3 with: @@ -42,7 +42,7 @@ jobs: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ - name: Install pnpm - uses: pnpm/action-setup@v2.2.2 + uses: pnpm/action-setup@v4 with: run_install: false - name: Get pnpm store directory diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65ea0364b1..9f2c7e8dc5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v3 - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index cd1c5c2ee3..dbd231c9b6 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v3 - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 9120fc1ecb..1c86fd4d55 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -19,7 +19,7 @@ jobs: fetch-depth: 0 - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 - name: Use Node.js 16.x uses: actions/setup-node@v3 From aaea501d8f2e54f6bf6a6116d948626bdd96379e Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Mon, 8 Jul 2024 19:29:54 +0800 Subject: [PATCH 2/3] fix: allow decorators-legacy syntax in js file (#6935) --- .changeset/early-tomatoes-beg.md | 5 +++++ packages/plugin-jsx-plus/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/early-tomatoes-beg.md diff --git a/.changeset/early-tomatoes-beg.md b/.changeset/early-tomatoes-beg.md new file mode 100644 index 0000000000..87c83716f2 --- /dev/null +++ b/.changeset/early-tomatoes-beg.md @@ -0,0 +1,5 @@ +--- +'@ice/plugin-jsx-plus': patch +--- + +fix: allow decorators-legacy syntax in js file diff --git a/packages/plugin-jsx-plus/src/index.ts b/packages/plugin-jsx-plus/src/index.ts index 735e7e3706..93ffe389fc 100644 --- a/packages/plugin-jsx-plus/src/index.ts +++ b/packages/plugin-jsx-plus/src/index.ts @@ -29,6 +29,7 @@ const babelTransformOptions = { 'topLevelAwait', 'classProperties', 'classPrivateMethods', + 'decorators-legacy', // allowing decorators by default ], generatorOpts: { decoratorsBeforeExport: true, @@ -107,7 +108,6 @@ const plugin: Plugin = (options: JSXPlusOptions = {}) => ({ if (/\.tsx?$/.test(id)) { // When routes file is a typescript file, add ts parser plugins. options.parserOpts.plugins.push('typescript'); - options.parserOpts.plugins.push('decorators-legacy'); // allowing decorators by default } const { code, map } = transformSync(source, options); From 7992d40579f2011a8e7b9ec9a7268458ba3ce72a Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Tue, 9 Jul 2024 11:37:59 +0800 Subject: [PATCH 3/3] Fix: throw error for better debugging (#6927) * fix: throw error for better debugging * chore: test --- .changeset/unlucky-boats-type.md | 5 +++++ packages/runtime/src/routes.tsx | 3 ++- packages/runtime/tests/routes.test.tsx | 25 ++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 .changeset/unlucky-boats-type.md diff --git a/.changeset/unlucky-boats-type.md b/.changeset/unlucky-boats-type.md new file mode 100644 index 0000000000..2d413f9a81 --- /dev/null +++ b/.changeset/unlucky-boats-type.md @@ -0,0 +1,5 @@ +--- +'@ice/runtime': patch +--- + +fix: throw error for better debugging diff --git a/packages/runtime/src/routes.tsx b/packages/runtime/src/routes.tsx index be0189c77a..fe95deb476 100644 --- a/packages/runtime/src/routes.tsx +++ b/packages/runtime/src/routes.tsx @@ -50,7 +50,8 @@ export async function loadRouteModule(route: RouteModule, routeModulesCache = {} return routeModule; } catch (error) { console.error(`Failed to load route module: ${id}.`); - console.error(error); + // Re-throw error for better debugging. + throw error; } } diff --git a/packages/runtime/tests/routes.test.tsx b/packages/runtime/tests/routes.test.tsx index e048d5a5ce..066360c16a 100644 --- a/packages/runtime/tests/routes.test.tsx +++ b/packages/runtime/tests/routes.test.tsx @@ -138,17 +138,20 @@ describe('routes', () => { }); it('load error module', async () => { - const routeModule = await loadRouteModules([{ - id: 'error', - // @ts-ignore - lazy: async () => { - throw new Error('err'); - return {}; - }, - }], {}); - expect(routeModule).toStrictEqual({ - error: undefined, - }); + // `toThrowError` seems not working with async function. + try { + await loadRouteModules([{ + id: 'error', + // @ts-ignore + lazy: async () => { + throw new Error('err'); + return {}; + }, + }], {}); + expect(true).toBe(false); + } catch (err) { + expect(true).toBe(true); + } }); it('load async route', async () => {