Skip to content
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

feat: use @vue/compiler-sfc as a compiler for TS if available #5170

Merged
merged 2 commits into from Mar 19, 2020

Conversation

cexbrayat
Copy link
Member

@cexbrayat cexbrayat commented Feb 9, 2020

Update: I'll let you decide but #5172 is probably a better alternative. See vuejs/vue-cli-plugin-vue-next#5 for more context

The fork-ts-checker-webpack-plugin is using vue-template-compiler by default, and this compiler is not the correct one to pick for vue-next. This commit tries to load @vue/compiler-sfc and falls back to vue-template-compiler if it does not find it.

It also bumps the fork-ts-checker-webpack-plugin to use v3.1.3

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

@cexbrayat cexbrayat changed the title feat: use @vue/compiler-sfc as a s compiler for TS if available feat: use @vue/compiler-sfc as a compiler for TS if available Feb 9, 2020
@sodatea
Copy link
Member

sodatea commented Feb 16, 2020

I think we can just add a file that shims the compiler API add pass it to the fork-ts-checker-webpack-plugin.

@sodatea
Copy link
Member

sodatea commented Feb 16, 2020

All it needs is a path to a file that exports the parseComponent API, which can be implemented by wrapping around the @vue/compiler-sfc public API.
https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/5008da9f4bd732bf70cfae0e187e4e4ecc95dfd1/src/VueProgram.ts#L303-L323

@cexbrayat cexbrayat force-pushed the fix/ts-vue-next branch 2 times, most recently from e2627da to 2b2f03a Compare February 19, 2020 13:07
@cexbrayat
Copy link
Member Author

@sodatea I updated the PR based on your idea.
To sum up:

  • we need to use the latest fork-ts-checker-webpack-plugin to be able to give it another compiler (the one currently used does not)
  • the second commit introduces a shim that just delegates to parse when parseComponent is called by the webpack plugin.
    I am open to suggestions for the file name and location.

We should now be able to remove vue-template-compiler from the devDependencies when using vue-next 🙂

cexbrayat added a commit to cexbrayat/vue-cli-plugin-vue-next that referenced this pull request Feb 19, 2020
When vuejs/vue-cli#5170 lands in the CLI, we should be able to remove `vue-template-compiler` from the devDependencies.

Fixes vuejs#5
@cexbrayat
Copy link
Member Author

@sodatea I updated the PR with your feedback:

  • now bumps to fork-ts-checker-webpack-plugin@3.1.1
  • now uses require.resolve to load the new compiler

The `fork-ts-checker-webpack-plugin` is using `vue-template-compiler` by default, and this compiler is not the correct one to pick for vue-next. This commit tries to load `@vue/compiler-sfc` and falls back to `vue-template-compiler` if it does not find it.
@sodatea sodatea merged commit 3633cf5 into vuejs:dev Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants