Skip to content

Commit f079d05

Browse files
feat(swc-angular): ✨ require @swc/core@~1.13.0
This also fixes broken transform when using constructor DI. Fixes #304 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Younes Jaaidi <[email protected]>
1 parent 1941e0c commit f079d05

File tree

7 files changed

+367
-230
lines changed

7 files changed

+367
-230
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383
"@playwright/experimental-ct-core": "1.50.1",
8484
"@playwright/test": "1.50.1",
8585
"@schematics/angular": "19.2.15",
86-
"@swc-node/register": "1.10.9",
87-
"@swc/core": "1.10.18",
88-
"@swc/helpers": "0.5.15",
89-
"@swc/jest": "0.2.37",
86+
"@swc-node/register": "1.11.1",
87+
"@swc/core": "1.13.5",
88+
"@swc/helpers": "0.5.17",
89+
"@swc/jest": "0.2.39",
9090
"@types/babel__core": "^7.20.5",
9191
"@types/jest": "29.5.14",
9292
"@types/node": "^22.10.1",

packages/swc-angular/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ function assertCompatibleSwcCoreVersion(version: string) {
103103
}>(packageJsonPath).version;
104104
}
105105

106-
if (!version.startsWith('1.10.')) {
106+
if (!version.startsWith('1.13.')) {
107107
console.error(`
108108
@swc/core version ${version} is incompatible with @jscutlery/swc-angular.
109-
Please use @swc/core version 1.10.x
110-
> npm add -D @swc/core@~1.10.0
109+
Please use @swc/core version 1.13.x
110+
> npm add -D @swc/core@~1.13.0
111111
`);
112112
process.exit(1);
113113
}

packages/swc-angular/src/version-guard.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { join } from 'node:path';
1313
*/
1414

1515
test.each([
16-
[' <1.10.0', { version: '1.9.3' }],
17-
['>=1.11.0', { version: '1.11.0' }],
16+
[' <1.13.0', { version: '1.12.0' }],
17+
['>=1.14.0', { version: '1.14.0' }],
1818
])(
1919
'should throw an error when module is imported and version is %s',
2020
async (_, { version }) => {
@@ -37,8 +37,8 @@ test.each([
3737
},
3838
);
3939

40-
test.each(['1.10.0', '1.10.7'])(
41-
'should not throw an error when module is imported and version is ~1.10.0',
40+
test.each(['1.13.0', '1.13.7'])(
41+
'should not throw an error when module is imported and version is ~1.13.0',
4242
async (version) => {
4343
setUp();
4444

@@ -60,7 +60,7 @@ test('should fallback to package.json if version is not available (this happens
6060
version: undefined,
6161
}));
6262
fileSystem.setJsonFile('node_modules/@swc/core/package.json', {
63-
version: '1.10.7',
63+
version: '1.13.0',
6464
});
6565

6666
await import('./index');
@@ -69,7 +69,7 @@ test('should fallback to package.json if version is not available (this happens
6969
expect(process.exit).not.toHaveBeenCalledOnce();
7070
});
7171

72-
test.each(['1.9.3', '1.11.0'])(
72+
test.each(['1.12.0', '1.14.0'])(
7373
'should throw an error if version from package.json is not compatible',
7474
async (version) => {
7575
const { fileSystem } = setUp();

tests/playwright-ct-angular-demo/src/recipe-search.component.pw.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ import {
66
import { RecipeSearchTestContainer } from './recipe-search.test-container';
77

88
test.describe('<wm-recipe-search>', () => {
9-
test('should search recipes without keyword on load', async ({ mount }) => {
10-
const { recipeTitleLocator, verifyScreenshot } =
11-
await renderSearchComponent({ mount });
9+
test('should search recipes without keyword on load', async ({
10+
page,
11+
mount,
12+
}) => {
13+
const { recipeTitleLocator } = await renderSearchComponent({ mount });
1214

1315
await expect(recipeTitleLocator).toHaveText(['Beer', 'Burger']);
1416

15-
await verifyScreenshot('all recipes');
17+
/* Prefer using whole page screenshot for two reasons:
18+
* 1. it's the same resolution and the Playwright reporter diff will show slider.
19+
* 2. we make sure that there's no extra overlay in the DOM (e.g. dialog). */
20+
await expect(page).toHaveScreenshot(`all recipes.png`, {
21+
maxDiffPixelRatio: 0.3,
22+
});
1623
});
1724

1825
test('should search recipes using given filter', async ({ mount }) => {
@@ -35,24 +42,6 @@ test.describe('<wm-recipe-search>', () => {
3542
async updateFilter({ keywords }: { keywords: string }) {
3643
await locator.getByLabel('Keywords').fill(keywords);
3744
},
38-
async verifyScreenshot(name: string) {
39-
/* Wait for images to load. */
40-
await locator.page().waitForFunction(() => {
41-
const images = Array.from(document.querySelectorAll('img'));
42-
return images.every(img => img.complete);
43-
});
44-
45-
/* For some reason, Firefox reaches here while all images didn't load yet.
46-
* Keep trying until it succeeds. */
47-
await expect(async () => {
48-
/* Prefer using whole page screenshot for two reasons:
49-
* 1. it's the same resolution and the Playwright reporter diff will show slider.
50-
* 2. we make sure that there's no extra overlay in the DOM (e.g. dialog). */
51-
await expect(locator.page()).toHaveScreenshot(`${name}.png`, {
52-
maxDiffPixelRatio: 0.3,
53-
});
54-
}).toPass();
55-
},
5645
};
5746
}
5847
});

tests/swc-angular-wide/src/swc-plugin-angular-input.spec.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,30 @@ describe('swc-angular-plugin: input', () => {
9696
expect(heading).toBe('Hello required input alias!');
9797
});
9898

99-
/* Cf. https://github.com/jscutlery/devkit/issues/304 */
100-
it.fails(
101-
'🐞 should bind inputs even when property is assigned using constructor injection',
102-
() => {
103-
@Component({
104-
standalone: true,
105-
selector: 'jsc-title',
106-
template: ` <h1>Hello {{ title() }}!</h1> `,
107-
})
108-
class Title {
109-
title = input<string>();
110-
111-
constructor(private _service: Service) {}
112-
}
113-
114-
@Component({
115-
standalone: true,
116-
imports: [Title],
117-
template: ` <jsc-title [title]="title" /> `,
118-
})
119-
class Container {
120-
title = 'input';
121-
}
122-
123-
const { heading } = render(Container);
124-
expect(heading).toBe('Hello input!');
125-
},
126-
);
99+
it('should bind inputs even when property is assigned using constructor injection', () => {
100+
@Component({
101+
standalone: true,
102+
selector: 'jsc-title',
103+
template: ` <h1>Hello {{ title() }}!</h1> `,
104+
})
105+
class Title {
106+
title = input<string>();
107+
108+
constructor(private _service: Service) {}
109+
}
110+
111+
@Component({
112+
standalone: true,
113+
imports: [Title],
114+
template: ` <jsc-title [title]="title" /> `,
115+
})
116+
class Container {
117+
title = 'input';
118+
}
119+
120+
const { heading } = render(Container);
121+
expect(heading).toBe('Hello input!');
122+
});
127123

128124
function render(cmpType: Type<unknown>) {
129125
const { nativeElement } = createComponent(cmpType);
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
2-
globalThis.ngJest = {
3-
testEnvironmentOptions: {
4-
errorOnUnknownElements: true,
5-
errorOnUnknownProperties: true,
6-
},
7-
};
81
import 'reflect-metadata';
92
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
103
import { it } from '@jest/globals';
114

125
(globalThis as any).it.fails = it.failing;
13-
setupZoneTestEnv();
6+
setupZoneTestEnv({
7+
errorOnUnknownElements: true,
8+
errorOnUnknownProperties: true,
9+
});

0 commit comments

Comments
 (0)