Skip to content

Develop #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/mp-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down