From d281862980627c7c5449c596d62df81a21c322d3 Mon Sep 17 00:00:00 2001 From: Jon Braz Date: Tue, 4 Jun 2019 21:23:25 +0000 Subject: [PATCH 1/2] Add babel to gulp buildDev workflow for js compilation --- gulp/tasks/javascript.js | 16 +++++++++ gulpfile.babel.js | 3 +- package-lock.json | 77 ++++++++++++++++++++++++---------------- package.json | 2 ++ 4 files changed, 67 insertions(+), 31 deletions(-) diff --git a/gulp/tasks/javascript.js b/gulp/tasks/javascript.js index 0b9fe0b19..1891fec57 100644 --- a/gulp/tasks/javascript.js +++ b/gulp/tasks/javascript.js @@ -4,6 +4,7 @@ import gulp from 'gulp'; import uglify from 'gulp-uglify'; import eslint from 'gulp-eslint'; import { app, src, tmp } from '../paths.js'; +import babel from 'gulp-babel'; const config = { app: { @@ -53,3 +54,18 @@ export const lint = () => gulp .src(context.lint) .pipe(eslint()) .pipe(eslint.format()); + +/** + * Compile with Babel + */ +export const compileJs = () => gulp + .src([ + join(tmp, 'apps', '**', '*.js'), + ]) + .pipe(babel({ + babelrc: false, + ignore: ['**/node_modules'], + plugins: ['babel-plugin-transform-object-rest-spread'], + presets: ['env'] + })) + .pipe(gulp.dest(join(tmp, 'apps'))); diff --git a/gulpfile.babel.js b/gulpfile.babel.js index e552a61fd..6d8952623 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -2,7 +2,7 @@ import { serve, watch } from './gulp/tasks/server.js'; import gulp from 'gulp'; import require from './gulp/tasks/require.js'; import writeVersion from './gulp/tasks/write-version.js'; -import { lint, minifyJs, minifyJsApp } from './gulp/tasks/javascript.js'; +import { lint, minifyJs, minifyJsApp, compileJs } from './gulp/tasks/javascript.js'; import { templates, templatesApp } from './gulp/tasks/templates.js'; import { compileSass, css, minifyCssApp } from './gulp/tasks/style.js'; import { @@ -20,6 +20,7 @@ const buildProd = gulp.series( moveFilesToTmp, compileSass, templates, + compileJs, require, minifyJs, css, diff --git a/package-lock.json b/package-lock.json index 7702e51d0..fff7fa3ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -742,6 +742,12 @@ "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", "dev": true }, + "babel-plugin-syntax-object-rest-spread": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", + "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", + "dev": true + }, "babel-plugin-syntax-trailing-function-commas": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", @@ -1004,6 +1010,16 @@ "babel-runtime": "^6.22.0" } }, + "babel-plugin-transform-object-rest-spread": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", + "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", + "dev": true, + "requires": { + "babel-plugin-syntax-object-rest-spread": "^6.8.0", + "babel-runtime": "^6.26.0" + } + }, "babel-plugin-transform-regenerator": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", @@ -3182,8 +3198,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3204,14 +3219,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3226,20 +3239,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3356,8 +3366,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3369,7 +3378,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3384,7 +3392,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3392,14 +3399,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3418,7 +3423,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3499,8 +3503,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3512,7 +3515,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3598,8 +3600,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3635,7 +3636,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3655,7 +3655,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3699,14 +3698,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -4002,6 +3999,26 @@ } } }, + "gulp-babel": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/gulp-babel/-/gulp-babel-7.0.1.tgz", + "integrity": "sha512-UqHS3AdxZyJCRxqnAX603Dj3k/Wx6hzcgmav3QcxvsIFq3Y8ZkU7iXd0O+JwD5ivqCc6o0r1S7tCB/xxLnuSNw==", + "dev": true, + "requires": { + "plugin-error": "^1.0.1", + "replace-ext": "0.0.1", + "through2": "^2.0.0", + "vinyl-sourcemaps-apply": "^0.2.0" + }, + "dependencies": { + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + } + } + }, "gulp-cached": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/gulp-cached/-/gulp-cached-1.1.1.tgz", diff --git a/package.json b/package.json index ba4d6a106..6a174c32c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "dependencies": {}, "devDependencies": { "babel-core": "^6.26.3", + "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-polyfill": "^6.26.0", "babel-preset-env": "^1.7.0", "browser-sync": "^2.26.7", @@ -30,6 +31,7 @@ "eslint-plugin-promise": "^4.0.0", "eslint-plugin-standard": "^4.0.0", "gulp": "^4.0.0", + "gulp-babel": "^7.0.0", "gulp-cached": "^1.1.1", "gulp-clean-css": "^3.9.0", "gulp-concat": "^2.6.1", From 9ab3fc6bdcc59156259b022eaa4181d6c9554666 Mon Sep 17 00:00:00 2001 From: Jon Braz Date: Thu, 7 Nov 2019 16:10:26 -0800 Subject: [PATCH 2/2] Apply babel to lib, add babel to buildDev and buildApp flows --- gulp/tasks/javascript.js | 8 +++++--- gulpfile.babel.js | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gulp/tasks/javascript.js b/gulp/tasks/javascript.js index 1891fec57..51177ad40 100644 --- a/gulp/tasks/javascript.js +++ b/gulp/tasks/javascript.js @@ -56,16 +56,18 @@ export const lint = () => gulp .pipe(eslint.format()); /** - * Compile with Babel + * Compile *.js files in /apps/** and /js/lib to ES5 with Babel */ export const compileJs = () => gulp .src([ join(tmp, 'apps', '**', '*.js'), - ]) + join(tmp, 'js', 'lib', '**', '*.js') + ], { base: tmp }) .pipe(babel({ babelrc: false, + compact: true, ignore: ['**/node_modules'], plugins: ['babel-plugin-transform-object-rest-spread'], presets: ['env'] })) - .pipe(gulp.dest(join(tmp, 'apps'))); + .pipe(gulp.dest(tmp)); diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 6d8952623..1dabe4014 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -41,6 +41,7 @@ const buildApp = gulp.series( moveFilesToTmp, compileSass, templatesApp, + compileJs, require, minifyJsApp, minifyCssApp,