Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

fix #205 by upgrading postcss libraries #236

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var insertCSSPath = normalize.lib('insert-css')

var hasBabel = true
try {
require('babel-core')
require('@babel/core')
} catch (e) {
hasBabel = false
}
Expand Down Expand Up @@ -86,8 +86,8 @@ compiler.compile = function (content, filePath, cb) {
].concat(parts.styles.map(function (style) {
return processStyle(style, filePath, id, resolvedParts)
})))
.then(mergeParts)
.catch(cb)
.then(mergeParts)
.catch(cb)

function mergeParts () {
// check whether script/template has changed
Expand Down
7 changes: 3 additions & 4 deletions lib/compilers/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ var assign = require('object-assign')
var ensureRequire = require('../ensure-require')

var defaultBabelOptions = {
presets: ['es2015'],
plugins: ['transform-runtime']
presets: ['@babel/preset-env']
}

var babelRcPath = path.resolve(process.cwd(), '.babelrc')
Expand All @@ -27,7 +26,7 @@ function getBabelRc () {
module.exports = function (raw, cb, compiler, filePath) {
if ((compiler.options.babel || babelOptions) === defaultBabelOptions) {
try {
ensureRequire('babel', ['babel-preset-es2015', 'babel-runtime', 'babel-plugin-transform-runtime'])
ensureRequire('babel', ['@babel/preset-env'])
} catch (e) {
console.error(e.message)
console.error(
Expand All @@ -39,7 +38,7 @@ module.exports = function (raw, cb, compiler, filePath) {
}

try {
var babel = require('babel-core')
var babel = require('@babel/core')
var options = assign({
comments: false,
filename: filePath,
Expand Down
4 changes: 2 additions & 2 deletions lib/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.lib = function (file) {
if (IS_TEST) {
return path.resolve(__dirname, file)
} else {
return 'vueify/lib/' + file
return '@nymag/vueify/lib/' + file
}
}

Expand All @@ -15,7 +15,7 @@ exports.dep = function (dep) {
return dep
} else if (fs.existsSync(path.resolve(__dirname, '../node_modules', dep))) {
// npm 2 or npm linked
return 'vueify/node_modules/' + dep
return '@nymag/vueify/node_modules/' + dep
} else {
// npm 3
return dep
Expand Down
6 changes: 3 additions & 3 deletions lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var addId = postcss.plugin('add-id', function () {
attribute: currentId
}))
})
}).process(node.selector).result
}).processSync(node)
})
}
})
Expand All @@ -46,13 +46,14 @@ module.exports = function (id, css, scoped, options) {
return Promise.resolve(val)
} else {
var plugins = []
var opts = {}
var opts = { from: 'source' }

if (options.postcss instanceof Array) {
plugins = options.postcss.slice()
} else if (options.postcss instanceof Object) {
plugins = options.postcss.plugins || []
opts = options.postcss.options
opts.from = opts.from || 'source'
}

// scoped css rewrite
Expand Down Expand Up @@ -81,4 +82,3 @@ module.exports = function (id, css, scoped, options) {
})
}
}

Loading