-
-
Notifications
You must be signed in to change notification settings - Fork 52
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(emotion): Add emotion #29
feat(emotion): Add emotion #29
Conversation
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.
If i am not wrong to have a fully working plugin, sourcemap needs to implement:
get_code_map
as_arg
to_writer
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.
@kwonoj is working on required apis
// Sourcemap is wrong at the moment, plugin has to use data.source_map but at | ||
// the moment it is not fully supported and cant be converted to | ||
// Arc<SourceMap> | ||
let cm = Lrc::new(SourceMap::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.
This is wrong
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.
Do you want me to make a fix for that and have a working plugin without source maps or do you prefer to wait until source maps are supported in Plugins to finish the emotion plugin?
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 don't have strong opinion about it, but this is simply wrong and it will panic
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.
Will it be correct?
let cm = Arc::new(SourceMap::default());
This is my first time writing Rust code and maybe i am doing a stupid question
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, the problem is not initialization.
It's wrong value
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.
As i understand i should read the file and set the content as value of source map, right?
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, it will not work because SourceMap
is a set of files
What are the differences between this and https://github.com/vercel/next.js/tree/canary/packages/next-swc/crates/emotion ? |
This one depends on the one in the next.js repository |
This is just to publish as npm package and allow non NextJs applications to use the plugin. This is using the existing one from Next (the one you wrote). This plugin could be used by |
@kwonoj Once swc-project/swc#4781 is merged, is it possible to do the sourcemap conversion in order to pass it to the |
I'm not clear if emotion plugin is sufficient with |
// Sourcemap is wrong at the moment, plugin has to use data.source_map but at | ||
// the moment it is not fully supported and cant be converted to | ||
// Arc<SourceMap> | ||
let cm = Lrc::new(SourceMap::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.
@kwonoj i have been trying to fix the problem with sourcemap but i don't find information about if it is possible to convert Arc<PluginSourceMapProxy>
into Arc<SourceMap>
, is there a way to convert?
I took a look to your code instrument plugin and i see you use Arc<SourceMapper>
instead https://github.com/kwonoj/swc-coverage-instrument/blob/91f1972e50effc9bc8c02abf794da80f4b856f84/packages/swc-coverage-instrument/src/visitors/coverage_visitor.rs#L18. Should the next_emotion
plugin use Arc<SourceMapper>
? i made a try to change from Arc<SourceMap>
to Arc<SourceMapper>
in the next plugin and it seems to work (but in the configuration i don't know how to convert Arc<SourceMap>
into Arc<SourceMapper>
) https://github.com/vercel/next.js/blob/607ff2b3225ea9fab04b4fca07e4a609b05e8038/packages/next-swc/crates/core/src/lib.rs#L196
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.
Yes, you can't use concrete types to make compatible for plugin's proxy / customr transform both, reason sourcemapper is implemented for the plugin proxy.
Closed in favor of: https://github.com/IvanRodriCalleja/emotion-swc-plugin |
swc_emotion
TODO: Sourcemaps are deactivated right now until are fully supported. swc-project/swc#4282
Plugin can be used right now without sourcemaps (at the moment always use
false
)