File tree Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Expand file tree Collapse file tree 3 files changed +23
-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 @@ -128,23 +128,25 @@ function getPathPrefix (src) {
128
128
return `${ '../' . repeat ( length ) } `
129
129
}
130
130
131
- const defaultStylePart = {
132
- type : 'style' ,
133
- content : '\n' ,
134
- start : 0 ,
135
- attrs : { } ,
136
- end : 1 ,
137
- map : {
138
- version : 3 ,
139
- sources : [ ] ,
140
- names : [ ] ,
141
- mappings : '' ,
142
- sourcesContent : [ ]
131
+ const defaultPart = type => {
132
+ return {
133
+ type,
134
+ content : '\n' ,
135
+ start : 0 ,
136
+ attrs : { } ,
137
+ end : 1 ,
138
+ map : {
139
+ version : 3 ,
140
+ sources : [ ] ,
141
+ names : [ ] ,
142
+ mappings : '' ,
143
+ sourcesContent : [ ]
144
+ }
143
145
}
144
146
}
145
147
146
148
module . exports = {
147
- defaultStylePart ,
149
+ defaultPart ,
148
150
cacheFileInfo,
149
151
getFileInfo,
150
152
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