Firstly, I understand text/babel
is not for use in production, but I found it quite useful for development as when I make a change to my .jsx
file
Without diving too deeply into the Babel source (looking at https://github.com/babel/babel/blob/master/packages/babel/src/api/browser.js), I'm going to guess that it reads your JSX source, performs transformation on the source, and then eval
s the source in some way to execute it. The scope is not shared because babel prepends 'use strict';
to the transformed code (standard in ES6).
If you really need to expose a variable, you can attach it to window
(ie use window.mything
in your JSX instead of just mything
). Ideally, you should make use of modules as you split your code up into multiple files. You can make use of a build step to transform your code through Babel and use browserify/webpack to manage dependencies.