babel / babel-standalone

:video_game: Now located in the Babel repo! Standalone build of Babel for use in non-Node.js environments, including browsers.
https://github.com/babel/babel/tree/master/packages/babel-standalone
MIT License
819 stars 121 forks source link

Require is not supported in the browser.. #71

Closed jonysy closed 7 years ago

jonysy commented 7 years ago

Full message:

Require is not supported in the browser, you need a commonjs environment such as node.js/io.js, browserify/webpack etc

What needs to be done to get this to work?

import { foo } from "./bar";
loganfsmyth commented 7 years ago

You cannot use babel-standalone in this case. babel-standalone is able to compile individual files, but it has no support for modular code. For modules to work, you would need to use a normal Babel workflow using something like Webpack or Browserify to bundle all of your files into a single file to execute in the browser.

jonysy commented 7 years ago

Thank you, Logan :)