vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

Tricky Src Imports : no compile or hot-reload with version 17.4.2 #2068

Open sebastienroul opened 8 months ago

sebastienroul commented 8 months ago

Using Webpack 3.12.4 + vue-loader 17.4.2.

Our practice is to split html and js (for maintenance purpose)

Here is a simplified sample of what we have

In version 17.4.1 before commit src/templateLoader.ts

It worked like a charm.

But after, this commit (and also in version 17.4.0) it doesn't work any more.

=> It silenty kill all our app, just with a build in our CDI.

As the 'html' part is parsed via AST, AST try to find a child which is a template => and consider it as THE template of the page : In our cas :

<template v-else>
      <div >
        BAR
      </div>
    </template>

And then fail in compilation with 'Invalid end tag'....

We try to fix it, by encapsulating the html code in a template :

 <template>
  <div>
    <template v-if="loading">
      <div>
        FOO
      </div>
    </template>
    <template v-else>
      <div >
        BAR
      </div>
    </template>
  </div>
</template>

It works ! vue-loader give the control to compiler-scf.js, and everything is ok. Html is 'compiled'

BUT the hotreload doesn't work anymore.

Then hot-reload happened, but not with the new code, only with original source ast-parsed.

Sorry for being so long to explain, but it's tricky.

Let me know if you need any explanation or info.

Regards