-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: CSS variable injection #426
Conversation
import { transform } from '../../transformers/transformer'; | ||
import { pretify } from '../../__tests__/utils'; | ||
|
||
describe('transform', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorganize the tests per file type.
"allowJs": false, | ||
"checkJs": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make typescript stricter for the postcss-plugin-lwc
project.
Benchmark resultsBase commit: |
expect(() => transform()).toThrow( | ||
/Expect a string for source. Received undefined/ | ||
/Expect a string for source. Received undefined/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected
} | ||
}); | ||
it("should apply transformation for valid javascript file", async () => { | ||
describe('javascript transform', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for consistency with html and css test descriptions, perhaps we can capitalize JAVASCRIPT transform. Also wondering if we need the word transform since the root level describe is already named transform
@@ -1,68 +1,100 @@ | |||
import * as postcss from "postcss"; | |||
import * as cssnano from "cssnano"; | |||
import postcssPluginRaptor from "postcss-plugin-lwc"; | |||
import postcssPluginLwc from "postcss-plugin-lwc"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for renaming! raptor no more
"export default style;" | ||
].join("\n"); | ||
/** | ||
* Transform the var function to a call expression to the custom properties resolver with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description is a bit confusing. Are we doing transform var function to a call expression in a form of custom properties resolver...?
token: TOKEN_PLACEHOLDER, | ||
customProperties: { | ||
allowDefinition: customProperties.allowDefinition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is existence check needed prior accessing allowDefinition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need since it gets normalized.
@@ -51,42 +17,35 @@ function transform(decl: Declaration, transformer: VarTransformer, value: string | |||
return value; | |||
} | |||
|
|||
const [, prefix] = varMatch; | |||
// Prefix is either an empty string or a whitespace depending if the `var()` function is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good comment
@@ -17,6 +24,15 @@ export type OutputProxyCompatConfig = | |||
| { module: string } | |||
| { independent: string }; | |||
|
|||
export interface CustomPropertiesConfig { | |||
allowDefinition?: boolean; | |||
resolveFromModule?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the simplification
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
Add custom properties injection support as outlined in the RF0105 CSS custom properties injection.
Does this PR introduce a breaking change?