Skip to content

Commit

Permalink
Merge b0a89bd into 78a6b96
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeyer2115 committed May 19, 2021
2 parents 78a6b96 + b0a89bd commit 3d699a5
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions hbshelpers/babel.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
const { transformSync } = require('@babel/core');

/**
* Babel-ifies the enclosed code, using the config below.
* Babel-ifies the enclosed code, using the config below. Note that if the
* IS_DEVELOPMENT_PREVIEW environment variable is set to 'true', the enclosed
* code is returned verbatim. This is an optimization for the build preview.
*
* @param {import('handlebars').HelperOptions} options
* @returns {string|null}
*/
module.exports = function babel(options) {
const srcCode = options.fn(this);
return transformSync(srcCode, {
compact: true,
minified: true,
comments: false,
sourceType: 'script',
presets: ['@babel/preset-env'],
plugins: [
'@babel/syntax-dynamic-import',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-object-assign',
]
}).code;

if (process.env.IS_DEVELOPMENT_PREVIEW === 'true' ) {
return srcCode;
} else {
return transformSync(srcCode, {
compact: true,
minified: true,
comments: false,
sourceType: 'script',
presets: ['@babel/preset-env'],
plugins: [
'@babel/syntax-dynamic-import',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-object-assign',
]
}).code;
}
};

0 comments on commit 3d699a5

Please sign in to comment.