Skip to content

Commit a4fcdbe

Browse files
committed
make standalone build usable in Node.js too
1 parent 0ca13df commit a4fcdbe

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

build/config.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const banner =
1212
' * Released under the MIT License.\n' +
1313
' */'
1414

15-
const baseAlias = require('./alias')
16-
1715
const builds = {
1816
// Runtime only (CommonJS). Used by bundlers e.g. Webpack & Browserify
1917
'web-runtime-dev': {
@@ -43,21 +41,15 @@ const builds = {
4341
dest: path.resolve(__dirname, '../dist/vue.js'),
4442
format: 'umd',
4543
env: 'development',
46-
banner,
47-
alias: {
48-
he: './entity-decoder'
49-
}
44+
banner
5045
},
5146
// Runtime+compiler standalone production build.
5247
'web-standalone-prod': {
5348
entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'),
5449
dest: path.resolve(__dirname, '../dist/vue.min.js'),
5550
format: 'umd',
5651
env: 'production',
57-
banner,
58-
alias: {
59-
he: './entity-decoder'
60-
}
52+
banner
6153
},
6254
// Web compiler (CommonJS).
6355
'web-compiler': {
@@ -86,7 +78,7 @@ function genConfig (opts) {
8678
plugins: [
8779
flow(),
8880
buble(),
89-
alias(Object.assign({}, baseAlias, opts.alias))
81+
alias(require('./alias'))
9082
]
9183
}
9284

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
/* @flow */
22

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

5-
export function decode (html: string): string {
6-
decoder.innerHTML = html
7-
return decoder.textContent
5+
let decode
6+
7+
/* istanbul ignore else */
8+
if (inBrowser) {
9+
const decoder = document.createElement('div')
10+
decode = (html: string): string => {
11+
decoder.innerHTML = html
12+
return decoder.textContent
13+
}
14+
} else {
15+
decode = require('he').decode
816
}
17+
18+
export { decode }

src/compiler/parser/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { decode } from 'he'
3+
import { decode } from './entity-decoder'
44
import { parseHTML } from './html-parser'
55
import { parseText } from './text-parser'
66
import { cached, no, camelize } from 'shared/util'

0 commit comments

Comments
 (0)