Skip to content

Allow passing a custom compiler through options #1198

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

Closed
rigor789 opened this issue Mar 20, 2018 · 2 comments
Closed

Allow passing a custom compiler through options #1198

rigor789 opened this issue Mar 20, 2018 · 2 comments

Comments

@rigor789
Copy link

What problem does this feature solve?

I'm wondering if we could allow specifying a custom template compiler to be used here

const compile =
isServer && compiler.ssrCompile && options.optimizeSSR !== false
? compiler.ssrCompile
: compiler.compile

The reason this would be useful is that we could more easily allow vue-loader to work with different platforms such as nativescript-vue.

Our goal is to keep feature parity with vue-loader, without having to maintain a fork which could easily get out of sync.

This would allow us to create a loader that is run before vue-loader, which would assemble a .vue file based on the targeted platform, and let vue-loader take care of the rest the same way it does for the web.

A more detailed write up of what we are working on can be found here: nativescript-vue#1

What does the proposed API look like?

I think it can be as simple as this

const compilerToUse = options.templateCompiler || compiler

const compile =
    isServer && compilerToUse.ssrCompile && options.optimizeSSR !== false
      ? compilerToUse.ssrCompile
      : compilerToUse.compile
@yyx990803
Copy link
Member

This is supported in the next branch FYI. I can take a PR for master if you need it for v14 as well.

@rigor789
Copy link
Author

Thank you! just tried with the next branch and this works really well! As for master, I don't think we need it right now, since our loader is still a work in progress, and I'll work with the next branch.

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

No branches or pull requests

2 participants