File tree 3 files changed +22
-17
lines changed
3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ var hasBuble = !!tryRequire('buble-loader')
24
24
25
25
// for mp js
26
26
var { compileMP, compileMPScript } = require ( './mp-compiler' )
27
- var { defaultStylePart } = require ( './mp-compiler/util' )
27
+ var { defaultPart } = require ( './mp-compiler/util' )
28
28
29
29
var rewriterInjectRE = / \b ( c s s (?: - l o a d e r ) ? (?: \? [ ^ ! ] + ) ? ) (?: ! | $ ) /
30
30
@@ -103,7 +103,11 @@ module.exports = function (content) {
103
103
104
104
// fix #153: 根组件没有 style 模块,不生成页面的 wxss,补齐内容方便加载 vendor.wxss
105
105
if ( ! parts . styles . length ) {
106
- parts . styles . push ( defaultStylePart )
106
+ parts . styles . push ( defaultPart ( 'style' ) )
107
+ }
108
+ // fix #562: 组件没有 script 模块,会阻塞编译
109
+ if ( ! parts . script ) {
110
+ parts . script = defaultPart ( 'script' )
107
111
}
108
112
109
113
var hasScoped = parts . styles . some ( function ( s ) { return s . scoped } )
Original file line number Diff line number Diff line change @@ -121,23 +121,24 @@ function getBabelrc (src) {
121
121
return ''
122
122
}
123
123
124
- const defaultStylePart = {
125
- type : 'style' ,
126
- content : '\n' ,
127
- start : 0 ,
128
- attrs : { } ,
129
- end : 1 ,
130
- map : {
131
- version : 3 ,
132
- sources : [ ] ,
133
- names : [ ] ,
134
- mappings : '' ,
135
- sourcesContent : [ ]
124
+ const defaultPart = type => {
125
+ return {
126
+ type,
127
+ content : '\n' ,
128
+ start : 0 ,
129
+ attrs : { } ,
130
+ end : 1 ,
131
+ map : {
132
+ version : 3 ,
133
+ sources : [ ] ,
134
+ names : [ ] ,
135
+ mappings : '' ,
136
+ sourcesContent : [ ]
136
137
}
137
138
}
138
139
139
140
module . exports = {
140
- defaultStylePart ,
141
+ defaultPart ,
141
142
cacheFileInfo,
142
143
getFileInfo,
143
144
getCompNameAndSrc,
Original file line number Diff line number Diff line change 5
5
var path = require ( 'path' )
6
6
var parse = require ( './parser' )
7
7
var loaderUtils = require ( 'loader-utils' )
8
- var { defaultStylePart } = require ( './mp-compiler/util' )
8
+ var { defaultPart } = require ( './mp-compiler/util' )
9
9
10
10
module . exports = function ( content ) {
11
11
this . cacheable ( )
@@ -17,6 +17,6 @@ module.exports = function (content) {
17
17
if ( Array . isArray ( part ) ) {
18
18
part = part [ query . index ]
19
19
}
20
- part = part || defaultStylePart
20
+ part = part || defaultPart ( 'style' )
21
21
this . callback ( null , part . content , part . map )
22
22
}
You can’t perform that action at this time.
0 commit comments