Skip to content

Instantly share code, notes, and snippets.

// inside app.js
export class App {}
// inside domUtil.js
import jQuery from 'jquery' // comes from the node_modules directory
export var domUtil = {}
// inside another file
import {App} from './app'
import {domUtil as domStuff} from './domUtil'
module.exports = {
entry: './src/main',
module: {
loaders: [
// Transpile any JavaScript file:
{ test: /\.js$/, loader: 'webpack-traceur?runtime&sourceMaps&experimental' }
]
},
resolve: {
// you can now require('file') instead of require('file.js')
$ npm start
> mocha-with-traceur@0.0.1 start /Users/uxebu/mocha-sinon-traceur-example
> webpack-dev-server
http://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from /Users/uxebu/mocha-sinon-traceur-example
[traceur-loader]: Processing file: /Users/uxebu/mocha-sinon-traceur-example/src/main.js
[traceur-loader]: Current options are: { runtime: true, traceurOptions: {} }
module.exports = {
entry: './src/main',
module: {
loaders: [
// Transpile any JavaScript file:
{
test: /\.js$/,
loader: 'webpack-traceur?runtime',
exclude: /node_modules/ // <<<<===== prevent traceur to modify all from node_modules
}
// should get loaded into tddbin
switch(points) {
case 0: return 'Love';
case 1: return 'Fifteen';
case 2: return 'Thirty';
case 3: return 'Forty';
}
pointsMap = [
'Love',
'Fifteen',
'Thirty',
'Forty'
];
pointsMap = {
0: 'Love',
1: 'Fifteen',
2: 'Thirty',
3: 'Forty'
};
function callTie(points) {
if (points < 3) {
var pointsMap = {
0: 'Love-All',
1: 'Fifteen-All',
2: 'Thirty-All'
};
return pointsMap[points];
}
return 'Deuce';
var pointsMap = {
0: 'Love-All',
1: 'Fifteen-All',
2: 'Thirty-All'
};
function callTie(points) {
if (points < 3) {
return pointsMap[points];
}