Attempting to write a transformer that converts svg files to vue components does not appear to be working as expected
š Configuration/Setup
Following the documentation of Transformer and the svg-react plugin implementation, I am attempting to write a parcel transformer plugin that converts imported svg files to vue components:
š¤ Expected Behavior
I had expected the following minimal implementation to be adequate (Full source):
Basically I was assuming that if I return an asset of type=vue where the svg is wrapped inside a template block, the default pipeline for vue3 sfc will take care of processing the generated component.
Now the dev server reports that everything has been built successfully but when I access the ui in browser, it fails to resolve the svg modules and I get a runtime error.
idex.b7a05eb9.js:61 Uncaught Error: Cannot find module 'vue:../../assets/icons/warning.svg'
at newRequire (index.b7a05eb9.js:61:19)
at newRequire (index.b7a05eb9.js:45:18)
at localRequire (index.b7a05eb9.js:84:35)
at 9LNAw.vue (fs-initializer.vue:46:1)
at newRequire (index.b7a05eb9.js:71:24)
at localRequire (index.b7a05eb9.js:84:35)
at initialize (fs-initializer.vue:4:12)
at 8nCLl.3e3393ff5748202f (fs-initializer.vue:12:1)
at newRequire (index.b7a05eb9.js:71:24)
at localRequire (index.b7a05eb9.js:84:35)
I am also convinced that this is not an issue with the transform itself - if I generate the vue component as a file as a separate step outside parcel and then import the generated file from my components - vue is able to handle it just fine and everything works.
š bug report
Attempting to write a transformer that converts svg files to vue components does not appear to be working as expected
š Configuration/Setup
Following the documentation of Transformer and the svg-react plugin implementation, I am attempting to write a parcel transformer plugin that converts imported svg files to vue components:
š¤ Expected Behavior
I had expected the following minimal implementation to be adequate (Full source):
Basically I was assuming that if I return an asset of type=vue where the svg is wrapped inside a template block, the default pipeline for vue3 sfc will take care of processing the generated component.
My .parcelrc is as follows:
šÆ Current Behavior
This does not work. And I end up with errors saying that it is unable to find a transformer to further process the asset returned by my transformer.
If I also add vue transformer explicitly (which I don't see why would be needed):
Now the dev server reports that everything has been built successfully but when I access the ui in browser, it fails to resolve the svg modules and I get a runtime error.
I am also convinced that this is not an issue with the transform itself - if I generate the vue component as a file as a separate step outside parcel and then import the generated file from my components - vue is able to handle it just fine and everything works.
š Your Environment