From e08b59d8bb04edf2f3eea95b859f8d93e6837f0f Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Thu, 12 Dec 2019 18:31:57 +0100 Subject: [PATCH] Include decorator and class field plugins after TypeScript, if present --- index.js | 6 +++--- node-tests/addon-test.js | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 6010ab74..68e05ab5 100644 --- a/index.js +++ b/index.js @@ -340,7 +340,8 @@ module.exports = { plugins, [require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }], { - before: ['@babel/plugin-proposal-class-properties', '@babel/plugin-transform-typescript'] + before: ['@babel/plugin-proposal-class-properties'], + after: ['@babel/plugin-transform-typescript'] } ); } @@ -357,8 +358,7 @@ module.exports = { plugins, [require.resolve('@babel/plugin-proposal-class-properties'), { loose: options.loose || false }], { - after: ['@babel/plugin-proposal-decorators'], - before: ['@babel/plugin-transform-typescript'] + after: ['@babel/plugin-proposal-decorators', '@babel/plugin-transform-typescript'] } ); } diff --git a/node-tests/addon-test.js b/node-tests/addon-test.js index b4429b48..8265e81b 100644 --- a/node-tests/addon-test.js +++ b/node-tests/addon-test.js @@ -792,6 +792,12 @@ describe('ember-cli-babel', function() { expect(loosePlugins[1][1].loose).to.equal(true, 'loose setting added correctly'); }); + + it('should include class fields and decorators after typescript if detected', function() { + let plugins = this.addon._addDecoratorPlugins(['@babel/plugin-transform-typescript'], {}); + expect(plugins[0]).to.equal('@babel/plugin-transform-typescript', 'typescript still first'); + expect(plugins.length).to.equal(3, 'class fields and decorators added'); + }); }); describe('_shouldIncludeHelpers()', function() {