Skip to content

Commit

Permalink
Merge branch 'release/next' into fix/suspense-request
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Jul 9, 2024
2 parents f1d4ba5 + 7992d40 commit 4a46a12
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-tomatoes-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/plugin-jsx-plus': patch
---

fix: allow decorators-legacy syntax in js file
5 changes: 5 additions & 0 deletions .changeset/unlucky-boats-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---

fix: throw error for better debugging
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-jsx-plus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const babelTransformOptions = {
'topLevelAwait',
'classProperties',
'classPrivateMethods',
'decorators-legacy', // allowing decorators by default
],
generatorOpts: {
decoratorsBeforeExport: true,
Expand Down Expand Up @@ -107,7 +108,6 @@ const plugin: Plugin<JSXPlusOptions> = (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);
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
25 changes: 14 additions & 11 deletions packages/runtime/tests/routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 4a46a12

Please sign in to comment.