Open corwin-of-amber opened 3 years ago
On the descriptor
returned by parse()
, you can check descriptor.script.attrs.lang
See vue-loader
, for example:
Nice, thanks! Would it make sense to expose this information through the top-level package component-compiler
, since component-compiler-utils
is sort of an internal package? E.g., add attrs
or lang
to CompileResult
?
Just to add my two cents--I also think @corwin-of-amber's suggestion above would be pretty helpful. Currently, if you want to add additional transpilation to the script block, you can't use the top level component-compiler
package, because it doesn't pass that information through to the compiler consumer. I obviously don't expect component-compiler
to do any actual work with things like the lang
attribute, but to expose that information as metadata to whatever is consuming the compiler results would be helpful.
Hello, I have submitted a PR to add the lang
property to the CompileResult
object. As suggested by @Aaron-Pool, by default, it does nothing, but it might be helpful for other tools (for example, https://github.com/apeschar/esbuild-vue/pull/7).
According to #30, the builder that uses vue-component-compiler is responsible for running the script through whatever transpiler is appropriate (e.g.
tsc
). Is there a way to know whichlang
was specified for the<script>
tag? For<style>
, there is a propertypreprocessLang
on the descriptor, but not for the script.