FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add transpilation step · devhttps/frontend@3b286be · GitHub

Commit 3b286be

Browse files
committed
add transpilation step
1 parent 9d8d9dd commit 3b286be

12 files changed

Lines changed: 101 additions & 50 deletions

File tree

‎.babelrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"production": {
44
"presets": [
55
"latest"
6+
],
7+
"plugins": [
8+
"add-module-exports",
9+
"transform-es2015-modules-amd"
610
]
711
},
812
"development": {

‎.eslintignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66

77
# main app
88
static/src/stylesheets
9+
static/transpiled
910
static/vendor/javascripts
1011
static/src/javascripts-legacy/projects/common/utils/atob.js
1112
static/src/javascripts-legacy/projects/common/utils/picturefill.js

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ developer.properties
5858
*-spec-runner.html
5959

6060
static/hash
61+
static/transpiled
6162
static/target
6263
static/riffraff
6364

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
"any-observable": "^0.2.0",
1919
"autoprefixer": "^6.5.3",
2020
"aws-sdk": "~2.0.0-rc4",
21+
"babel-cli": "^6.18.0",
2122
"babel-core": "^6.21.0",
2223
"babel-loader": "^6.2.4",
24+
"babel-plugin-add-module-exports": "^0.2.1",
2325
"babel-plugin-transform-async-to-generator": "^6.16.0",
26+
"babel-plugin-transform-es2015-modules-amd": "^6.18.0",
2427
"babel-preset-env": "^1.1.4",
2528
"babel-preset-latest": "^6.16.0",
2629
"browser-sync": "^2.8.2",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const execa = require('execa');
2+
3+
const { src, transpiled } = require('../../config').paths;
4+
5+
module.exports = {
6+
description: 'Transpile',
7+
task: () => execa('babel', [`${src}/javascripts`, '--out-dir', `${transpiled}/javascripts`, '--ignore', 'eslintrc.js'], {
8+
env: {
9+
BABEL_ENV: 'production',
10+
},
11+
}),
12+
};
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const path = require('path');
22
const rimraf = require('rimraf');
33

4-
const { target, hash } = require('../../config').paths;
4+
const { target, hash, transpiled } = require('../../config').paths;
55

66
module.exports = {
77
description: 'Clear JS build artefacts',
88
task: () => {
99
rimraf.sync(path.resolve(target, 'javascripts'));
10+
rimraf.sync(path.resolve(transpiled, 'javascripts'));
1011
rimraf.sync(path.resolve(hash, 'javascripts'));
1112
},
1213
};

‎tools/__tasks__/compile/javascript/copy.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const cpy = require('cpy');
33

4-
const { vendor, target, hash } = require('../../config').paths;
4+
const { src, vendor, target, hash, transpiled } = require('../../config').paths;
55

66
module.exports = {
77
description: 'Copy 3rd JS party libraries',
@@ -23,5 +23,18 @@ module.exports = {
2323
parents: true,
2424
nodir: true,
2525
}),
26+
// copy the legacy (untranspiled es5) code to `transpiled`.
27+
// once that directory has been converted, this won't be needed.
28+
cpy(['**/*'], path.resolve(transpiled, 'javascripts'), {
29+
cwd: path.resolve(src, 'javascripts-legacy'),
30+
parents: true,
31+
nodir: true,
32+
}),
33+
cpy(['**/*'], path.resolve(transpiled, 'javascripts'), {
34+
cwd: path.resolve(src, 'javascripts'),
35+
parents: true,
36+
nodir: true,
37+
ignore: '*.js',
38+
}),
2639
]),
2740
};

‎tools/__tasks__/compile/javascript/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
require('./clean'),
55
require('../inline-svgs'),
66
require('./copy'),
7+
require('./babel'),
78
require('./rjs'),
89
require('./rjs--webpack'),
910
require('./webpack'),

‎tools/__tasks__/compile/javascript/rjs.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-unused-expressions */
22
({
3-
baseUrl: '../../../../static/src/javascripts',
3+
baseUrl: '../../../../static/transpiled/javascripts',
44
paths: {
55
admin: 'projects/admin',
66
common: 'projects/common',

‎tools/__tasks__/config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
module.exports = {
44
paths: {
55
target: path.join(__dirname, '../', '../', 'static', 'target'),
6+
transpiled: path.join(__dirname, '../', '../', 'static', 'transpiled'),
67
hash: path.join(__dirname, '../', '../', 'static', 'hash'),
78
src: path.join(__dirname, '../', '../', 'static', 'src'),
89
public: path.join(__dirname, '../', '../', 'static', 'public'),

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL