From 0b87fed3266952fe258e97ff730aa731230a49ca Mon Sep 17 00:00:00 2001 From: anchengjian Date: Sat, 10 Mar 2018 21:55:26 +0800 Subject: [PATCH 1/2] fix: extend babelrc --- lib/mp-compiler/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mp-compiler/index.js b/lib/mp-compiler/index.js index 1b77394..39e82f7 100644 --- a/lib/mp-compiler/index.js +++ b/lib/mp-compiler/index.js @@ -2,6 +2,7 @@ const compiler = require('mpvue-template-compiler') const htmlBeautify = require('js-beautify').html +const path = require('path') const babel = require('babel-core') const { parseConfig, parseComponentsDeps } = require('./parse') const { genScript, genStyle, genPageWxml } = require('./templates') @@ -91,7 +92,8 @@ function compileWxml (compiled, html) { // 针对 .vue 单文件的脚本逻辑的处理 // 处理出当前单文件组件的子组件依赖 function compileMPScript (script, optioins, moduleId) { - const { metadata } = babel.transform(script.content, { plugins: [parseComponentsDeps] }) + const babelrc = optioins.globalBabelrc ? optioins.globalBabelrc : path.resolve('./.babelrc') + const { metadata } = babel.transform(script.content, { extends: babelrc, plugins: [parseComponentsDeps] }) // metadata: importsMap, components const { importsMap, components: originComponents } = metadata @@ -135,7 +137,9 @@ const startPageReg = /^\^/ function compileMP (content, optioins) { const { resourcePath, emitError, emitFile, emitWarning, resolve, context } = this - const { metadata } = babel.transform(content, { plugins: [parseConfig] }) + + const babelrc = optioins.globalBabelrc ? optioins.globalBabelrc : path.resolve('./.babelrc') + const { metadata } = babel.transform(content, { extends: babelrc, plugins: [parseConfig] }) // metadata: config const { config, rootComponent } = metadata From fd3316f5245d4ad053befc299c0a707574a3a6f1 Mon Sep 17 00:00:00 2001 From: anchengjian Date: Sat, 10 Mar 2018 22:46:14 +0800 Subject: [PATCH 2/2] new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ccdfee4..08ad212 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mpvue-loader", - "version": "1.0.1", + "version": "1.0.2", "description": "mpvue single-file component loader for Webpack", "main": "index.js", "repository": {