You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a custom transformer that generates HTML. It seems that parcel doesn't do normal post-processing of HTML if it came from this transformer. Following the guide, my transformer looks like this:
exportdefaultnewTransformer({asynctransform({asset,options}){// generates html from source filelethtml=awaitrunHtmeta(asset.filePath);letdeps=html.matchAll(/@(import)|(include)"(.*?)"/g);for(letdepofdeps){// Tried adding dependencies but it also doesn't workasset.addDependency({specifier: `./${dep}`,specifierType: 'kdl'});}// had to add this so the gen'd html is invalidated on source changeasset.invalidateOnFileChange(asset.filePath)asset.type='html';asset.setCode(html);// Return the assetreturn[asset];}});
I've noticed that it doesn't invalidate HTML deps like imported TS and CSS, despite knowing about them in the first build, which makes me always delete the generated files to invalidate the cache. However, the actual contents of the generated HTML do change.
I assume the generated HTML goes through the usual steps, as it does generate a dependency tree, but it seems that caching does not take this into account.
Am I doing something wrong? (Besides not setting a source map)
My original discussion didn't get any answers so I'm reposting as an issue to hopefully get some insights.
Also, I would love more pointers into how I would write a custom HTML transformer, sort-of in a tutorial form. I wrote what I have reading the docs, but I think I'm still missing some bits.
Hi, I have a custom transformer that generates HTML. It seems that parcel doesn't do normal post-processing of HTML if it came from this transformer. Following the guide, my transformer looks like this:
I've noticed that it doesn't invalidate HTML deps like imported TS and CSS, despite knowing about them in the first build, which makes me always delete the generated files to invalidate the cache. However, the actual contents of the generated HTML do change.
I assume the generated HTML goes through the usual steps, as it does generate a dependency tree, but it seems that caching does not take this into account.
Am I doing something wrong? (Besides not setting a source map)
Originally posted by @Diegovsky in #10086
The text was updated successfully, but these errors were encountered: