diff --git a/tests/integration/swc/fixtures/decorator/new/modern.config.ts b/tests/integration/swc/fixtures/decorator/new/modern.config.ts index 3b4896c36640..2bbd294588b9 100644 --- a/tests/integration/swc/fixtures/decorator/new/modern.config.ts +++ b/tests/integration/swc/fixtures/decorator/new/modern.config.ts @@ -2,14 +2,9 @@ import appTools, { defineConfig } from '@modern-js/app-tools'; import { swcPlugin } from '@modern-js/plugin-swc'; export default defineConfig({ - tools: { - swc: { - jsc: { - transform: { - /** use new decorator */ - legacyDecorator: false, - }, - }, + source: { + decorators: { + version: '2022-03', }, }, output: { diff --git a/tests/integration/swc/fixtures/decorator/new/src/index.js b/tests/integration/swc/fixtures/decorator/new/src/index.js index 7589b8ffefdb..651b9e807c18 100644 --- a/tests/integration/swc/fixtures/decorator/new/src/index.js +++ b/tests/integration/swc/fixtures/decorator/new/src/index.js @@ -1,9 +1,10 @@ -function newDecorator() { +function newDecorator(value) { console.log('foo decorator'); + return value; } class Foo { - @newDecorator() + @newDecorator foo() { console.log('foo'); } diff --git a/tests/integration/swc/tests/decorator.test.ts b/tests/integration/swc/tests/decorator.test.ts index 24251ad87818..c9411ab253b3 100644 --- a/tests/integration/swc/tests/decorator.test.ts +++ b/tests/integration/swc/tests/decorator.test.ts @@ -6,7 +6,7 @@ const fixtures = path.resolve(__dirname, '../fixtures'); const getJsFiles = (appDir: string) => readdirSync(path.resolve(appDir, 'dist/static/js')) - .filter(filepath => /\.js$/.test(filepath)) + .filter(filepath => /\.js.map$/.test(filepath)) .map(filePath => readFileSync(path.join(appDir, 'dist/static/js', filePath)), ); @@ -19,7 +19,9 @@ describe('swc use new decorator', () => { const jsFiles = getJsFiles(appDir); expect( - jsFiles.some(item => item.includes('@swc/helpers/esm/_decorate.js')), + jsFiles.some(item => + item.includes('@swc/helpers/esm/_apply_decs_2203_r.js'), + ), ).toBeTruthy(); });