ReferenceError: [BABEL] item.vue: Unknown option: foreign._. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name.
Vueify in vueify/lib/compilers/babel.js passes options to babel.transform(raw, options) in wrong format presets: { _: [ 'env' ] } which is created by minimist via subarg in browserify instead of correct format presets: [ 'env' ].
For example babelify transform works well with the similar command:
$ browserify -t [ babelify --presets [ env ] ] -e main.js -o build.js
... this syntax comes directly from babelify doc at npmjs.com
In babelify it is working thanks to following code in babelify/index.js in Babelify.configure():
// add this after line "`var babel = require('babel-core')"
var opts = compiler.options.babel
if (opts) {
delete opts._
// "--opt [ a b ]" and "--opt a --opt b" are allowed:
if (opts.ignore && opts.ignore._) opts.ignore = opts.ignore._
if (opts.only && opts.only._) opts.only = opts.only._
if (opts.plugins && opts.plugins._) opts.plugins = opts.plugins._
if (opts.presets && opts.presets._) opts.presets = opts.presets._
}
Vueify transform passes incorrect format of options object to babel...
$ browserify -t [ vueify --babel [ --presets [ env ] ] ] -e main.js -o build.js
Vueify in vueify/lib/compilers/babel.js passes options to
babel.transform(raw, options)
in wrong formatpresets: { _: [ 'env' ] }
which is created byminimist
viasubarg
in browserify instead of correct formatpresets: [ 'env' ]
.For example babelify transform works well with the similar command:
$ browserify -t [ babelify --presets [ env ] ] -e main.js -o build.js
... this syntax comes directly from babelify doc at npmjs.comIn babelify it is working thanks to following code in babelify/index.js in Babelify.configure():
This issue can be fixed by adding following code in vueify/lib/compilers/babel.js:
PR: https://github.com/vuejs/vueify/pull/235