-
Notifications
You must be signed in to change notification settings - Fork 10
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
Rfc/issue 185 resources refactor #466
Rfc/issue 185 resources refactor #466
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.
I had got used to calling these transforms
plugins ¯\_(ツ)_/¯
That modification to rollup config is perfect, I was thinking people were going to have to include their own configuration with their plugins or something. The additional intercept and optimize capability is a good idea as well.
My only gripe is with no pre-transform(resource) or default override capability. This could be addressed at a later time.
edit: also I'm not sure if I'm in agreement with the combined markdown and html resource. When I wrote #450 and attempted to decouple them, I recall it being slightly difficult because they both needed to make use of app/page templates.
} | ||
|
||
// handle custom user file extensions | ||
const customResources = compilation.config.plugins.filter((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.
Nice! Was curious how we were going to implement this in rollup. This is exactly whats needed.
} | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
async intercept(contents, headers) { |
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.
Interesting idea +1
// ex: remove es shim <script>, convert .ts -> .js and update path references | ||
// this is only an _index.html_ file, BYOA (Bring Your Own AST) | ||
// eslint-disable-next-line no-unused-vars | ||
shouldOptimize(contents, url) { |
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.
Perfect for post-serialize plugin functionality
htmlModified = htmlModified.replace(/<script src="\/node_modules\/@webcomponents\/webcomponentsjs\/webcomponents-bundle.js"><\/script>/, ''); | ||
htmlModified = htmlModified.replace(/<script type="importmap-shim">.*?<\/script>/s, ''); | ||
htmlModified = htmlModified.replace(/<script defer="" src="\/node_modules\/es-module-shims\/dist\/es-module-shims.js"><\/script>/, ''); | ||
htmlModified = htmlModified.replace(/<script type="module-shim"/g, '<script type="module"'); |
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.
💯 agree with this refactor.
Yeah, and I think once there are some clear use cases for that, I think it will make it easier to understand what a good design for that could look like. It could be just as easy as running // then handle serving urls
app.use(async (ctx, next) => {
// run user plugins
// run greenwood plugins
// run user plugins again?
}); Or perhaps cascading middleware is better for this, but certainly solving in its own PR will allow us to drill down into the design and come up with something good once we have that clear use case.
Maybe I misunderstand your comment, but given my experience is the same as yours (decoupling meant more logic spread out in multiple places, specifically |
* initial transforms refactor using Resources approach * POC of a FooResource * make resource resolve async and resource support for css js and json * support standard font and image resources * integrate markdown resource handling * WIP resource lifecycle refactor * refactor all plugins * comments and code cleanup * delete old transforms * filename change for consistency * custom file extension integration with rollup * fix existing test cases to restore expected outcomes post refactor * fix .ico resolution by using url * made spec for a foo resource plugin * delete old plugin specs, rename existing specs, added plugin name spec * refactor and restore google analytics plugin * refactor and restore polyfills plugin * plugin documentation refactoring * add examples and rename * refactor serialize teardown into standard html optimize * remove unfinished sentance from docs * refactor import map from standard html plugin to node resolve plugin intercept * fix linting * remove example foo code
* initial transforms refactor using Resources approach * POC of a FooResource * make resource resolve async and resource support for css js and json * support standard font and image resources * integrate markdown resource handling * WIP resource lifecycle refactor * refactor all plugins * comments and code cleanup * delete old transforms * filename change for consistency * custom file extension integration with rollup * fix existing test cases to restore expected outcomes post refactor * fix .ico resolution by using url * made spec for a foo resource plugin * delete old plugin specs, rename existing specs, added plugin name spec * refactor and restore google analytics plugin * refactor and restore polyfills plugin * plugin documentation refactoring * add examples and rename * refactor serialize teardown into standard html optimize * remove unfinished sentance from docs * refactor import map from standard html plugin to node resolve plugin intercept * fix linting * remove example foo code
Related Issue
resolves #185 - a new take on an existing design as started in #450
Summary of Changes
ResourceInterface
base class (f.k.a Transforms) with various lifecycles.Notes / Thoughts
@greenwood/data
and return JS for .gqlTODOs
intercept
-importMap
?devServer
to use standard plugins now?importMap
,liveServer
into their own?