diff --git a/src/babelPluginTsdx.ts b/src/babelPluginTsdx.ts index 665731394..f6db78f7f 100644 --- a/src/babelPluginTsdx.ts +++ b/src/babelPluginTsdx.ts @@ -67,6 +67,7 @@ export const babelPluginTsdx = babelPlugin.custom(() => ({ // pragma: customOptions.jsx || 'h', // pragmaFrag: customOptions.jsxFragment || 'Fragment', // }, + { name: 'babel-plugin-macros' }, { name: 'babel-plugin-annotate-pure-calls' }, { name: 'babel-plugin-dev-expression' }, customOptions.format !== 'cjs' && { @@ -90,9 +91,6 @@ export const babelPluginTsdx = babelPlugin.custom(() => ({ name: '@babel/plugin-transform-regenerator', async: false, }, - { - name: 'babel-plugin-macros', - }, isTruthy(customOptions.extractErrors) && { name: './errors/transformErrorMessages', }, diff --git a/test/integration/fixtures/build-withBabel/.babelrc.js b/test/integration/fixtures/build-withBabel/.babelrc.js index 06ede96cd..a010a8d6b 100644 --- a/test/integration/fixtures/build-withBabel/.babelrc.js +++ b/test/integration/fixtures/build-withBabel/.babelrc.js @@ -4,7 +4,6 @@ module.exports = { './test-babel-preset' ], plugins: [ - 'styled-components', ['@babel/plugin-transform-runtime', { helpers: false }], ] } diff --git a/test/integration/fixtures/build-withBabel/src/styled.tsx b/test/integration/fixtures/build-withBabel/src/styled.tsx index 12ca9fe94..c0dcbc3b0 100644 --- a/test/integration/fixtures/build-withBabel/src/styled.tsx +++ b/test/integration/fixtures/build-withBabel/src/styled.tsx @@ -1,4 +1,4 @@ -import styled from 'styled-components'; +import styled from 'styled-components/macro'; export const Title = styled.h1` /* this comment should be removed */ diff --git a/test/integration/tsdx-build-withBabel.test.js b/test/integration/tsdx-build-withBabel.test.js index cb2b3b59c..a11fddbb2 100644 --- a/test/integration/tsdx-build-withBabel.test.js +++ b/test/integration/tsdx-build-withBabel.test.js @@ -19,19 +19,22 @@ describe('integration :: tsdx build :: .babelrc.js', () => { const output = execWithCache('node ../dist/index.js build'); expect(output.code).toBe(0); - // from styled.h1` to styled.h1( - const matched = grep(/styled.h1\(/, ['dist/build-withbabel.*.js']); + // from styled.h1` to styled.h1.withConfig( + const matched = grep(/styled.h1.withConfig\(/, [ + 'dist/build-withbabel.*.js', + ]); expect(matched).toBeTruthy(); }); - // TODO: make this test work by allowing customization of plugin order - it.skip('should remove comments in the CSS', () => { + // TODO: make this test work with the babel-plugin and not just the macro + // by allowing customization of plugin order + it('should remove comments in the CSS', () => { const output = execWithCache('node ../dist/index.js build'); expect(output.code).toBe(0); - // the "should be removed" comment shouldn't be there (gets error code) + // the comment "should be removed" should no longer be there const matched = grep(/should be removed/, ['dist/build-withbabel.*.js']); - expect(matched).toBeTruthy(); + expect(matched).toBeFalsy(); }); it('should add an import of regeneratorRuntime', () => {