@@ -87,7 +87,7 @@ function compileMPML (compiled, html, options) {
8787 emitError : this . emitError ,
8888 emitFile : this . emitFile ,
8989 resourcePath : this . resourcePath ,
90- context : this . options . context ,
90+ context : this . _compiler . options . context ,
9191 rootComponent : null ,
9292 compiled, html,
9393 fileExt
@@ -98,7 +98,8 @@ function compileMPML (compiled, html, options) {
9898// 针对 .vue 单文件的脚本逻辑的处理
9999// 处理出当前单文件组件的子组件依赖
100100function compileMPScript ( script , mpOptioins , moduleId ) {
101- const { resourcePath, options, resolve, context } = this
101+ // enhance: 兼容新版webpack4,options在this._compiler中
102+ const { resourcePath, _compiler : { options } , resolve, context } = this
102103 const babelrc = getBabelrc ( mpOptioins . globalBabelrc )
103104
104105 let scriptContent = script . content
@@ -140,7 +141,8 @@ function compileMPScript (script, mpOptioins, moduleId) {
140141// checkMPEntry 针对 entry main.js 的入口处理: 编译出 app, page 的入口js、mpml、json
141142let globalComponents
142143function compileMP ( content , mpOptioins ) {
143- const { resourcePath, emitFile, resolve, context, options } = this
144+ // enhance: 兼容新版webpack4,options在this._compiler中
145+ const { resourcePath, emitFile, resolve, context, _compiler : { options } } = this
144146 const fileInfo = resolveTarget ( resourcePath , options . entry )
145147 cacheFileInfo ( resourcePath , fileInfo )
146148 const { isApp, isPage } = fileInfo
@@ -193,7 +195,8 @@ function compileMP (content, mpOptioins) {
193195 resolve ( context , rootComponent , ( err , rootComponentSrc ) => {
194196 if ( err ) return
195197 // 这儿需要搞定 根组件的 路径
196- createPageMPML ( emitFile , resourcePath , rootComponentSrc , this . options . context , mpOptioins . fileExt )
198+ // enhance: 兼容新版webpack4,options在this._compiler中
199+ createPageMPML ( emitFile , resourcePath , rootComponentSrc , this . _compiler . options . context , mpOptioins . fileExt )
197200 } )
198201 }
199202 }
0 commit comments