Babel support
See original GitHub issueIn most of my projects that are not performance critical I am using Babel. Just tried out nexe on one of these projects but it has issues at least with ES7 syntax, e.g. module.exports = async function (cmdArgs) {.
The file that I am building has babel defined as follows:
//run.js
require('babel/register')({
experimental: true,
loose: true
});
var nodegitFile = require('./nodegit');
nodegitFile(['tests/fixtures/example.txt']);
and running node run.js works fine.
The error I am getting on nexe -i run.js is:
----> bundle project/blame-history/run.js
events.js:141
throw er; // Unhandled 'error' event
^
Error: Parsing file project/blame-history/nodegit.js: Unexpected token (5:23)
at Deps.parseDeps (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/index.js:418:28)
at fromSource (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/index.js:361:48)
at /Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/index.js:356:17
at ConcatStream.<anonymous> (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/node_modules/concat-stream/index.js:32:43)
at emitNone (events.js:72:20)
at ConcatStream.emit (events.js:163:7)
at finishMaybe (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:460:14)
at endWritable (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:469:3)
at ConcatStream.Writable.end (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:436:5)
at Transform.onend (/Users/markus/npm/lib/node_modules/nexe/node_modules/module-deps/node_modules/readable-stream/lib/_stream_readable.js:523:10)
Any chance to get nexe to support Babel?
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Babel · The compiler for next generation JavaScript
Babel is a JavaScript compiler. · Put in next-gen JavaScript · Get browser-compatible JavaScript out · Current Sponsors · Base Support · Gold...
Read more >Babel is a compiler for writing next generation JavaScript.
Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain features...
Read more >General Support Functionality — Babel 2.11.0 documentation
Babel ships a few general helpers that are not being used by Babel itself but are useful in combination with functionality provided by...
Read more >Documentation - Using Babel with TypeScript
How to create a hybrid Babel + TypeScript project. ... By using babel's support for TypeScript, you get the ability to work with...
Read more >Tooling - styled-components
Babel Plugin. This plugin adds support for server-side rendering, minification of styles, and a nicer debugging experience.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

For anyone else that stumbles here wondering how to package up newer js here is an approach that will work.
tl;dr; use webpack to create a single js file and package that with nexe
Use webpack to create a single js file starting from some entry point.
Below is a
webpack.config.jsthat I used.You will need to ensure you have the correct dependencies in your
package.json. Here is an example from mine.In my case
cli.jswas my entrypoint. Webpack will “follow” your import or require expressions and you will end up with a single file/tmp/build.jswhich is all of the code for your CLI app packaged up in a single js file.With the above config file, run the webpack CLI command per usual. It will produce
/tmp/build.jswhich is your entire app as a single js file suitable for running with node. (i.e.node /tmp/build.jsto test it).I have not taken the step to actually package it with nexe (since having a single JS file was good enough for my use case) but it should be relatively straight forward to do so with the final js file.
Bundling is decoupled from nexe in
nexe@beta