From 989610e8c3f547d0e06f3ddc706e7cbaa1061e5f Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 10 Jun 2019 14:28:07 -0700 Subject: [PATCH 1/4] Webpack the addons --- addons/xterm-addon-attach/package.json | 7 +++-- addons/xterm-addon-attach/src/tsconfig.json | 2 +- addons/xterm-addon-attach/webpack.config.js | 31 +++++++++++++++++++ addons/xterm-addon-fit/package.json | 7 +++-- addons/xterm-addon-fit/src/tsconfig.json | 2 +- addons/xterm-addon-fit/webpack.config.js | 31 +++++++++++++++++++ addons/xterm-addon-search/package.json | 7 +++-- addons/xterm-addon-search/src/tsconfig.json | 2 +- addons/xterm-addon-search/webpack.config.js | 31 +++++++++++++++++++ addons/xterm-addon-web-links/package.json | 7 +++-- .../xterm-addon-web-links/src/tsconfig.json | 2 +- .../xterm-addon-web-links/webpack.config.js | 31 +++++++++++++++++++ bin/packageAddons.js | 19 ++++++++++++ package.json | 1 + 14 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 addons/xterm-addon-attach/webpack.config.js create mode 100644 addons/xterm-addon-fit/webpack.config.js create mode 100644 addons/xterm-addon-search/webpack.config.js create mode 100644 addons/xterm-addon-web-links/webpack.config.js create mode 100644 bin/packageAddons.js diff --git a/addons/xterm-addon-attach/package.json b/addons/xterm-addon-attach/package.json index e381730c..e0f2f0a8 100644 --- a/addons/xterm-addon-attach/package.json +++ b/addons/xterm-addon-attach/package.json @@ -5,11 +5,14 @@ "name": "The xterm.js authors", "url": "https://xtermjs.org/" }, - "main": "lib/AttachAddon.js", + "main": "lib/xterm-addon-attach.js", "types": "typings/xterm-addon-attach.d.ts", "license": "MIT", "scripts": { - "prepublishOnly": "../../node_modules/.bin/tsc -p src" + "build": "../../node_modules/.bin/tsc -p src", + "prepackage": "npm run build", + "package": "../../node_modules/.bin/webpack", + "prepublishOnly": "npm run package" }, "peerDependencies": { "xterm": "^3.14.0" diff --git a/addons/xterm-addon-attach/src/tsconfig.json b/addons/xterm-addon-attach/src/tsconfig.json index 9a92ab48..d875aa53 100644 --- a/addons/xterm-addon-attach/src/tsconfig.json +++ b/addons/xterm-addon-attach/src/tsconfig.json @@ -7,7 +7,7 @@ "es2015" ], "rootDir": ".", - "outDir": "../lib", + "outDir": "../out", "sourceMap": true, "removeComments": true, "strict": true diff --git a/addons/xterm-addon-attach/webpack.config.js b/addons/xterm-addon-attach/webpack.config.js new file mode 100644 index 00000000..65996f19 --- /dev/null +++ b/addons/xterm-addon-attach/webpack.config.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +const addonName = 'AttachAddon'; +const mainFile = 'xterm-addon-attach.js'; + +module.exports = { + entry: `./out/${addonName}.js`, + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + output: { + filename: mainFile, + path: path.resolve('./lib'), + library: addonName, + libraryTarget: 'umd' + }, + mode: 'production' +}; diff --git a/addons/xterm-addon-fit/package.json b/addons/xterm-addon-fit/package.json index a29f3199..e2b91d41 100644 --- a/addons/xterm-addon-fit/package.json +++ b/addons/xterm-addon-fit/package.json @@ -5,11 +5,14 @@ "name": "The xterm.js authors", "url": "https://xtermjs.org/" }, - "main": "lib/FitAddon.js", + "main": "lib/xterm-addon-fit.js", "types": "typings/xterm-addon-fit.d.ts", "license": "MIT", "scripts": { - "prepublishOnly": "../../node_modules/.bin/tsc -p src" + "build": "../../node_modules/.bin/tsc -p src", + "prepackage": "npm run build", + "package": "../../node_modules/.bin/webpack", + "prepublishOnly": "npm run package" }, "peerDependencies": { "xterm": "^3.14.0" diff --git a/addons/xterm-addon-fit/src/tsconfig.json b/addons/xterm-addon-fit/src/tsconfig.json index 6b914e81..5539aa56 100644 --- a/addons/xterm-addon-fit/src/tsconfig.json +++ b/addons/xterm-addon-fit/src/tsconfig.json @@ -7,7 +7,7 @@ "es2015" ], "rootDir": ".", - "outDir": "../lib", + "outDir": "../out", "sourceMap": true, "removeComments": true, "strict": true diff --git a/addons/xterm-addon-fit/webpack.config.js b/addons/xterm-addon-fit/webpack.config.js new file mode 100644 index 00000000..4b542150 --- /dev/null +++ b/addons/xterm-addon-fit/webpack.config.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +const addonName = 'FitAddon'; +const mainFile = 'xterm-addon-fit.js'; + +module.exports = { + entry: `./out/${addonName}.js`, + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + output: { + filename: mainFile, + path: path.resolve('./lib'), + library: addonName, + libraryTarget: 'umd' + }, + mode: 'production' +}; diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index 38f76add..5c11efde 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -5,11 +5,14 @@ "name": "The xterm.js authors", "url": "https://xtermjs.org/" }, - "main": "lib/SearchAddon.js", + "main": "lib/xterm-addon-search.js", "types": "typings/xterm-addon-search.d.ts", "license": "MIT", "scripts": { - "prepublishOnly": "../../node_modules/.bin/tsc -p src" + "build": "../../node_modules/.bin/tsc -p src", + "prepackage": "npm run build", + "package": "../../node_modules/.bin/webpack", + "prepublishOnly": "npm run package" }, "peerDependencies": { "xterm": "^3.14.0" diff --git a/addons/xterm-addon-search/src/tsconfig.json b/addons/xterm-addon-search/src/tsconfig.json index 58a4bacf..1cb6d4d7 100644 --- a/addons/xterm-addon-search/src/tsconfig.json +++ b/addons/xterm-addon-search/src/tsconfig.json @@ -7,7 +7,7 @@ "es6", ], "rootDir": ".", - "outDir": "../lib", + "outDir": "../out", "sourceMap": true, "removeComments": true, "strict": true diff --git a/addons/xterm-addon-search/webpack.config.js b/addons/xterm-addon-search/webpack.config.js new file mode 100644 index 00000000..726dceb6 --- /dev/null +++ b/addons/xterm-addon-search/webpack.config.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +const addonName = 'SearchAddon'; +const mainFile = 'xterm-addon-search.js'; + +module.exports = { + entry: `./out/${addonName}.js`, + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + output: { + filename: mainFile, + path: path.resolve('./lib'), + library: addonName, + libraryTarget: 'umd' + }, + mode: 'production' +}; diff --git a/addons/xterm-addon-web-links/package.json b/addons/xterm-addon-web-links/package.json index 82edbe9b..5325df9d 100644 --- a/addons/xterm-addon-web-links/package.json +++ b/addons/xterm-addon-web-links/package.json @@ -5,11 +5,14 @@ "name": "The xterm.js authors", "url": "https://xtermjs.org/" }, - "main": "lib/WebLinksAddon.js", + "main": "lib/xterm-addon-web-links.js", "types": "typings/xterm-addon-web-links.d.ts", "license": "MIT", "scripts": { - "prepublishOnly": "../../node_modules/.bin/tsc -p src" + "build": "../../node_modules/.bin/tsc -p src", + "prepackage": "npm run build", + "package": "../../node_modules/.bin/webpack", + "prepublishOnly": "npm run package" }, "peerDependencies": { "xterm": "^3.14.0" diff --git a/addons/xterm-addon-web-links/src/tsconfig.json b/addons/xterm-addon-web-links/src/tsconfig.json index 6b914e81..5539aa56 100644 --- a/addons/xterm-addon-web-links/src/tsconfig.json +++ b/addons/xterm-addon-web-links/src/tsconfig.json @@ -7,7 +7,7 @@ "es2015" ], "rootDir": ".", - "outDir": "../lib", + "outDir": "../out", "sourceMap": true, "removeComments": true, "strict": true diff --git a/addons/xterm-addon-web-links/webpack.config.js b/addons/xterm-addon-web-links/webpack.config.js new file mode 100644 index 00000000..fd87d07e --- /dev/null +++ b/addons/xterm-addon-web-links/webpack.config.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +const addonName = 'WebLinksAddon'; +const mainFile = 'xterm-addon-web-links.js'; + +module.exports = { + entry: `./out/${addonName}.js`, + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + output: { + filename: mainFile, + path: path.resolve('./lib'), + library: addonName, + libraryTarget: 'umd' + }, + mode: 'production' +}; diff --git a/bin/packageAddons.js b/bin/packageAddons.js new file mode 100644 index 00000000..54ed634e --- /dev/null +++ b/bin/packageAddons.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const cp = require('child_process'); +const path = require('path'); +const fs = require('fs'); + +const addons = fs.readdirSync(path.resolve(__dirname, '../addons')); +addons.forEach(addon => { + cp.spawnSync( + 'npm', ['run', 'package'], + { + cwd: path.resolve(__dirname, `../addons/${addon}`), + stdio: 'inherit' + } + ); +}); diff --git a/package.json b/package.json index 16ebca92..e93ab8ca 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "test-api": "mocha \"**/*.api.js\"", "test-unit": "node ./bin/test.js", "build": "tsc -b ./tsconfig.all.json", + "postbuild": "node ./bin/packageAddons.js", "prepare": "npm run build", "prepublishOnly": "npm run package", "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput", From b657a1f30e0de88dd64436980220da282b3ab8ef Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 10 Jun 2019 14:41:43 -0700 Subject: [PATCH 2/4] Use addon tsc output in the demo, similar to the core lib --- demo/client.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index f1626c4f..e0d55d57 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -9,13 +9,17 @@ // Use tsc version (yarn watch) import { Terminal } from '../out/public/Terminal'; +import { AttachAddon } from '../addons/xterm-addon-attach/out/AttachAddon'; +import { FitAddon } from '../addons/xterm-addon-fit/out/FitAddon'; +import { SearchAddon, ISearchOptions } from '../addons/xterm-addon-search/out/SearchAddon'; +import { WebLinksAddon } from '../addons/xterm-addon-web-links/out/WebLinksAddon'; + // Use webpacked version (yarn package) // import { Terminal } from '../lib/xterm'; - -import { AttachAddon } from 'xterm-addon-attach'; -import { FitAddon } from 'xterm-addon-fit'; -import { SearchAddon, ISearchOptions } from 'xterm-addon-search'; -import { WebLinksAddon } from 'xterm-addon-web-links'; +// import { AttachAddon } from 'xterm-addon-attach'; +// import { FitAddon } from 'xterm-addon-fit'; +// import { SearchAddon, ISearchOptions } from 'xterm-addon-search'; +// import { WebLinksAddon } from 'xterm-addon-web-links'; // Pulling in the module's types relies on the above, it's looks a // little weird here as we're importing "this" module From d9ce9e96f543d3fd120c910f5cd5fa7bc4da74e9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 10 Jun 2019 14:47:10 -0700 Subject: [PATCH 3/4] Remove packageAddons step on install It's not needed when the demo doesn't use it --- bin/packageAddons.js | 19 ------------------- package.json | 1 - 2 files changed, 20 deletions(-) delete mode 100644 bin/packageAddons.js diff --git a/bin/packageAddons.js b/bin/packageAddons.js deleted file mode 100644 index 54ed634e..00000000 --- a/bin/packageAddons.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -const cp = require('child_process'); -const path = require('path'); -const fs = require('fs'); - -const addons = fs.readdirSync(path.resolve(__dirname, '../addons')); -addons.forEach(addon => { - cp.spawnSync( - 'npm', ['run', 'package'], - { - cwd: path.resolve(__dirname, `../addons/${addon}`), - stdio: 'inherit' - } - ); -}); diff --git a/package.json b/package.json index e93ab8ca..16ebca92 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "test-api": "mocha \"**/*.api.js\"", "test-unit": "node ./bin/test.js", "build": "tsc -b ./tsconfig.all.json", - "postbuild": "node ./bin/packageAddons.js", "prepare": "npm run build", "prepublishOnly": "npm run package", "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput", From 3e91f08e34789ba27ecc7b34af7acf2c64858185 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 10 Jun 2019 14:51:09 -0700 Subject: [PATCH 4/4] Bump addon versions --- addons/xterm-addon-attach/package.json | 2 +- addons/xterm-addon-fit/package.json | 2 +- addons/xterm-addon-search/package.json | 2 +- addons/xterm-addon-web-links/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-attach/package.json b/addons/xterm-addon-attach/package.json index e0f2f0a8..1d72b144 100644 --- a/addons/xterm-addon-attach/package.json +++ b/addons/xterm-addon-attach/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-attach", - "version": "0.1.0-beta10", + "version": "0.1.0-beta11", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-fit/package.json b/addons/xterm-addon-fit/package.json index e2b91d41..4ee8e1b7 100644 --- a/addons/xterm-addon-fit/package.json +++ b/addons/xterm-addon-fit/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-fit", - "version": "0.1.0-beta2", + "version": "0.1.0-beta3", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index 5c11efde..02cb6695 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-search", - "version": "0.1.0-beta5", + "version": "0.1.0-beta6", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-web-links/package.json b/addons/xterm-addon-web-links/package.json index 5325df9d..a764a200 100644 --- a/addons/xterm-addon-web-links/package.json +++ b/addons/xterm-addon-web-links/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-web-links", - "version": "0.1.0-beta9", + "version": "0.1.0-beta10", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/"