n-riesco / jp-babel Goto Github PK
View Code? Open in Web Editor NEWjp-babel is a babel kernel for the Jupyter notebook
License: Other
jp-babel is a babel kernel for the Jupyter notebook
License: Other
When I run jp-babel
I get the following error. The '/usr/local/lib/node_modules/jp-babel/' directory exists, but there is obviously no 'images' subdirectory...not sure why it's looking one...
$ jp-babel
events.js:141
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/jp-babel/images/logo-32x32.png'
at Error (native)
Consider a typo like the following:
% jupyter console --kernel=babel
KERNEL: SHELL_SOCKET: Unhandled message type: history_request
Jupyter console 5.1.0
jp-babel v0.2.0
https://github.com/n-riesco/jp-babel
In [1]: if (3 == 4) ( console.log('wow'); }
SyntaxError: unknown: Unexpected token, expected , (1:32)
> 1 | if (3 == 4) ( console.log('wow'); }
| ^
and then you can hit Ctrl-C all you like, but nothing works and you basically have to kill the process.
This issue is not present in IJavascript:
% jupyter console --kernel=javascript
KERNEL: SHELL_SOCKET: Unhandled message type: history_request
Jupyter console 5.1.0
IJavascript v5.0.17
https://github.com/n-riesco/ijavascript
In [1]: if (3 == 4) ( console.log('wow'); }
SyntaxError: Unexpected token ;
at Object.exports.runInThisContext (vm.js:53:16)
at run ([eval]:613:19)
at onRunRequest ([eval]:384:22)
at onMessage ([eval]:352:17)
at emitTwo (events.js:87:13)
at process.emit (events.js:172:7)
at handleMessage (internal/child_process.js:695:10)
at Pipe.channel.onread (internal/child_process.js:440:11)
In [2]:
where you get back the shell prompt and can fix your typo and continue to work.
Invalid code should return is_complete_reply.status: 'invalid'
.
Moved from #13 (comment) .
I've been using this for a few weeks now with the Hydrogen plugin for Atom and it's working great, but when trying to add a babel plugin in .babelrc jp-babel doesn't seem to find it:
{ "plugins": ["syntax-flow"] }
I tried both project local and global plugin installation, as well as putting .babelrc in the project root and $HOME, doesn't make a difference.
Am I missing something here, any way to make this work?
Jupyter lab seems to be cool kid on the block with the intention to "eventually replace the classic Jupyter Notebook."
From what I checked switching over to lab is literally as easy as replacing "notebook" with "lab" in "bin/rc.js"
Thoughts?
Hi there,
It would be nice to be able to use the new async/await syntax. Could it be as simple as wrapping the REPL as mentioned here? tc39/proposal-async-await#9 (comment)
Cheers,
Jun
See #1 for an initial report.
This bug is triggered when babel-preset-es2015
is installed as a nested dependency.
To work around this issue, install jp-babel
along with babel-preset-es2015
:
npm install jp-babel babel-preset-es2015
Follow up from #9 (comment)
I upgraded the babel dependencies when working on #9 and encountered You gave us a visitor for the node type "ForAwaitStatement" but it's not a valid type
when trying to use async/await in a cell. Doing a git clean -xfd && npm install
resolved it for me.
Another issue that is somewhat related is the Error: Module version mismatch. Expected 48, got 47.
error that occurs when jp-babel is installed with one version of Node and used with another without rebuilding. There is an open issue on ijavascript: n-riesco/ijavascript#76
Sorry @n-riesco for spamming... One last issue I promise.
I installed jp-babel without any issue, but I just can't get hydrogen to run on Babel ES6 Javascript (powered by language-babel package in Atom), and the kernel is properly registered. Since jp-babel use babel-preset-2015
and ES6=ES2015, I thought I don't have to do any setting. It should just work after installation, right?
Where all can I place a .babelrc?
I'm assuming that ~/.babelrc works; but I generally don't want to set even user globals.
cat >> $path/.babelrc << EOF
See also: #24
jp-babel seems to take about 10-15 seconds on the first eval with a fresh kernel (even on something simple as 1+2) as opposed to ijavascript's almost immediate evaluation.
Any way to speed this up?
In case it is helpful to others, here is the .babelrc
file that I am using with this kernel to get TypeScript and React working:
{
"presets": [
"@babel/react",
[
"@babel/typescript",
{
"isTSX": true,
"allExtensions": true,
"allowNamespaces": true
}
]
]
}
Which paths for the .babelrc are supported?
Originally posted by @westurner in #24 (comment)
Just installed jp-babel kernel, started a new notebook. Then the kernel died:
Error: EACCES: permission denied, scandir '/store/mycomputer/datastore'
at Object.fs.readdirSync (fs.js:904:18)
at findFile (/store/mycomputer/datastore/myusername/programs/jupyter/node_modules/jp-babel/lib/kernel.js:100:21)
at findFile (/store/mycomputer/datastore/myusername/programs/jupyter/node_modules/jp-babel/lib/kernel.js:110:12)
at findFile (/store/mycomputer/datastore/myusername/programs/jupyter/node_modules/jp-babel/lib/kernel.js:110:12)
at Object.<anonymous> (/store/mycomputer/datastore/myusername/programs/jupyter/node_modules/jp-babel/lib/kernel.js:84:19)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
It looks like jp-babel traverses up the directories in order to find a .babelrc
.
$ ls -l /store/mycomputer/datastore
ls: cannot open directory '/store/mycomputer/datastore': Permission denied
$ ls -ld /store/mycomputer/datastore
drwx--x--x 9 root root 4096 Jan 4 15:41 /store/mycomputer/datastore
This is how things are on the computer I'm currently at. I guess we can't assume all parent dirs are accessible.
$ jp-babel --version
1.1.3
$ npx npm --version
5.6.0
$ npx ipython --version
6.2.1
$ lsb_release -sd
"openSUSE Leap 42.3"
If imported modules are referenced outside of the cells where they're imported, they're undefined
:
// In[1]
import infer from 'json-schema-generator';
// In[2]
infer
// ReferenceError: infer is not defined
// at evalmachine.<anonymous>:3:1
// at ContextifyScript.Script.runInThisContext (vm.js:25:33)
// at Object.exports.runInThisContext (vm.js:77:17)
// at run ([eval]:608:19)
// at onRunRequest ([eval]:379:22)
// at onMessage ([eval]:347:17)
// at emitTwo (events.js:106:13)
// at process.emit (events.js:191:7)
// at process.nextTick (internal/child_process.js:744:12)
// at _combinedTickCallback (internal/process/next_tick.js:67:7)
Hello!
Thanks for your work thus far on this. The error I'm encountering happens when requiring an es6 sub module inside a jp-babel notebook session.
For example, if I have a file called my-module.js
which contains a destructured assignment:
const {a} = {a: 'val'};
module.exports = a;
and I require it in the notebook with this statement: const m = require('my-module');
it will generate the following error:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at loader (/usr/local/lib/node_modules/jp-babel/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/jp-babel/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at evalmachine.<anonymous>:3:17
at Object.exports.runInThisContext (vm.js:54:17)
however, if I change my-module.js
to:
const b = {a: 'val'}, a = b.a;
module.exports = a;
I can require it successfully in the notebook. For some reason the const
variable declaration is fine, but the destructered assignment isn't. However, destructured assignment works fine if I do it within the notebook.
I'm confused as to why all es6 features will work in the notebook, but the only es6 feature that seems to work in a submodule required within the notebook is const
. If the required submodules weren't being babel compiled I would expect the supported es6 features to be all or nothing.
Also, default variables (such as function test(a='value'){}
) work within the notebook, but throws this error when they're included in a submodule:
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at loader (/usr/local/lib/node_modules/jp-babel/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/jp-babel/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at evalmachine.<anonymous>:3:17
at Object.exports.runInThisContext (vm.js:54:17)
hopefully this is easily reproducible. Once again, thank you for your work on this thus far, it's been really useful for me in my work.
hi,
My current project requires babel7 but it seems to be not supported by jp-babel. Is there is any solution to make it works with babel 7?
I really appreciate this package, it saves a lot of my time.
import * from "module"
Works fine and always return 'use strict', that's ok.
But import * from "**./**module"
always fails if contains es6 features.
This should be alike with n-riesco/jp-coffeescript@52ea3b4
@n-riesco I'm not familiar with babel, so I can't fix it by myself corectlly.
When you run multiple cells by 'run all', the output of all cells is shown for the last one. I.e. when you use console.log(). Not sure if this is related but a
function () {}
evaluation returns 'use strict'
. Is this intended?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.