You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just use vue@next package in a NodeJS environment, setup a component with only a template string.
What is expected?
Compiling template works
What is actually happening?
An HTML comment is rendered instead of the expected markup and a warning message is displayed:
[Vue warn]: Component provides template but the build of Vue you are running does not support runtime template compilation. Either use the full build or pre-compile the template using Vue CLI.
I've dig the code a bit, If I understand correclty, vue package is now a full-build (runtime-dom + compiler-dom).
I think the main issue here come from the __RUNTIME_COMPILE__ build variable.
Full-build works with ESM & Global builds, all the needed packages are built with __RUNTIME_COMPILE__ to true and bundled together in one file by rollup.
But this behavior fail for CommonJS build, because vue/dist/vue.cjs.js require @vue/runtime-core with a __RUNTIME_COMPILE__ set to false.
letcompile: CompileFunction|undefined// exported method uses any to avoid d.ts relying on the compiler types.exportfunctionregisterRuntimeCompiler(_compile: any){compile=_compile}functionfinishComponentSetup(instance: ComponentInternalInstance,parentSuspense: SuspenseBoundary|null,isSSR: boolean){// More code here...if(__RUNTIME_COMPILE__&&Component.template&&!Component.render){// __RUNTIME_COMPILE__ ensures `compile` is providedComponent.render=compile!(Component.template,{isCustomElement: instance.appContext.config.isCustomElement||NO})// mark the function as runtime compiled;(Component.renderasRenderFunction).isRuntimeCompiled=true}// More code here...}
With __RUNTIME_COMPILE__ to false and after rollup tree-shaking, the output code will be:
functionregisterRuntimeCompiler(_compile){}functionfinishComponentSetup(instance,parentSuspense,isSSR){// More code here...}
As you can see, compile variable which hold the compiler function is totally deleted of the source code.
What I've tried:
Using directly @vue/{runtime,compiler}-dom but problem was the same, theses builds use __RUNTIME_COMPILE__ to false
Trying to remove __RUNTIME_COMPILE__ from packages, everytinh works, but 3 tests fails now. Sample commit here
Maybe it's an intended behavior or a bad usage, I'm sorry to wasting your time 😄
The text was updated successfully, but these errors were encountered:
Version
3.0.0-alpha.8 / master branch
Reproduction link
https://github.com/chymz/vue-next-cjs-full-issue
Steps to reproduce
Just use
vue@next
package in a NodeJS environment, setup a component with only a template string.What is expected?
Compiling template works
What is actually happening?
An HTML comment is rendered instead of the expected markup and a warning message is displayed:
I've dig the code a bit, If I understand correclty,
vue
package is now a full-build (runtime-dom + compiler-dom).I think the main issue here come from the
__RUNTIME_COMPILE__
build variable.Full-build works with ESM & Global builds, all the needed packages are built with
__RUNTIME_COMPILE__
totrue
and bundled together in one file by rollup.But this behavior fail for CommonJS build, because
vue/dist/vue.cjs.js
require@vue/runtime-core
with a__RUNTIME_COMPILE__
set tofalse
.Maybe this leads to another issue: we cannot register a compiler on runtime.
If we take this part of the code: https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/component.ts#L420-L447
With
__RUNTIME_COMPILE__
tofalse
and after rollup tree-shaking, the output code will be:As you can see,
compile
variable which hold the compiler function is totally deleted of the source code.What I've tried:
@vue/{runtime,compiler}-dom
but problem was the same, theses builds use__RUNTIME_COMPILE__
tofalse
__RUNTIME_COMPILE__
from packages, everytinh works, but 3 tests fails now. Sample commit hereMaybe it's an intended behavior or a bad usage, I'm sorry to wasting your time 😄
The text was updated successfully, but these errors were encountered: