Skip to content
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

Request: Enhance "transforms" plugins #67

Open
tbeseda opened this issue Jan 17, 2023 · 2 comments
Open

Request: Enhance "transforms" plugins #67

tbeseda opened this issue Jan 17, 2023 · 2 comments
Labels
question Further information is requested

Comments

@tbeseda
Copy link
Contributor

tbeseda commented Jan 17, 2023

@enhance/ssr allows for script and css transformations, would it be possible to plug in custom transforms alongside the standard ones provided by arc-plugin-enhance here

const _html = enhance({
elements,
scriptTransforms: [
importTransform({ lookup: arc.static })
],
styleTransforms: [
styleTransform
],
initialState: store
})


No idea how this would look for a plugin author...

So far Enhance has intentionally (wisely!) avoided an explicit configuration file. Maybe transforms could be added via a file-based API?
plugins/transforms/css/index.mjs
I'm not sold, but it's a thought.

I don't think Enhance needs these sort of plugins, but it would open up some powerful possibilities. On the other hand it could have a negative performance impact and lead to some plugin author/consumer anti-patterns and footguns. On the other other hand, can't save everyone from themselves 😬

@tbeseda tbeseda added the question Further information is requested label Jan 17, 2023
@kristoferjoseph
Copy link
Contributor

This is a great idea and has been requested previously.
The technical hurdle we ran into was knowing when to run the transform since some transforms would be undone by others.
I had planned to loop back around on this at a later date in order to gather some specifications for concrete use cased people wanted this feature for so I could write better tests.

@tbeseda
Copy link
Contributor Author

tbeseda commented Jan 19, 2023

I wonder if we could start with just CSS transforms? That seems more well defined as to when devs want those to run. Transforming <scripts> is a bit more of a chicken-egg problem.

I'll outline one idea I had as a reference point for a possible implementation:

I'd like to parse <style> tags and replace their contents with output from Lightning.css.
I want it to simply perform the convenient transforms for browser compatibility (like vendor prefixing and syntax lowering).
I don't want all the fancy bundling Lightning features (like imports and expansion) which would need user config and filesystem access.

Just: here's a string of CSS, make it more compatible with more browsers, and I (the plugin) puts it back before it's sent to the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants