2
0
Эх сурвалжийг харах

fix entity-decoder build config

Evan You 9 жил өмнө
parent
commit
366202f316

+ 4 - 1
build/config.js

@@ -25,6 +25,7 @@ const builds = {
     entry: path.resolve(__dirname, '../src/entries/web-runtime.js'),
     dest: path.resolve(__dirname, '../dist/vue.runtime.js'),
     format: 'umd',
+    env: 'development',
     banner
   },
   // runtime-only production build for CDN
@@ -41,6 +42,7 @@ const builds = {
     dest: path.resolve(__dirname, '../dist/vue.js'),
     format: 'umd',
     env: 'development',
+    alias: { he: './entity-decoder' },
     banner
   },
   // Runtime+compiler standalone production build.
@@ -49,6 +51,7 @@ const builds = {
     dest: path.resolve(__dirname, '../dist/vue.min.js'),
     format: 'umd',
     env: 'production',
+    alias: { he: './entity-decoder' },
     banner
   },
   // Web compiler (CommonJS).
@@ -91,7 +94,7 @@ function genConfig (opts) {
     plugins: [
       flow(),
       buble(),
-      alias(require('./alias'))
+      alias(Object.assign({}, require('./alias'), opts.alias))
     ]
   }
 

+ 5 - 14
src/compiler/parser/entity-decoder.js

@@ -1,18 +1,9 @@
 /* @flow */
 
-import { inBrowser } from 'core/util/env'
+let decoder
 
-let decode
-
-/* istanbul ignore else */
-if (inBrowser) {
-  const decoder = document.createElement('div')
-  decode = (html: string): string => {
-    decoder.innerHTML = html
-    return decoder.textContent
-  }
-} else {
-  decode = require('he').decode
+export function decode (html: string): string {
+  decoder = decoder || document.createElement('div')
+  decoder.innerHTML = html
+  return decoder.textContent
 }
-
-export { decode }

+ 1 - 1
src/compiler/parser/index.js

@@ -1,6 +1,6 @@
 /* @flow */
 
-import { decode } from './entity-decoder'
+import { decode } from 'he'
 import { parseHTML } from './html-parser'
 import { parseText } from './text-parser'
 import { cached, no, camelize } from 'shared/util'

+ 1 - 1
src/platforms/weex/runtime/index.js

@@ -16,7 +16,7 @@ Vue.config.mustUseProp = mustUseProp
 Vue.options.directives = platformDirectives
 
 // install platform patch function
-Vue.prototype.__patch__ = config._isServer ? noop : patch
+Vue.prototype.__patch__ = patch
 
 // wrap mount
 Vue.prototype.$mount = function (