summaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-04-20 03:09:25 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-04-24 16:14:29 +0200
commit82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch)
tree965f6eb89b84d65a62b49008fd972c004832ccd1 /gulpfile.js
parente6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff)
downloadwallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.gz
wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.bz2
wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.zip
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules into one file (plus commons chunks) for every entry point. This results in a much smaller extension size (almost half). Furthermore we use yarn/npm even for extension run-time dependencies. This relieves us from manually vendoring and building dependencies. It's also easier to understand for new developers familiar with node.
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js48
1 files changed, 21 insertions, 27 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 025a67a34..9841b5f75 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -30,6 +30,7 @@
*/
const gulp = require("gulp");
+const gutil = require("gulp-util");
const map = require("map-stream");
const zip = require("gulp-zip");
const gzip = require("gulp-gzip");
@@ -47,6 +48,7 @@ const through = require('through2');
const File = require('vinyl');
const Stream = require('stream').Stream;
const vfs = require('vinyl-fs');
+const webpack = require('webpack');
const paths = {
ts: {
@@ -55,11 +57,9 @@ const paths = {
"!src/**/*-test*.ts",
],
decl: [
- "decl/lib.es6.d.ts",
- "decl/urijs/URIjs.d.ts",
- "decl/systemjs/systemjs.d.ts",
- "decl/react-global.d.ts",
+ "decl/jed.d.ts",
"decl/chrome/chrome.d.ts",
+ "decl/urijs.d.ts",
],
test: [
"testlib/**/.ts",
@@ -70,8 +70,10 @@ const paths = {
dist: [
"img/icon.png",
"img/logo.png",
- "src/**/*.{js,css,html}",
- "testlib/**/*.{js,ts,tsx,html}",
+ "src/**/*.{css,html}",
+ "src/taler-wallet-lib.js",
+ "src/emscripten/taler-emscripten-lib.js",
+ "dist/*-bundle.js",
],
// for the source distribution
extra: [
@@ -103,9 +105,9 @@ const tsBaseArgs = {
jsx: "react",
reactNamespace: "React",
experimentalDecorators: true,
- module: "system",
+ module: "commonjs",
sourceMap: true,
- noLib: true,
+ lib: ["ES6", "DOM"],
noImplicitReturns: true,
noFallthroughCasesInSwitch: true,
strictNullChecks: true,
@@ -157,27 +159,19 @@ gulp.task("clean", function () {
});
-gulp.task("dist-prod", ["clean"], function () {
+gulp.task("dist-prod", ["clean", "compile-prod"], function () {
return vfs.src(paths.dist, {base: ".", stripBOM: false})
.pipe(gulp.dest("build/ext/"));
});
-gulp.task("compile-prod", ["clean"], function () {
- const tsArgs = {};
- Object.assign(tsArgs, tsBaseArgs);
- tsArgs.typescript = require("typescript");
- // relative to the gulp.dest
- tsArgs.outDir = ".";
- // We don't want source maps for production
- tsArgs.sourceMap = undefined;
- let opts = {base: "."};
- const files = concatStreams(
- gulp.src(paths.ts.src, opts),
- gulp.src(paths.ts.decl, opts));
-
- return files
- .pipe(ts(tsArgs))
- .pipe(gulp.dest("build/ext/"));
+gulp.task("compile-prod", function (callback) {
+ let config = require("./webpack.config.js");
+ webpack(config, function(err, stats) {
+ if(err) {
+ throw new gutil.PluginError("webpack", err);
+ }
+ callback();
+ });
});
gulp.task("manifest-stable", ["clean"], function () {
@@ -199,7 +193,7 @@ gulp.task("manifest-unstable", ["clean"], function () {
});
-gulp.task("package-stable", ["compile-prod", "dist-prod", "manifest-stable"], function () {
+gulp.task("package-stable", ["dist-prod", "manifest-stable"], function () {
let basename = String.prototype.concat("taler-wallet-stable-", manifest.version_name, "-", manifest.version);
let zipname = basename + ".zip";
let xpiname = basename + ".xpi";
@@ -209,7 +203,7 @@ gulp.task("package-stable", ["compile-prod", "dist-prod", "manifest-stable"], fu
.pipe(symlink("build/" + xpiname, {relative: true, force: true}));
});
-gulp.task("package-unstable", ["compile-prod", "dist-prod", "manifest-unstable"], function () {
+gulp.task("package-unstable", ["dist-prod", "manifest-unstable"], function () {
let basename = String.prototype.concat("taler-wallet-unstable-", manifest.version_name, "-", manifest.version);
let zipname = basename + ".zip";
let xpiname = basename + ".xpi";