Giter Club home page Giter Club logo

babel-standalone's Introduction

babel-standalone is now part of babel! Go check it out ⚠️⚠️⚠️⚠️

babel-standalone

babel-standalone is a standalone build of Babel for use in non-Node.js environments, including browsers. It's bundled with all the standard Babel plugins and presets, and a build of babili (babel-minify) is optionally available too.

But why?!

It's true that using Babel through Webpack, Browserify or Gulp should be sufficient for most use cases. However, there are some valid use cases for babel-standalone:

  • Sites like JSFiddle, JS Bin, the REPL on the Babel site, etc. These sites compile user-provided JavaScript in real-time.
  • Apps that embed a JavaScript engine such as V8 directly, and want to use Babel for compilation
  • Apps that want to use JavaScript as a scripting language for extending the app itself, including all the goodies that ES2015 provides.
  • Integration of Babel into a non-Node.js environment (ReactJS.NET, ruby-babel-transpiler, php-babel-transpiler, etc).

Installation

There are several ways to get a copy of babel-standalone. Pick whichever one you like:

  • Use it via UNPKG: https://unpkg.com/babel-standalone@6/babel.min.js. This is a simple way to embed it on a webpage without having to do any other setup.
  • Install via Bower: bower install babel-standalone
  • Install via NPM: npm install --save babel-standalone
  • Manually grab babel.js and/or babel.min.js from the GitHub releases page. Every release includes these files.
  • Install it via Git: You can use the repo at https://github.com/Daniel15/babel-standalone-bower to pull a prebuilt version from Git. Note that this is generally only advised for systems that must pull artifacts from Git, such as Bower.

Usage

Load babel.js or babel.min.js in your environment. This will expose Babel's API in a Babel object:

var input = 'const getMessage = () => "Hello World";';
var output = Babel.transform(input, { presets: ['es2015'] }).code;

When loaded in a browser, babel-standalone will automatically compile and execute all script tags with type text/babel or text/jsx:

<div id="output"></div>
<!-- Load Babel -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Your custom script here -->
<script type="text/babel">
const getMessage = () => "Hello World";
document.getElementById('output').innerHTML = getMessage();
</script>

You can use the data-plugins and data-presets attributes to specify the Babel plugins/presets to use:

<script type="text/babel" data-presets="es2015,stage-2">

Loading external scripts via src attribute is supported too:

<script type="text/babel" src="foo.js"></script>

Note that .babelrc doesn't work in babel-standalone, as no file system access is available. The presets and/or plugins to use must be specified in the options passed to Babel.transform.

Customisation

Custom plugins and presets can be added using the registerPlugin and registerPreset methods respectively:

// Simple plugin that converts every identifier to "LOL"
function lolizer() {
  return {
    visitor: {
      Identifier(path) {
        path.node.name = 'LOL';
      }
    }
  }
}
Babel.registerPlugin('lolizer', lolizer);

Once registered, just use the name of the plugin:

var output = Babel.transform(
  'function helloWorld() { alert(hello); }',
  {plugins: ['lolizer']}
);
// Returns "function LOL() { LOL(LOL); }"

Custom plugins also work for inline <script>s:

<script type="text/babel" data-plugins="lolizer">

Manually Building

If you want to manually upgrade the Babel version used by babel-standalone (or build your own release), follow these steps:

  1. Upgrade the Babel versions in package.json. This can be done with npm-check-upgrades (eg. npm-check-updates -u -a --packageFile ./package.json /^babel\-/)
  2. Delete node_modules, as npm often produces inefficient directory layouts if you upgrade in-place
  3. Run npm install && npm run build
  4. Run npm run test to ensure it works
  5. Open examples/example.htm and ensure it works

babel-standalone's People

Contributors

cansin avatar danbuild avatar daniel15 avatar ghoullier avatar greenkeeperio-bot avatar hzoo avatar jeffrafter avatar jetiny avatar jochenberger avatar miclaus avatar mweststrate avatar ngyikp avatar ssergiienko avatar taion avatar tpetricek avatar zzmingo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

babel-standalone's Issues

Auto-update script doesn't handle UTF-8 characters correctly

At first I thought this was a bug in my JS runtime, but the minified script doesn't parse in Node either.

C:\Users\fatce\Desktop>node babel.min.js
C:\Users\fatce\Desktop\babel.min.js:6
},e.prototype.setData=function(e,t){return this.data[e]=t},e.prototype.getData=function(e){var t=this;do{var r=t.data[e];if(null!=r)return r}while(t=t.parent)},e.prototype.removeData=function(e){var t=this;do{var r=t.data[e];null!=r&&(t.data[e]=null)}while(t=t.parent)},e.prototype.init=function(){this.references||this.crawl()},e.prototype.crawl=function(){M++,this._crawl(),M--},e.prototype._crawl=function(){var e=this.path;if(this.references=(0,c.default)(null),this.bindings=(0,c.default)(null),this.globals=(0,c.default)(null),this.uids=(0,c.default)(null),this.data=(0,c.default)(null),e.isLoop())for(var t=R.FOR_INIT_KEYS,r=Array.isArray(t),n=0,t=r?t:(0,v.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i,a=e.get(s);a.isBlockScoped()&&this.registerBinding(a.node.kind,a)}if(e.isFunctionExpression()&&e.has("id")&&(e.get("id").node[R.NOT_LOCAL_BINDING]||this.registerBinding("local",e.get("id"),e)),e.isClassExpression(
SyntaxError: Invalid or unexpected token
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

The unminified script is fine.

Using the plugin throws an error

I'm experimenting with your module in browser and I would like to use transform-runtime plugin. However for now it's impossible 'cause an error is thrown - Uncaught ReferenceError: require is not defined. It points to this line - var _regenerator = require('babel-runtime/regenerator'); which is the code of plugin itself. Does this mean that your module needs deeply include/require all dependencies in order to be available in browser?

My code looks like:

var options = { presets: ['es2015', 'react', 'stage-0'], plugins: ['transform-runtime'] };
var output = Babel.transform('let a = 2', options).code;

Thanks!

long term solution to packaging babel

hi Daniel,
probably you and I are the only ones interested in this conversation (babel/babel@c0afdfd). do you think Requirejs is a viable long term solution for people looking at a pure browser based flow ?

or do you think we should start looking at alternatives. I'm not sure if you will maintain babel-standalone in the long term.

Automatic builds of latest (or all) Babel versions

Hey,

I also think having this browser.js functionality is great for client only prototyping and examples on the web, so would be great to keep it running.

But it's not reasonable to keep this up to date manually, so maybe a good automatised build chain could take care of things? So I'm thinking something along the lines of GreenKeeper creating PRs of new versions of Babel, Travis building a bundle and CDNJS hosting all versions.

Is this something you'd be up for setting up? I wouldn't mind lending a hand and I'm sure others would be happy to chip in. All these services I mentioned should be free for open source projects.

Support link preload to fix browsers that prevent fetching scripts with an invalid type attribute

When using the following syntax:

  <script type="text/babel" src="src/main.js"></script>

On Chrome 55, the console displays this error:

Fetching scripts with an invalid type/language attributes is deprecated and will be removed in M56, around January 2017. See https://www.chromestatus.com/features/5760718284521472 for more details.

There are more details here: https://www.chromestatus.com/feature/5760718284521472

The suggested approach is to use link preload, which I presume would be something like this:

  <link rel="preload" href="src/main.js" as="script" data-babel="es2015,stage-3">

Async/await plugin

Hello,
It might be a noob question, but is there a way to use a plugin for async/await in browser environment with babel standalone? Is babel standalone extendable?
And if so, how would I do that?

Thanks

How to use plugins modules exports and imports?

https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export

default export

I have following code:

<!doctype html>
<html>
<head>
    <title>Babel Test</title>
</head>
<body>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.14.0/babel.min.js"></script>

     <script data-plugins="transform-es2015-modules-umd" type="text/babel">
        export default function cube(x) {
          return x * x * x;
        }   
    </script>

</body>
</html>

I can export function cube but how do I import it?


Note that data-plugins="transform-es2015-modules-umd" is required, otherwise it will throw ReferenceError: exports is not defined

babili-standalone requires ES6

I'm currently using babel-standalone in the compiler for my game engine minisphere. I use Duktape as my JavaScript backend, which currently only supports ES5.1 with a few select ES6 features, so I need a transpiler. Babel itself works fine in this environment, but Babili does not, as it seems to require at least ES6 Set. Could Babili be made to run in ES5 environments?

Rebuild for 6.7.4

We've been getting reports in https://phabricator.babeljs.io/T7198 which appear to be because of minification. I think the case people are hitting will no longer occur in 6.7.x so it'd be great to get a new version of this out, since I think the majority of cases where people are using Babel as a prebuilt package is through this module.

Set defaualt presets as `latest,stage-0,react`

Perhaps it would be advisable to set defaualt presets as latest,stage-0,react (or latest,stage-1,react). We have es2015,react default presets, but why? Why not es2015,es2016 (current year) or latest?

I propose to fix default presets, or we must provide understandable explanation (logic, strategy) of which presets currently default and why.

Thanks for your work!

t.transform not a function with "systemjs": "~0.19.26", "babel-standalone": "~6.7.4"

getting this issue from chrome console ...
system.js:4 Uncaught (in promise) Error: TypeError: t.transform is not a function(…)

This may relate to systemjs/systemjs#891

I have this package json ...
{
"name": "ASP.NET",
"version": "0.0.0",
"dependencies": {
"angular2": "~2.0.0-beta.14",
"systemjs": "~0.19.26"
},
"devDependencies": {
"gulp": "3.9.1",
"gulp-concat": "2.6.0",
"gulp-cssmin": "0.1.7",
"gulp-uglify": "1.5.3",
"rimraf": "2.5.2",
"typescript": "~1.8.9",
"bootstrap": "^4.0.0-alpha.2",
"es6-module-loader": "~0.17.11",
"traceur": "~0.0.107",
"babel-core": "~6.7.6",
"babel-standalone": "~6.7.4"
}
}

And, I have this web in script tag page

    var systemConfig = {
        transpiler: "babel",
        map: {
            "babel": "../lib/babel-standalone/babel.js"
        }
    };
    System.config(systemConfig);
    System.import("app.js");

Using with css modules

First of all thanks for this awesome library.
I got to the point where I need to load styles using css-modules.

Does anyone know how to use this library with css modules and less preprocessor? I've tried with babel-plugin-css-modules-transform, css-modules-require-hook, babel-plugin-webpack-loaders but all of them are requiring 'fs' what is not possible in browser.

Thanks,
Jakub

Require is not supported in the browser..

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";

Option to disable automatic "text/babel" script parsing

Issue #15 added the ability to auto-transpile <script type="text/babel"> elements.

Could we get an option to disable that feature?

I use babel-standalone—6.7.7 via CDN—as the basis for one of my projects, babel-browser-harness, that already transpiles text/babel script tags, along with providing a module loader and a number of other features.

I'd like to update BBH to use 6.10.3, but the only way I can do it right now is with a kind of ugly workaround that intercepts the addEventListener() method. External libraries are loaded from CDN by default, so I can't modify the babel-standalone script.

Since babel-standalone uses a window event listener on DOMContentLoaded, I was hoping you could add a method that could be used to remove the listener before the the event fires—something simple like:

<script src=".../babel-standalone/6.10.3/babel.min.js"></script>
<script>
  Babel.removeDOMContentLoadedEventListener();
</script>

It should just require storing the event callback so it's available for window.removeEventListener().

Upgrade path from babel-core.browser

Hi!

I wanted to ask what the recommended upgrade path is to have on-the-fly compilation in the browser. Previously, I would use babel-core.5.8.34 like this:

<script src="babel-core.5.8.34.browser.js"></script>
<script src"mysource.js" type="text/babel"></script>

mysource.js would now be automatically compiled and executed. How can I achieve this with babel-standalone?

Add a lighter build with no presets bundled (build them separately)

Someone might want to use babel-standalone only for JSX transformation (for example), and not want to use any of the other Babel stuff. For this use-case, bundling every standard plugin and preset with babel-standalone is overkill. Instead, there could be a babel-standalone core JS file that only contains the core of Babel, and a preset-react file that contains just the React preset.

Investigate how much space is saved by building Babel with no plugins, and whether it's actually worth it. Perhaps most of the space is taken by the core of Babel, which would mean this is actually not worth doing.

Invalid preset specified in Babel options: "stage2"

When I insert a babel script with the data-presets attribute according to the README:

  <script type="text/babel" src="assets/js/app.js" data-presets="es2015,stage2"></script>  

I get the following error:

  babel.min.js:1 Uncaught Error: Invalid preset specified in Babel options: "stage2"  

Support preset options for the bundled presets

Right now, if, for example, [ [ "es2015", {} ] ] is given to plain babel-standalone in a browser, it causes babel to error out as it Couldn't find preset "es2015" relative to directory ".".

Can I specify presets without having to place all JavaScript inside a string?

According to README.md, if I want to specify plugins (e.g. react), I have to do something like this:

var input = 'const getMessage = () => "Hello World";';
var output = Babel.transform(input, { presets: ['es2015'] }).code;

In other words, all the JavaScript code to be transformed has to come from a string instead of a <script type="text/babel"></script> element. Is this right? If not, is there a complete example of an html page in which presets are specified?

sourceMaps

First, thanks a lot for this project, it's been very useful.

I'm actually considering using babel-standalone within Node because babel 6 is prohibitively slow in NPM 2.x. The one problem I've encountered is that sourceMaps don't seem to work with babel-standalone. I can look into why, but was just wondering if you knew anything about this.

Add ability to handle scripts using `text/babel` type

As a simple example:

<script type="text/babel">
const foo = () => alert('Hello world!');
foo();
</script>

babel-standalone should provide some way to parse all text/babel script tags, transform the script using Babel, and evaluate their contents.

Safari treats const as var/let

Version: Safari 9.1 (11601.5.17.1).

const a = 1;
console.log(a); // 1
a = 2;
console.log(a); // 2

It also doesn't show the error that Chrome, etc. does.

Error when trying to run any example: babel.js:3913 Uncaught SyntaxError: Invalid regular expression

I get this on Chrome console when trying to run any example. I tried latest build and 6.13.2.

babel.js:3913 Uncaught SyntaxError: Invalid regular expression: /[ªµºÀ-ÖØ-öø-�ˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-�Ҋ-ԯԱ-Ֆՙա-և�-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿ�ܒ-ܯ�-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽ�क़-ॡॱ-ঀঅ-ঌ��ও-নপ-রলশ-হঽৎড়�য়-ৡৰৱਅ-ਊ��ਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-��-ઑઓ-નપ-રલળવ-હઽ�ૠૡૹଅ-ଌ��ଓ-ନପ-ରଲଳଵ-ହଽଡ଼�ୟ-ୡୱஃஅ-ஊஎ-�ஒ-கஙசஜஞடணதந-பம-ஹ�అ-ఌఎ-�ఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-�ಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-�ഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆ�-ะาำเ-ๆ�ຂຄງຈຊ�ດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿ�-��-�����-��-�ႎႠ-ჅჇ��-ჺჼ-ቈቊ-��-ቖቘቚ-�በ-ኈኊ-��-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-�ጒ-ጕጘ-�ᎀ-�Ꭰ-��-��-ᙬᙯ-ᙿ�-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱ�-��-��-�ក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞ�-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣ�-�ᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-�ἠ-ὅὈ-��-ὗὙὛ�Ὗ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌ�-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ���-ₜℂℇℊ-ℓℕ℘-�ℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎ�-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼�-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ�-䶵一-鿕ꀀ-ꒌ�-ꓽꔀ-ꘌ�-ꘟꘪꘫꙀ-ꙮꙿ-�ꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-�ꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲ�ꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-�ꫠ-ꫪꫲ-ꫴ�-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗ�ײַ-ﬨשׁ-זּטּ-לּמּנּ�ףּפּצּ-ﮱﯓ-ﴽ�-�ﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Z�-zヲ-하-ᅦᅧ-�ᅭ-ᅲᅳ-ᅵ]/: Range out of order in character class

Use of additional plugins

Hello,

Is it possible to use additional plugins besides those that are included in the build? For example, add-module-exports.
If it is possible, how additional plugins can be used with babel-standalone?

Bower support is missing

Currently the Bower support is missing which complicates the installation process.

One way of enabling Bower support is to have the built artifacts published to the main repository as some projects do, however this was not deemed appropriate #13

Another way is to create a separate "artifact" repository/project that will contain the built artifacts of babel-standalone automatically pushed there by the build process of the main project. Then the published Bower package will refer to this "artifact" repository.

babel-standalone is meant to be used in a browser and Bower is quite a common tool used to install browser dependencies, so the support for it is highly desirable.

JSX tranformation is slow

Seems almost unusable on a mobile device. Completely different of course but I compared the jsx transformation to a browser version of html2hscript which seems to perform much better.

http://jsperf.com/babel-jsx-vs-html2hscript

Probably not something that can be fixed in babel-standalone but thought it's worth mentioning since the use-cases are similar but we see a crazy difference in performance.

Auto update script should nuke node_modules

npm does strange things and node_modules gets super bloated over time. I think it still hoists older versions of babel-core and ends up including the newer version in the sub-node_modules of all the plugins. The script should delete the entire node_modules directory when building.

Finish the auto-update script

  • git reset, git pull at the start (eg. see how Yarn Debian repo script does it)
  • Push to npm on success
  • Push to GitHub release on success

Add standalone Babylon build

To complement babel.js, add a babylon.js that's just the parser and nothing else. This could be useful for people that want to use a JavaScript AST but don't need to do any transformation.

[SOLVED]How can I integrate System.js and babel in browsers?

Help please!

How can I intergrate System.js and babel in browsers?

I want to use the pure es6 source code in browser when in development mode, and bundle files together when in production mode. So I config system.js and babel like below.

I installed both the latest version systemjs(0.19.24) and babel-standalone(6.6.5) via npm.

my index.html is below

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>System.js demo</title>
</head>
<body>
  <script src="./node_modules/systemjs/dist/system.src.js"></script>
  <script>
    System.config({
      baseURL: './',
      // or 'traceur' or 'typescript'
      transpiler: 'Babel',
      // or traceurOptions or typescriptOptions
      babelOptions: {
        presets: ['es2015']
      },
      map: {
        Babel: './node_modules/babel-standalone/babel.js'
      }
    });

    System.import('boot.js');
  </script>
</body>
</html>

and my boot.js is below

import { app } from './app.js'

app.run();

and my app.js is below

export app = {
  run: function(){
    console.log('app')
    alert('app')
  }
}

And when I visit the page, console have errors.

system.src.js:57 Uncaught (in promise) Error: ReferenceError: [BABEL] http://v:3000/boot.js: Using removed Babel 5 option: base.modules - Use the corresponding module transform plugin in the plugins option. Check out http://babeljs.io/docs/plugins/#modules(…)

Then I checked babel docs, and add one option to babelOptions, now my System.js config like this

System.config({
      baseURL: './',
      // or 'traceur' or 'typescript'
      transpiler: 'Babel',
      // or traceurOptions or typescriptOptions
      babelOptions: {
        plugins: ["transform-es2015-modules-systemjs"],
        presets: ['es2015']
      },
      map: {
        Babel: './node_modules/babel-standalone/babel.js'
      }
    });

    System.import('boot.js');

But the same error occur. I have no idea how to intergrate System.js and babel in browers to just load es6 source code module.

Could anyone help me? Thanks very much!!

EDIT

I checked system.src.js, and removed options.modules = 'system'; in babelTranspile function. then above error gone. but new error occured.

If I didn't include plugins: ["transform-es2015-modules-systemjs"] in babelOptions, js files are transformed to below

(function(System, SystemJS) {(function(__moduleName){'use strict';

var _app = require('./app.js');

_app.app.run();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJvb3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUVBLFNBQUksR0FBSiIsImZpbGUiOiJib290LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgYXBwIH0gZnJvbSAnLi9hcHAuanMnXG5cbmFwcC5ydW4oKTtcbiJdfQ==
})("http://v:3000/boot.js");
})(System, System);

But I got the error

require is not a function.

If I include plugins: ["transform-es2015-modules-systemjs"] in babelOptions, then files are not transformed, and will throw up error in app.js

system.src.js:57 Uncaught (in promise) Error: SyntaxError: Unexpected token export

Please help me how to fix this. Waiting for reply. Thanks very much

Last Edit

I solved the problem. It's my fault. I write error export statement. I should use export const app = .. insteadof export app = ...

Now my System config is below

System.config({
      baseURL: './',
      // or 'traceur' or 'typescript'
      transpiler: 'Babel',
      // or traceurOptions or typescriptOptions
      babelOptions: {
        plugins: ["transform-es2015-modules-systemjs"],
        presets: ['es2015', 'react']
      },
      map: {
        Babel: './node_modules/babel-standalone/babel.js'
      }
    });

    System.import('boot.js');

Browser support

Hi @Daniel15,

would be nice to have a browser support list at the readme.md file or somewhere :)

So far I have done some tests with babel-standalone and I could not make it run on IE8/IE9,
other browsers seems okay.

Safari gives "ERROR: unknown: Property id of VariableDeclarator expected node"

Safari is giving an error: ERROR: unknown: Property id of VariableDeclarator expected node. But this bug is extremely strange. First it only happens in Safari with the console closed, if I open the console its fine. Second, I've boiled it down to the following simple code showing the issue:

 class A extends React.Component {
      render() {
        return (
          <div>
            <div>Test</div>
            <input type="checkbox" value={this.props.value} onChange={{}} />
            <div style={{border: "1px solid #ddd"}}>test</div>
          </div>
        );
      }
    }

    class B extends React.Component {
      render() {
        return (
          null
        );
      }
    }

Its really strange, if I remove for example, the tag, it starts working. Also if I change the order of the classes it starts working. I've attached the test file I am using, its a modified version of the sample included with this project.

example.htm.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.