Creating a module in Browserify / 6to5ify that can be used by SystemJS

I have four ES6 modules and one module that provides data from the following four modules:

export { Board } from './board';
export { Card } from './card';
export { Game } from './game';
export { Player } from './player';

My goal is to have one JavaScript module file that I can use via systemjs api:

import { Card } from 'game';

It seems the best way to recursively compute and combine dependencies is through the browser, and the best way to compile ES5 with ES6 is 6to5. So, I looked at the 6to5ify node module. I copied and pasted the code from the example :

var fs = require("fs"),
    browserify = require("browserify"),
    to5ify = require("6to5ify");

browserify({ debug: false })
  .transform(to5ify)
  .require("./src/main.js", { entry: true })
  .bundle()
  .pipe(fs.createWriteStream("./dist/game.js"));

Finally, I upload game.js to another ES6 web project. However, at the moment I am getting errors, and the systemjs module loader starts looking for the dependencies of the game.js module, as if they were local dependencies:

GET http://localhost:9000/client/board.js 404 ( ) ES6--loader.src.js: 2510

GET http://localhost:9000/client/card.js 404 ( ) ES6--loader.src.js: 2510

GET http://localhost:9000/client/game.js 404 ( ) ES6--loader.src.js: 2510

GET http://localhost:9000/client/player.js 404 ( ) ES6--loader.src.js: 2510

, .

, 6to5, , systemjs , , .

+4

All Articles