-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/handle extracted compiled files (#1513)
* Extract styles to file in babel plugin * Add changeset * Add test for extracting to css files * WIP * Remove parcel-transformer-css reference * Fix type errors * Add .synk * Update .synk * Update .synk * Rename .synk to snyk (silly me) * Update webpack plugin * Update Parcel integration test * Remove duplicates * Update snapshot test * mute ts error in the fixture * Specify file name * Refactor tests * Add .css to prettierignore * remove .only * PR feedbacks * Add extractStylesToDirectory option to Webpack and Parcel * escape chars * Use AST contruction instead of template.ast --------- Co-authored-by: Jake Lane <[email protected]>
- Loading branch information
Showing
32 changed files
with
469 additions
and
179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@compiled/babel-plugin-strip-runtime': minor | ||
'@compiled/parcel-transformer': patch | ||
'@compiled/webpack-loader': patch | ||
--- | ||
|
||
Add extractStylesToDirectory config to support extraction to CSS files |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ CHANGELOG.md | |
coverage | ||
dist | ||
storybook-static | ||
**/__fixtures__/*.css |
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
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
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,13 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "browsers": "last 1 version" } }], | ||
["@babel/preset-react", { "runtime": "automatic" }] | ||
], | ||
"plugins": [ | ||
["@compiled/babel-plugin", { "importReact": false, "optimizeCss": false }], | ||
[ | ||
"@compiled/babel-plugin-strip-runtime", | ||
{ "extractStylesToDirectory": { "source": "src", "dest": "dist" } } | ||
] | ||
] | ||
} |
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,23 @@ | ||
{ | ||
"name": "@compiled/babel-component-extracted-fixture", | ||
"version": "0.1.0", | ||
"private": true, | ||
"main": "./dist/index.js", | ||
"scripts": { | ||
"build": "TEST_PKG_VERSION='0.0.0' babel ./src --out-dir=./dist" | ||
}, | ||
"dependencies": { | ||
"@compiled/react": "*" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.21.5", | ||
"@babel/core": "^7.21.8", | ||
"@babel/preset-env": "^7.21.5", | ||
"@babel/preset-react": "^7.18.6", | ||
"@compiled/babel-plugin": "*", | ||
"@compiled/babel-plugin-strip-runtime": "*" | ||
}, | ||
"peerDependencies": { | ||
"react": "^17.0.1" | ||
} | ||
} |
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,17 @@ | ||
import { styled, css } from '@compiled/react'; | ||
|
||
const Button = styled.button({ | ||
color: 'blue', | ||
fontSize: '30px', | ||
border: '2px solid blue', | ||
padding: '32px', | ||
backgroundColor: 'yellow', | ||
}); | ||
|
||
export default function BabelComponent({ children }) { | ||
return ( | ||
<div css={css({ marginTop: 30 })}> | ||
<Button>{children}</Button> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import BabelComponentExtracted from '@compiled/babel-component-extracted-fixture/dist/index'; | ||
import BabelComponent from '@compiled/babel-component-fixture'; | ||
import '@compiled/react'; | ||
import { css } from '@compiled/react'; | ||
|
||
const App = () => ( | ||
<> | ||
<div css={{ fontSize: 50, color: 'red' }}>CSS prop</div> | ||
<div css={css({ fontSize: 50, color: 'blue' })}>CSS prop</div> | ||
<BabelComponent>Babel component</BabelComponent> | ||
<BabelComponentExtracted>Component from NPM</BabelComponentExtracted> | ||
</> | ||
); |
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
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
Oops, something went wrong.