Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Integration with transpilers #113

Open
corwin-of-amber opened this issue Mar 25, 2021 · 4 comments
Open

Integration with transpilers #113

corwin-of-amber opened this issue Mar 25, 2021 · 4 comments

Comments

@corwin-of-amber
Copy link

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 which lang was specified for the <script> tag? For <style>, there is a property preprocessLang on the descriptor, but not for the script.

@LinusBorg
Copy link
Member

LinusBorg commented Mar 25, 2021

On the descriptor returned by parse(), you can check descriptor.script.attrs.lang

See vue-loader, for example:

https://github.com/vuejs/vue-loader/blob/66893d70eace99129adf96d9ecd27071e7f6cf38/lib/index.js#L127-L128

@corwin-of-amber
Copy link
Author

corwin-of-amber commented Mar 25, 2021

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?

@Aaron-Pool
Copy link

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.

@dwightjack
Copy link

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, apeschar/esbuild-vue#7).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants