1 | // DEVELOPMENT BABEL SHIM
|
2 | // =============================================================================
|
3 | // Use babel-register to JIT transpile the ES6/ES7 code in the webapp. It's
|
4 | // essentially a convenience shim, otherwise all webapp code would have to be
|
5 | // written Node compatible (annoying), not rendered serverside (bad for SEO), or
|
6 | // transpiled and then served (slow for development).
|
7 |
|
8 | const path = require('path');
|
9 |
|
10 | let config;
|
11 |
|
12 | try {
|
13 | // Worth noting that the .babelrc specified in this file is slightly different
|
14 | // from what the webpack config specifies. This is due to the webpack-hmr
|
15 | // transform needing to be present in the babel loader, but not in the server.
|
16 |
|
17 | config = JSON.parse(require('fs').readFileSync('.babelrc')); // eslint-disable-line global-require
|
18 | } catch (error) {
|
19 | console.error('Error parsing .babelrc: ', error);
|
20 | }
|
21 |
|
22 | require('babel-register')(config);
|
23 | require('babel-polyfill');
|
24 |
|
25 | process.argv.forEach((val) => {
|
26 | if (val.startsWith('--entry=')) {
|
27 | require(path.resolve(val.split('=').pop())); // eslint-disable-line
|
28 | }
|
29 | });
|