luisfarzati / express-babelify-middleware

Start developing ES6 in the browser right away, without any build setup
MIT License
24 stars 3 forks source link

Not compatible with @babel packages #8

Open sir-dunxalot opened 5 years ago

sir-dunxalot commented 5 years ago

This library does not seem to be compatible with Babel ^7.0.0 (e.g. @babel/core). When I updated Babel from 6.x to 7.x in my app, the following error message appeared:

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core
Here is the full stack trace: ``` web_1 | 2018-11-28T19:39:21.013Z grader Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel. (While processing preset: "/usr/src/web/node_modules/@babel/preset-env/lib/index.js") while parsing file: /usr/src/web/src/views/routes/results/new/view.js web_1 | at throwVersionError (/usr/src/web/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11) web_1 | at Object.assertVersion (/usr/src/web/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11) web_1 | at _default (/usr/src/web/node_modules/@babel/preset-env/lib/index.js:154:7) web_1 | at /usr/src/web/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12 web_1 | at /usr/src/web/node_modules/babel-core/lib/transformation/file/options/option-manager.js:317:46 web_1 | at Array.map () web_1 | at OptionManager.resolvePresets (/usr/src/web/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) web_1 | at OptionManager.mergePresets (/usr/src/web/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) web_1 | at OptionManager.mergeOptions (/usr/src/web/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) web_1 | at OptionManager.init (/usr/src/web/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) web_1 | at File.initOptions (/usr/src/web/node_modules/babel-core/lib/transformation/file/index.js:212:65) web_1 | at new File (/usr/src/web/node_modules/babel-core/lib/transformation/file/index.js:135:24) web_1 | at Pipeline.transform (/usr/src/web/node_modules/babel-core/lib/transformation/pipeline.js:46:16) web_1 | at Babelify._flush (/usr/src/web/node_modules/babelify/index.js:27:24) web_1 | at Babelify.prefinish (_stream_transform.js:137:10) web_1 | at emitNone (events.js:106:13) web_1 | at Babelify.emit (events.js:208:7) web_1 | at prefinish (_stream_writable.js:603:14) web_1 | at finishMaybe (_stream_writable.js:611:5) web_1 | at endWritable (_stream_writable.js:622:3) web_1 | at Babelify.Writable.end (_stream_writable.js:573:5) web_1 | at DuplexWrapper. (/usr/src/web/node_modules/duplexer2/index.js:29:14) web_1 | at Object.onceWrapper (events.js:313:30) web_1 | at emitNone (events.js:111:20) web_1 | at DuplexWrapper.emit (events.js:208:7) ```
sir-dunxalot commented 5 years ago

I was able to work around this issue by using the browserify-middleware and babelify packages instead of express-babelify-middleware:

import { Router } from 'express';
import browserify from 'browserify-middleware';

const router = Router();

const route = browserify('views/contact/view.js', {
  transform: ['babelify'],
});

router.get('/contact', route);