Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/core/src/utils/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ export function transformSyntaxToRspackTarget(
) {
return 'es2022';
}

// The es6 is the same as es2015, compatible with rspack API schema
if (normalizedSyntaxItem === 'es6') {
return 'es2015';
}
return normalizedSyntaxItem;
}

Expand Down
16 changes: 16 additions & 0 deletions packages/core/tests/syntax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,20 @@ describe('transformSyntaxToBrowserslist', () => {

describe('transformSyntaxToRspackTarget', () => {
test('esX', () => {
const es6 = transformSyntaxToRspackTarget('es6');
const es2023 = transformSyntaxToRspackTarget('es2023');
const es2024 = transformSyntaxToRspackTarget('es2024');
const esnext = transformSyntaxToRspackTarget('esnext');

expect(es2023).toEqual(es2024);
expect(es2023).toEqual(esnext);

expect(es6).toMatchInlineSnapshot(`
[
"es2015",
]
`);

expect(es2023).toMatchInlineSnapshot(
`
[
Expand All @@ -186,5 +193,14 @@ describe('transformSyntaxToRspackTarget', () => {
"es2022",
]
`);

expect(
transformSyntaxToRspackTarget(['Chrome 123', 'es6']),
).toMatchInlineSnapshot(`
[
"browserslist:Chrome 123",
"es2015",
]
`);
});
});
Loading