Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): support vue runtime compiler #4762

Merged

Conversation

huang-julien
Copy link
Member

@huang-julien huang-julien commented May 2, 2022

πŸ”— Linked issue

resolve nuxt/nuxt#13843

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR allow to use vue runtimeCompiler on both server and client side

  • add vue.runtimeCompiler boolean option to nuxt/schema
  • unmock vue 3 only when runtimeCompiler option is set to true when building and make vue runtime compiler available client side
  • with externalVue to true, force trace files used by generated code from the runtime compiler

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented May 2, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit b404f6e
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/632b6790a288710009537d25
😎 Deploy Preview https://deploy-preview-4762--nuxt3-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@danielroe danielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels May 3, 2022
@huang-julien huang-julien force-pushed the feat/nuxt-ssr-runtime-template-compiler branch 2 times, most recently from e897d31 to 905b3b6 Compare May 3, 2022 10:10
@pi0
Copy link
Member

pi0 commented May 3, 2022

Hi @huang-julien and thanks for this PR! πŸ’š I think finally we can add an option to nitro if modification of commonJS plugin options is required.

I hope we can add runtime support with lighter dependencies. At least having @vue/devtools-api doesn't makes sense to me in the bundle for it.

(BTW: You don't need to merge into main on each commit. I will make once rebase before merge)

@huang-julien
Copy link
Member Author

Hi @huang-julien and thanks for this PR! πŸ’š I think finally we can add an option to nitro if modification of commonJS plugin options is required.

I hope we can add runtime support with lighter dependencies. At least having @vue/devtools-api doesn't makes sense to me in the bundle for it.

(BTW: You don't need to merge into main on each commit. I will make once rebase before merge)

Hi @pi0 πŸ‘‹ , yes i was thinking about a PR on Nitro to add the option for the commonjs plugin modification instead of just replacing it in the nuxt package. Do you want me to remove the @vue/devtool-api from the bundle through a commit ?

@huang-julien
Copy link
Member Author

linked PR - nitrojs/nitro#187
the feature will be refactored if the PR is accepted

packages/nuxt/src/core/nitro.ts Outdated Show resolved Hide resolved
packages/nuxt/package.json Outdated Show resolved Hide resolved
@huang-julien
Copy link
Member Author

@pi0 it should be ok now. here's a working example

@huang-julien huang-julien requested a review from pi0 May 12, 2022 06:52
packages/nuxt/src/core/nitro.ts Outdated Show resolved Hide resolved
packages/schema/src/config/build.ts Outdated Show resolved Hide resolved
@huang-julien huang-julien requested a review from pi0 May 12, 2022 10:38
@huang-julien huang-julien force-pushed the feat/nuxt-ssr-runtime-template-compiler branch from 31535eb to 7095f92 Compare May 12, 2022 10:45
@huang-julien
Copy link
Member Author

huang-julien commented May 13, 2022

Client builds with runtime compiler now supports webpack and the runtimeCompiler option is now under the vue namespace in packages/schema/src/config/_app.ts

@tobiasdiez
Copy link
Contributor

What's the status of this PR? Would be awesome to use the runtime compiler soon!

@huang-julien
Copy link
Member Author

@tobiasdiez if you really need it now, this module can enable it

@huang-julien huang-julien marked this pull request as draft July 21, 2022 20:42
@huang-julien
Copy link
Member Author

investigating nuxt/nuxt#13843

@huang-julien
Copy link
Member Author

fixed nuxt/nuxt#13843

@huang-julien huang-julien marked this pull request as ready for review July 22, 2022 21:43
@atinux
Copy link
Member

atinux commented Jul 23, 2022

Thank you!

It would be nice to document this option somewhere since it is quite useful for CMS integrations using the template prop (see linked issue).

Also, is there a place where we can add a test case for this?

@huang-julien
Copy link
Member Author

huang-julien commented Jul 23, 2022

@atinux

Also, is there a place where we can add a test case for this?

Do you mean a stackblitz or an example ? I've tested the component with template defined in runtime in the playground here

@atinux
Copy link
Member

atinux commented Jul 25, 2022

I am thinking of a test case here: https://github.com/nuxt/framework/tree/main/test

Any guidance for the best place for it? @danielroe @pi0

@pi0
Copy link
Member

pi0 commented Jul 25, 2022

Testing requires making another fixture currently we only have one. We can add later.

I'm pending to locally test this PR. Some changes can be probably reduced for mocking and saving bundle size with option enabled.

In the meantime you can use nuxt-runtime-compiler module

@huang-julien huang-julien marked this pull request as draft September 3, 2022 22:20
@huang-julien
Copy link
Member Author

huang-julien commented Mar 31, 2023

can't find why CI are failing πŸ€·β€β™‚οΈ I can't see logs while it does work locally. I'm not even sure if the issue comes from estree walker

@huang-julien huang-julien marked this pull request as ready for review April 3, 2023 20:09
@autofix-troubleshooter
Copy link

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! πŸ˜ƒ

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me - I've tested on an external project as well, and all seems good. Very happy to iterate over v3.4 releases and then make stable in vue.runtimeCompiler in v3.5.

Thank you so much for your lengthy and good work on this ❀️

@danielroe danielroe changed the title feat(nuxt): support using vue runtimeCompiler on build feat(nuxt): support vue runtime compiler Apr 6, 2023
@danielroe danielroe merged commit 3fc9a75 into nuxt:main Apr 6, 2023
@danielroe danielroe mentioned this pull request Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow using vue runtime compiler in built nuxt app
8 participants