Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ example/*.log
docs/
npm-debug.log
/.idea/
typings/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 4
- 6
env:
- CXX=g++-4.8
addons:
Expand Down
4 changes: 2 additions & 2 deletions addons/attach/attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
/*
* CommonJS environment
*/
module.exports = attach(require('../../src/xterm'));
module.exports = attach(require('../../build/xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], attach);
define(['../../build/xterm'], attach);
} else {
/*
* Plain browser environment
Expand Down
4 changes: 2 additions & 2 deletions addons/fit/fit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
/*
* CommonJS environment
*/
module.exports = fit(require('../../src/xterm'));
module.exports = fit(require('../../build/xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fit);
define(['../../build/xterm'], fit);
} else {
/*
* Plain browser environment
Expand Down
4 changes: 2 additions & 2 deletions addons/fullscreen/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
/*
* CommonJS environment
*/
module.exports = fullscreen(require('../../src/xterm'));
module.exports = fullscreen(require('../../build/xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fullscreen);
define(['../../build/xterm'], fullscreen);
} else {
/*
* Plain browser environment
Expand Down
4 changes: 2 additions & 2 deletions addons/linkify/linkify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
/*
* CommonJS environment
*/
module.exports = linkify(require('../../src/xterm'));
module.exports = linkify(require('../../build/xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], linkify);
define(['../../build/xterm'], linkify);
} else {
/*
* Plain browser environment
Expand Down
41 changes: 5 additions & 36 deletions bin/build
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
#! /usr/bin/env node
#! /usr/bin/env sh

var child_process = require('child_process');
var fs = require('fs');
typings install

var buildDir = process.env.BUILD_DIR || 'build';

if (!fs.existsSync(buildDir)){
fs.mkdirSync(buildDir);
}

// Add `node_modules/.bin` to PATH
process.env.PATH = process.cwd() + '/node_modules/.bin:' + process.env.PATH;

console.log('Building xterm.js into ' + buildDir);

// Build ES2015 modules into ES5 form, then concatenate them,
// then remove unused require calls and save in output file with source map.
console.log(' - Building ' + buildDir + '/xterm.js...');

var jsBuildCmd = 'browserify src/xterm.js -s Terminal -t [ babelify --presets [ es2015 ] ] --debug | ';
jsBuildCmd += 'derequire | exorcist ' + buildDir + '/xterm.js.map > ' + buildDir + '/xterm.js';

var jsBuildProcess = child_process.execSync(jsBuildCmd);

if (jsBuildProcess.status) {
console.log(jsBuildProcess.error);
}

console.log(' OK.');

// Copy CSS into $BUILD_DIR
console.log(' - Building ' + buildDir + '/xterm.css...');

fs.createReadStream('src/xterm.css').pipe(
fs.createWriteStream(buildDir + '/xterm.css')
);
console.log(' OK.');
mkdir -p build
browserify src/xterm.js --standalone Terminal -p [ tsify ] --outfile build/xterm.js
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this solves most of problems with TypeScript building.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into this, while it does support outputting as umd module types only amd and system are supported with the --outFile argument. They recommend using browserify or webpack for bundling umds.

cp src/xterm.css build/xterm.css
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@
"repository": "https://github.com/sourcelair/xterm.js",
"license": "MIT",
"devDependencies": {
"babel-core": "6.14.0",
"babel-preset-es2015": "6.14.0",
"babelify": "^7.3.0",
"@types/node": "^6.0.41",
"browserify": "^13.1.0",
"chai": "3.5.0",
"derequire": "^2.0.3",
"docdash": "0.4.0",
"exorcist": "^0.4.0",
"express": "4.13.4",
"express-ws": "2.0.0-rc.1",
"glob": "^7.0.5",
"jsdoc": "3.4.0",
"mocha": "2.5.3",
"nodemon": "1.10.2",
"pty.js": "0.3.1",
"sleep": "^3.0.1"
"sleep": "^3.0.1",
"tsify": "^1.0.7",
"typescript": "^2.0.3",
"typings": "^1.4.0"
},
"scripts": {
"start": "nodemon --watch src --watch addons --exec bash -c './bin/build && node demo/app'",
"test": "mocha --recursive --compilers js:babel-core/register",
"test": "./bin/build && mocha --recursive ./test/*test.js ./test/**/*test.js",
"build:docs": "jsdoc -c jsdoc.json",
"build": "./bin/build"
}
Expand Down
2 changes: 1 addition & 1 deletion src/xterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ Terminal.prototype.open = function(parent) {
Terminal.loadAddon = function(addon, callback) {
if (typeof exports === 'object' && typeof module === 'object') {
// CommonJS
return require(__dirname + '/../addons/' + addon);
return require('../addons/' + addon);
} else if (typeof define == 'function') {
// RequireJS
return require(['../addons/' + addon + '/' + addon], callback);
Expand Down
2 changes: 1 addition & 1 deletion test/addons/linkify-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('chai').assert;
var Terminal = require('../../src/xterm');
var Terminal = require('../../build/xterm');
var linkify = require('../../addons/linkify/linkify');

describe('linkify addon', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/addons/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('chai').assert;
var Terminal = require('../../src/xterm');
var Terminal = require('../../build/xterm');

describe('xterm.js addons', function() {
it('should load addons with Terminal.loadAddon', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/composition-helper-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('chai').assert;
var Terminal = require('../src/xterm');
var Terminal = require('../build/xterm');

describe('CompositionHelper', function () {
var terminal;
Expand Down
2 changes: 1 addition & 1 deletion test/escape_sequences.js → test/escape-sequences-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var glob = require('glob');
var fs = require('fs');
var pty = require('pty.js');
var sleep = require('sleep');
var Terminal = require('../src/xterm');
var Terminal = require('../build/xterm');

var CONSOLE_LOG = console.log;

Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var assert = require('chai').assert;
var expect = require('chai').expect;
var Terminal = require('../src/xterm');
var Terminal = require('../build/xterm');

describe('xterm.js', function() {
var xterm;
Expand Down
2 changes: 1 addition & 1 deletion test/viewport-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('chai').assert;
var Terminal = require('../src/xterm');
var Terminal = require('../build/xterm');

describe('Viewport', function () {
var terminal;
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"rootDir": "src",
"allowJs": true
},
"exclude": [
"addons",
"build",
"demo",
"out",
"test",
"node_modules"
]
}
6 changes: 6 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "xterm",
"globalDependencies": {
"node": "registry:env/node#6.0.0+20160918225031"
}
}