@@ -17,84 +17,115 @@ const banner = (name, version) => `
17
17
* Released under the MIT license.
18
18
*/
19
19
`
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
+
20
28
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 ) + '/'
22
30
}
23
31
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' )
32
40
}
33
41
34
42
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' )
43
51
} ,
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
+ }
51
60
}
52
61
53
62
54
63
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
+ }
87
118
88
- Object . defineProperty ( config , '_name' , {
89
- enumerable : false ,
90
- value : name
91
- } )
119
+ Object . defineProperty ( config , '_name' , {
120
+ enumerable : false ,
121
+ value : name
122
+ } )
92
123
93
- return config ;
124
+ return config ;
94
125
}
95
126
96
127
if ( process . env . TARGET ) {
97
- module . exports = genConfig ( process . env . TARGET )
128
+ module . exports = genConfig ( process . env . TARGET )
98
129
} else {
99
- module . exports . getAllBuilds = ( ) => Object . keys ( builds ) . map ( genConfig )
130
+ module . exports . getAllBuilds = ( ) => Object . keys ( builds ) . map ( genConfig )
100
131
}
0 commit comments