Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e7cb26

Browse files
committed
feat: upgrade to vue 2.6
1 parent 867e5f8 commit 0e7cb26

File tree

21 files changed

+12923
-172
lines changed

21 files changed

+12923
-172
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"presets": ["env"],
2+
"presets": ["@babel/preset-env"],
33
"env": {
44
"test": {
5-
"presets": ["env"],
5+
"presets": ["@babel/preset-env"],
66
"plugins": ["transform-flow-strip-types"]
77
}
88
}
9-
}
9+
}

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/build.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function buildEntry(config) {
4141

4242
return rollup.rollup(config)
4343
.then(bundle => bundle.generate(output))
44-
.then(({ code }) => {
45-
return write(file, code)
44+
.then((res) => {
45+
return write(file, res.output[0].code)
4646
})
4747
}
4848

@@ -84,4 +84,4 @@ function copyHooks() {
8484

8585
fs.copyFileSync(sourcePath, targetPath);
8686
});
87-
}
87+
}

build/config.js

Lines changed: 94 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,115 @@ const banner = (name, version) => `
1717
* Released under the MIT license.
1818
*/
1919
`
20+
21+
// This is required because some of the third party plugins rely on this
22+
// and cause errors since there is no process variable in {N}.
23+
const intro = `
24+
global.process = global.process || {}
25+
global.process.env = global.process.env || {}
26+
`
27+
2028
const resolveVue = p => {
21-
return path.resolve(process.cwd(), 'node_modules', 'vue/src/', p) + '/'
29+
return path.resolve(process.cwd(), 'node_modules', 'vue/src/', p) + '/'
2230
}
2331
const aliases = {
24-
vue: resolveVue('core/index'),
25-
compiler: resolveVue('compiler'),
26-
web: resolveVue('platforms/web'),
27-
core: resolveVue('core'),
28-
shared: resolveVue('shared'),
29-
sfc: resolveVue('sfc'),
30-
//he: path.resolve(__dirname, 'node_modules', 'he', 'he')
31-
he: path.resolve(__dirname, '..', 'platform/nativescript/util/entity-decoder')
32+
vue: resolveVue('core/index'),
33+
compiler: resolveVue('compiler'),
34+
web: resolveVue('platforms/web'),
35+
core: resolveVue('core'),
36+
shared: resolveVue('shared'),
37+
sfc: resolveVue('sfc'),
38+
//he: path.resolve(__dirname, 'node_modules', 'he', 'he')
39+
he: path.resolve(__dirname, '..', 'platform/nativescript/util/entity-decoder')
3240
}
3341

3442
const builds = {
35-
'nativescript-vue': {
36-
entry: './platform/nativescript/framework.js',
37-
dest: './dist/index.js',
38-
moduleName: 'NativeScript-Vue',
39-
banner: banner('NativeScript-Vue'),
40-
external(id) {
41-
return id.startsWith('tns-core-modules') || id.startsWith('weex')
42-
}
43+
'nativescript-vue': {
44+
entry: './platform/nativescript/framework.js',
45+
dest: './dist/index.js',
46+
moduleName: 'NativeScript-Vue',
47+
banner: banner('NativeScript-Vue'),
48+
intro,
49+
external(id) {
50+
return id.startsWith('tns-core-modules') || id.startsWith('weex')
4351
},
44-
'nativescript-vue-template-compiler': {
45-
entry: './platform/nativescript/compiler.js',
46-
dest: './packages/nativescript-vue-template-compiler/index.js',
47-
moduleName: 'NativeScript-Vue-Template-Compiler',
48-
banner: banner('NativeScript-Vue-Template-Compiler'),
49-
external: Object.keys(require('../packages/nativescript-vue-template-compiler/package.json').dependencies)
50-
}
52+
},
53+
'nativescript-vue-template-compiler': {
54+
entry: './platform/nativescript/compiler.js',
55+
dest: './packages/nativescript-vue-template-compiler/index.js',
56+
moduleName: 'NativeScript-Vue-Template-Compiler',
57+
banner: banner('NativeScript-Vue-Template-Compiler'),
58+
external: Object.keys(require('../packages/nativescript-vue-template-compiler/package.json').dependencies)
59+
}
5160
}
5261

5362

5463
const genConfig = (name) => {
55-
const opts = builds[name]
56-
const config = {
57-
input: opts.entry,
58-
external: opts.external,
59-
output: {
60-
file: opts.dest,
61-
format: opts.format || 'cjs',
62-
banner: opts.banner,
63-
name: opts.moduleName
64-
},
65-
treeshake: {
66-
pureExternalModules: id => id.startsWith('weex')
67-
},
68-
watch: {
69-
chokidar: false
70-
},
71-
plugins: [
72-
replace({
73-
__WEEX__: false,
74-
__VERSION__: VueVersion,
75-
'process.env.NODE_ENV': "'development'",
76-
'let _isServer': 'let _isServer = false',
77-
'process.env.VUE_VERSION': `'${VueVersion}'`,
78-
'process.env.NS_VUE_VERSION': `'${NSVueVersion}'`
79-
}),
80-
flow(),
81-
buble(),
82-
alias(aliases),
83-
resolve(),
84-
commonjs(),
85-
],
86-
}
64+
const opts = builds[name]
65+
const config = {
66+
input: opts.entry,
67+
external: opts.external,
68+
output: {
69+
intro: opts.intro,
70+
file: opts.dest,
71+
format: opts.format || 'cjs',
72+
banner: opts.banner,
73+
name: opts.moduleName
74+
},
75+
// https://github.com/rollup/rollup/issues/2271#issuecomment-455129819
76+
onwarn(warning) {
77+
if (
78+
warning.code === 'CIRCULAR_DEPENDENCY' && [
79+
'vue',
80+
'element-registry',
81+
'patch' // v-template
82+
].some(d => warning.importer.includes(d))
83+
) {
84+
return
85+
} else if (
86+
warning.message.includes('weex')
87+
) {
88+
return
89+
}
90+
91+
console.warn(warning.message)
92+
},
93+
treeshake: {
94+
pureExternalModules: id => id.startsWith('weex')
95+
},
96+
watch: {
97+
chokidar: false
98+
},
99+
plugins: [
100+
replace({
101+
__WEEX__: false,
102+
__VERSION__: VueVersion,
103+
// 'process.env.NODE_ENV': "'development'",
104+
'let _isServer': 'let _isServer = false',
105+
// Vue 2.6 new slot syntax must be enabled via env.
106+
'process.env.NEW_SLOT_SYNTAX': `true`,
107+
'process.env.VBIND_PROP_SHORTHAND': `false`,
108+
'process.env.VUE_VERSION': `process.env.VUE_VERSION || '${VueVersion}'`,
109+
'process.env.NS_VUE_VERSION': `process.env.NS_VUE_VERSION || '${NSVueVersion}'`
110+
}),
111+
flow(),
112+
buble(),
113+
alias(aliases),
114+
resolve(),
115+
commonjs(),
116+
],
117+
}
87118

88-
Object.defineProperty(config, '_name', {
89-
enumerable: false,
90-
value: name
91-
})
119+
Object.defineProperty(config, '_name', {
120+
enumerable: false,
121+
value: name
122+
})
92123

93-
return config;
124+
return config;
94125
}
95126

96127
if (process.env.TARGET) {
97-
module.exports = genConfig(process.env.TARGET)
128+
module.exports = genConfig(process.env.TARGET)
98129
} else {
99-
module.exports.getAllBuilds = () => Object.keys(builds).map(genConfig)
130+
module.exports.getAllBuilds = () => Object.keys(builds).map(genConfig)
100131
}

0 commit comments

Comments
 (0)