vuejs / vue-template-es2015-compiler

Support a subset of handy ES2015 features in Vue 2.0 templates.
61 stars 23 forks source link

ES6 template string not transformed if stripWith is set to false #4

Closed puxxustc closed 8 years ago

puxxustc commented 8 years ago

env

macOS 10.12.2 Beta nodejs 7.1.0 vue@2.0.5 vue-loader@9.9.0 vue-template-compiler@2.0.5 vue-template-es2015-compiler@1.2.2

Steps to reproduce

init a test vue project

vue init webpack test
cd test

edit src/components/Hello.vue

<template>
  <div class="hello">
    <h1>{{ `${msg}` }}</h1>
  </div>
</template>

<script>
export default {
  name: 'hello',
  data () {
    return {
      msg: 'test',
    }
  },
}
</script>

edit build/webpack.base.conf to set stripWith option:

...
  vue: {
    loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
    postcss: [
      require('autoprefixer')({
        browsers: ['last 2 versions'],
      }),
    ],
    templateBuble: {
      transforms: {
        stripWith: false,
      },
    },
  },
}

then build

npm run build

What is actually happening?

got error:

> test@1.0.0 build /Users/xiaoxiao/test
> node build/build.js

  Tip:
  Built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

⠋ building for production...cp: no such file or directory: static/*
Hash: c549da50f0512c6e9d7a
Version: webpack 1.13.3
Time: 2993ms
                                                  Asset       Size  Chunks             Chunk Names
             static/js/manifest.6c94bf3b4868bf538742.js  832 bytes       0  [emitted]  manifest
                  static/js/app.b2c66577ddca1c16ffc3.js    12.9 kB    1, 0  [emitted]  app
               static/js/vendor.7ed3163398037fd18b97.js    51.6 kB    2, 0  [emitted]  vendor
    static/css/app.dfca11727ccf9e74f393b0c223db19ce.css  236 bytes    1, 0  [emitted]  app
         static/js/manifest.6c94bf3b4868bf538742.js.map    8.86 kB       0  [emitted]  manifest
              static/js/app.b2c66577ddca1c16ffc3.js.map    15.3 kB    1, 0  [emitted]  app
static/css/app.dfca11727ccf9e74f393b0c223db19ce.css.map  493 bytes    1, 0  [emitted]  app
           static/js/vendor.7ed3163398037fd18b97.js.map     410 kB    2, 0  [emitted]  vendor
                                             index.html  441 bytes          [emitted]

ERROR in static/js/app.b2c66577ddca1c16ffc3.js from UglifyJs
SyntaxError: Unexpected character '`' [./~/vue-loader/lib/template-compiler.js?id=data-v-0c9c5c28!./~/vue-loader/lib/selector.js?type=template&index=0!./src/components/Hello.vue:4,3]

Description

It seems that if stripWith is set to false, template string will not be transformed.