Skip to content

Commit ee391e4

Browse files
committed
(test): ensure Babel presets are merged and applied
- regression test as there was previously a bug where only plugins were merged and presets would only be merged if your preset list included preset-env - this is the first test that adds any sort of preset - couldn't find a small preset that would be easy to test against, so made a tiny one locally that just does a simple replace with babel-plugin-replace-identifiers
1 parent 9f559fa commit ee391e4

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"@types/semver": "^7.1.0",
114114
"@types/styled-components": "^5.0.1",
115115
"autoprefixer": "^9.7.4",
116+
"babel-plugin-replace-identifiers": "^0.1.1",
116117
"cssnano": "^4.1.10",
117118
"doctoc": "^1.4.0",
118119
"husky": "^4.2.2",

test/integration/fixtures/build-withBabel/.babelrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module.exports = {
2+
presets: [
3+
// ensure Babel presets are merged and applied
4+
'./test-babel-preset'
5+
],
26
plugins: [
37
'styled-components',
48
['@babel/plugin-transform-runtime', { helpers: false }],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// a simple babel preset to ensure presets are merged and applied
2+
module.exports = () => ({
3+
plugins: [['replace-identifiers', { sum: 'replacedSum' }]],
4+
});

test/integration/tsdx-build-withBabel.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe('integration :: tsdx build :: .babelrc.js', () => {
4444
expect(matched).toBeTruthy();
4545
});
4646

47+
it('should merge and apply presets', () => {
48+
const output = execWithCache('node ../dist/index.js build');
49+
expect(output.code).toBe(0);
50+
51+
// ensures replace-identifiers was used
52+
const matched = grep(/replacedSum/, ['dist/build-withbabel.*.js']);
53+
expect(matched).toBeTruthy();
54+
});
55+
4756
it('should compile files into a dist directory', () => {
4857
const output = execWithCache('node ../dist/index.js build');
4958

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ babel-plugin-macros@^2.6.1:
18381838
cosmiconfig "^6.0.0"
18391839
resolve "^1.12.0"
18401840

1841+
babel-plugin-replace-identifiers@^0.1.1:
1842+
version "0.1.1"
1843+
resolved "https://registry.yarnpkg.com/babel-plugin-replace-identifiers/-/babel-plugin-replace-identifiers-0.1.1.tgz#38819617d814ab0e4b35cfa373e40758b359f68f"
1844+
integrity sha1-OIGWF9gUqw5LNc+jc+QHWLNZ9o8=
1845+
18411846
"babel-plugin-styled-components@>= 1":
18421847
version "1.10.7"
18431848
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.10.7.tgz#3494e77914e9989b33cc2d7b3b29527a949d635c"

0 commit comments

Comments
 (0)