question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using babelify with new scoped packages

See original GitHub issue

Today I installed the new scoped packages of babel, e.g. @babel/core etc., including the plugins, e.g. @babel/plugin-proposal-pipeline-operator etc. However, babelify@8 still requires the ‘old’ babel-core package, AFAICT. I first installed babel-core@6 by accident, which had problems with the new .babelrc plugin syntax (before it would prefix babel-plugin- to get the package, I think; now it’d need to add plugin- between @babel/ and the plugin name).

However, babel-core@7.0.0-beta.3, the latest I could find, gave the following error instead:

/home/larsw/project_dir/node_modules/babelify/index.js:65
  if (!babel.util.canCompile(filename, extensions)) {
                  ^

TypeError: Cannot read property 'canCompile' of undefined
  at /home/larsw/project_dir/node_modules/babelify/index.js:65:21
  at Babelify (/home/larsw/project_dir/node_modules/babelify/index.js:10:36)
  at nr (/home/larsw/project_dir/node_modules/module-deps/index.js:301:23)
  at onfile (/home/larsw/project_dir/node_modules/resolve/lib/async.js:56:21)
  at onex (/home/larsw/project_dir/node_modules/resolve/lib/async.js:104:32)
  at /home/larsw/project_dir/node_modules/resolve/lib/async.js:24:24
  at FSReqWrap.oncomplete (fs.js:153:5)

Note: I’m not sure if it’s possible to use babelify with the new scoped packages at all.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
noygalcommented, Nov 14, 2017

I’ve open PR for this issue: https://github.com/babel/babelify/pull/252

Meanwhile you can replace the package with my package:

"dependencies": {
    "@babel/core": "^7.0.0-beta.3",
    "@babel/preset-env": "^7.0.0-beta.32",
    "babel-core": "^6.26.0",
    "babelify": "git+https://github.com/noygal/babelify.git#feature/babel-7-support",
  }

And use the new options babel to pass your own babel package:

browserify().transform('babelify', {
  presets: ['@babel/preset-env'],
  babel: require('@babel/core')
})
2reactions
niftylettucecommented, Dec 26, 2017

Can we get this merged please? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Henry on Twitter: "we're just modifying like every file in the repo ...
Using scoped packages means that you will need to make a one time change of "@babel/env" instead of ... gulp-babel -> @babel/gulp, babelify...
Read more >
Consuming ES6 modules in NPM packages Adventures in brine
I think you can already see how useful our new package is going to be. CleverClass is pretty unexceptional, except for the addition...
Read more >
babelify transformation on JSX for React element failing
I am new to React.js and trying out some examples. I have the following code in my js file: var React = require('react'); ......
Read more >
Babel · The compiler for next generation JavaScript - Babel.js
As of Meteor 1.2, the ecmascript package is installed by default for all new apps. meteor add ecmascript. Copy. npm install --save-dev @babel/register ......
Read more >
Getting import/export working ES6 style using Browserify + ...
If you want to use ES6 modules, you'll need Babel/Babelify to convert your ES6 code into ES5, such that Browserify can understand it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found