Skip to content

Commit

Permalink
make standalone build usable in Node.js too
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 5, 2016
1 parent 0ca13df commit a4fcdbe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 3 additions & 11 deletions build/config.js
Expand Up @@ -12,8 +12,6 @@ const banner =
' * Released under the MIT License.\n' +
' */'

const baseAlias = require('./alias')

const builds = {
// Runtime only (CommonJS). Used by bundlers e.g. Webpack & Browserify
'web-runtime-dev': {
Expand Down Expand Up @@ -43,21 +41,15 @@ const builds = {
dest: path.resolve(__dirname, '../dist/vue.js'),
format: 'umd',
env: 'development',
banner,
alias: {
he: './entity-decoder'
}
banner
},
// Runtime+compiler standalone production build.
'web-standalone-prod': {
entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'),
dest: path.resolve(__dirname, '../dist/vue.min.js'),
format: 'umd',
env: 'production',
banner,
alias: {
he: './entity-decoder'
}
banner
},
// Web compiler (CommonJS).
'web-compiler': {
Expand Down Expand Up @@ -86,7 +78,7 @@ function genConfig (opts) {
plugins: [
flow(),
buble(),
alias(Object.assign({}, baseAlias, opts.alias))
alias(require('./alias'))
]
}

Expand Down
18 changes: 14 additions & 4 deletions src/compiler/parser/entity-decoder.js
@@ -1,8 +1,18 @@
/* @flow */

const decoder = document.createElement('div')
import { inBrowser } from 'core/util/env'

export function decode (html: string): string {
decoder.innerHTML = html
return decoder.textContent
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 { decode }
2 changes: 1 addition & 1 deletion src/compiler/parser/index.js
@@ -1,6 +1,6 @@
/* @flow */

import { decode } from 'he'
import { decode } from './entity-decoder'
import { parseHTML } from './html-parser'
import { parseText } from './text-parser'
import { cached, no, camelize } from 'shared/util'
Expand Down

0 comments on commit a4fcdbe

Please sign in to comment.