Skip to content

Commit

Permalink
Merge pull request #72 from LeoPlatform/CAT-1026-upgrade-to-use-custo…
Browse files Browse the repository at this point in the history
…m-babelify

Added custom babelify loader at a per-project level
  • Loading branch information
chubshaun authored Jun 21, 2022
2 parents b4cef57 + 9714a49 commit 7db50e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,26 @@ function buildLambdaDirectory(rootDir, opts, callback) {
},
debug: true
});

let babelPresets = [
[path.resolve(__dirname, "../node_modules/babel-preset-env"), {
"targets": {
"node": "8"
}
}]
];

// added to allow usage of upgraded @babel/preset-env transformers to support later versions of Node while
// still preserving backwards compatibility of leo-cli's older babel-related packages (6x)
try {
babelify = require.resolve("babelify", { paths: [rootDir] });
babelPresets = []; // blow away set presets otherwise .babelrc presets will not be used
} catch(e) {
// use the older babelify/transformer
}

b.transform(babelify, {
presets: [
[path.resolve(__dirname, "../node_modules/babel-preset-env"), {
"targets": {
"node": "8.10"
}
}]
],
presets: babelPresets,
sourceMaps: false
});

Expand Down Expand Up @@ -852,7 +864,7 @@ function writeCloudFormation(rootDir, opts, program, config, callback) {
if (program.saveCloudFormation && config._meta && config._meta.microserviceDir) {
fs.writeFileSync(`${config._meta.microserviceDir}/cloudformation.json`, JSON.stringify(cf, null, 2));
}

fs.writeFileSync(`${opts.buildDir}/cloudformation-${now}.json`, JSON.stringify(cf, null, 2));
if (opts.variations && Array.isArray(opts.variations) && opts.variations.length) {
opts.variations.map(v => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leo-cli",
"version": "3.0.1",
"version": "3.0.2",
"description": "A Nodejs interface to interact with the Leo SDK and AWS",
"repository": {
"type": "git",
Expand Down

0 comments on commit 7db50e7

Please sign in to comment.