-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(ecmascript): support configurable emotion options #4458
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,38 @@ impl Default for TypescriptTransformOptionsVc { | |
| } | ||
| } | ||
|
|
||
| #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)] | ||
| pub enum EmotionLabelKind { | ||
| DevOnly, | ||
| Always, | ||
| Never, | ||
| } | ||
|
|
||
| //[TODO]: need to support importmap, there are type mismatch between | ||
| //[TODO]: next.config.js to swc's emotion options | ||
| #[turbo_tasks::value(shared)] | ||
| #[derive(Default, Clone, Debug)] | ||
| pub struct EmotionTransformOptions { | ||
| pub enabled: bool, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's how I started, and then ends up this was somewhat more ergonomics when try to read next.config.js, we have couple of conditions
and having Option was easier to gracefully read & create config value among those conditions. It is possible to argue who would do 2 (if you specifiy compiler option, explicitly disabling it is non common) but that's certainly possible case if someone relies on some dynamic evaluation based on env / fn. |
||
| pub sourcemap: Option<bool>, | ||
| pub label_format: Option<String>, | ||
| pub auto_label: Option<EmotionLabelKind>, | ||
| } | ||
|
|
||
| #[turbo_tasks::value_impl] | ||
| impl EmotionTransformOptionsVc { | ||
| #[turbo_tasks::function] | ||
| pub fn default() -> Self { | ||
| Self::cell(Default::default()) | ||
| } | ||
| } | ||
|
|
||
| impl Default for EmotionTransformOptionsVc { | ||
| fn default() -> Self { | ||
| Self::default() | ||
| } | ||
| } | ||
|
|
||
| impl WebpackLoadersOptions { | ||
| pub fn is_empty(&self) -> bool { | ||
| self.extension_to_loaders.is_empty() | ||
|
|
@@ -117,7 +149,7 @@ pub struct ModuleOptionsContext { | |
| #[serde(default)] | ||
| pub enable_jsx: Option<JsxTransformOptionsVc>, | ||
| #[serde(default)] | ||
| pub enable_emotion: bool, | ||
| pub enable_emotion: Option<EmotionTransformOptionsVc>, | ||
| #[serde(default)] | ||
| pub enable_react_refresh: bool, | ||
| #[serde(default)] | ||
|
|
||
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.
Can we just always enable the sourcemap?
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 now, this inherits what next.config.js allow to configure. I hope to simplify / consolidate but thinking about feature parity to existing next.js configs we may need to expose.