-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(test): ensure styled-components works with TSDX
- well, babel-plugin-styled-components fails... but we have a TODO to make it work at least! - ensure styled template tags get converted to regular functions - add a build-withBabel fixture (deps): add styled-components - and it has peerDeps on react-dom and react-is - add @types/styled-components for TS usage
- Loading branch information
Showing
15 changed files
with
351 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
plugins: [ | ||
'styled-components' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"scripts": { | ||
"build": "tsdx build" | ||
}, | ||
"name": "build-withbabel", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { Title } from './styled'; | ||
|
||
export const sum = (a: number, b: number) => { | ||
if ('development' === process.env.NODE_ENV) { | ||
console.log('fuck'); | ||
} | ||
return a + b; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Title = styled.h1` | ||
/* this comment should be removed */ | ||
font-size: 1.5em; | ||
text-align: center; | ||
color: palevioletred; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"lib": ["dom", "esnext"], | ||
"declaration": true, | ||
"sourceMap": true, | ||
"rootDir": "./src", | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"strictPropertyInitialization": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "./", | ||
"paths": { | ||
"*": ["src/*", "node_modules/*"] | ||
}, | ||
"jsx": "react", | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src", "types"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const shell = require('shelljs'); | ||
|
||
const util = require('../util'); | ||
|
||
shell.config.silent = false; | ||
|
||
const testDir = 'integration'; | ||
const fixtureName = 'build-withBabel'; | ||
const stageName = `stage-integration-${fixtureName}`; | ||
|
||
describe('integration :: tsdx build :: .babelrc.js', () => { | ||
beforeAll(() => { | ||
util.teardownStage(stageName); | ||
util.setupStageWithFixture(testDir, stageName, fixtureName); | ||
}); | ||
|
||
it('should convert styled-components template tags', () => { | ||
let output = shell.exec('node ../dist/index.js build'); | ||
expect(output.code).toBe(0); | ||
|
||
// from styled.h1` to styled.h1( | ||
output = shell.grep(/styled.h1\(/, ['dist/build-withbabel.*.js']); | ||
expect(output.code).toBe(0); | ||
}); | ||
|
||
// TODO: make this test work by allowing customization of plugin order | ||
it.skip('should remove comments in the CSS', () => { | ||
// the "should be removed" comment shouldn't be there (gets error code) | ||
const output = shell.grep(/should be removed/, [ | ||
'dist/build-withbabel.*.js', | ||
]); | ||
expect(output.code).toBe(1); | ||
}); | ||
|
||
it('should compile files into a dist directory', () => { | ||
expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-withbabel.cjs.development.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-withbabel.cjs.production.min.js') | ||
).toBeTruthy(); | ||
expect(shell.test('-f', 'dist/build-withbabel.esm.js')).toBeTruthy(); | ||
|
||
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); | ||
}); | ||
|
||
afterAll(() => { | ||
util.teardownStage(stageName); | ||
}); | ||
}); |
Oops, something went wrong.