File tree Expand file tree Collapse file tree 5 files changed +24
-19
lines changed Expand file tree Collapse file tree 5 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ var hasBuble = !!tryRequire('buble-loader')
2424
2525// for mp js
2626var { compileMP, compileMPScript } = require ( './mp-compiler' )
27- var { defaultStylePart } = require ( './mp-compiler/util' )
27+ var { defaultPart } = require ( './mp-compiler/util' )
2828
2929var rewriterInjectRE = / \b ( c s s (?: - l o a d e r ) ? (?: \? [ ^ ! ] + ) ? ) (?: ! | $ ) /
3030
@@ -103,7 +103,11 @@ module.exports = function (content) {
103103
104104 // fix #153: 根组件没有 style 模块,不生成页面的 wxss,补齐内容方便加载 vendor.wxss
105105 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' )
107111 }
108112
109113 var hasScoped = parts . styles . some ( function ( s ) { return s . scoped } )
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function delint (sourceFile) {
5757 switch ( node . kind ) {
5858 case ts . SyntaxKind . ImportDeclaration :
5959 // 只处理 import Comp from 'xxx.vue'
60- if ( node . importClause . name ) {
60+ if ( node . importClause && node . importClause . name ) {
6161 importsMap [ node . importClause . name . escapedText ] = node . moduleSpecifier . text
6262 }
6363 // report(node, 'import')
Original file line number Diff line number Diff line change @@ -121,23 +121,24 @@ function getBabelrc (src) {
121121 return ''
122122}
123123
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 : [ ]
136137 }
137138}
138139
139140module . exports = {
140- defaultStylePart ,
141+ defaultPart ,
141142 cacheFileInfo,
142143 getFileInfo,
143144 getCompNameAndSrc,
Original file line number Diff line number Diff line change 55var path = require ( 'path' )
66var parse = require ( './parser' )
77var loaderUtils = require ( 'loader-utils' )
8- var { defaultStylePart } = require ( './mp-compiler/util' )
8+ var { defaultPart } = require ( './mp-compiler/util' )
99
1010module . exports = function ( content ) {
1111 this . cacheable ( )
@@ -17,6 +17,6 @@ module.exports = function (content) {
1717 if ( Array . isArray ( part ) ) {
1818 part = part [ query . index ]
1919 }
20- part = part || defaultStylePart
20+ part = part || defaultPart ( 'style' )
2121 this . callback ( null , part . content , part . map )
2222}
Original file line number Diff line number Diff line change 11{
22 "name" : " mpvue-loader" ,
3- "version" : " 1.1.2 " ,
3+ "version" : " 1.1.3 " ,
44 "description" : " mpvue single-file component loader for Webpack" ,
55 "main" : " index.js" ,
66 "repository" : {
You can’t perform that action at this time.
0 commit comments