diff --git a/src/compile-support/babel.js b/src/compile-support/babel.js index 36ffe828a..52bafcee5 100644 --- a/src/compile-support/babel.js +++ b/src/compile-support/babel.js @@ -2,7 +2,6 @@ var crypto = require('crypto') var path = require('path') -var defaultOptions = require('../../static/babelrc.json') var babel = null var babelVersionDirectory = null @@ -12,6 +11,14 @@ var babelVersionDirectory = null // babel-polyfill. require('babel-regenerator-runtime'); +// We run babel with lots of different working directories (like plugin folders). +// To make sure presets always resolve to the correct path inside N1, resolve +// them to their absolute paths ahead of time. +var defaultOptions = require('../../static/babelrc.json') +defaultOptions.presets = defaultOptions.presets.map((modulename) => + require.resolve(`babel-preset-${modulename}`) +); + exports.shouldCompile = function (sourceCode, filePath) { return (filePath.endsWith('.es6') || filePath.endsWith('.jsx')) }