[client-app] symlink in babelrc and resolve links

Summary:
The prod build was failing because it couldn't find the .babelrc.

I decided to put the babelrc in the main nylas-mail repo with the
expectation that it'll need to be in the open source version too. To DRY
up this for us building, we sylink the root one to the client-app babelrc

Also since we now dereference symlinks we don't need to do the full copy
of nylas-private-resources so we don't have two error reporters floating
around

Test Plan: npm run build-client

Reviewers: juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D3993
This commit is contained in:
Evan Morikawa 2017-02-21 16:08:59 -05:00
parent 776cf26d7a
commit 3071856a8e
5 changed files with 19 additions and 19 deletions

View file

@ -1,7 +0,0 @@
{
"presets": [
"electron",
"react"
],
"sourceMaps": "inline"
}

1
.babelrc Symbolic link
View file

@ -0,0 +1 @@
packages/client-app/.babelrc

View file

@ -0,0 +1,7 @@
{
"presets": [
"electron",
"react"
],
"sourceMaps": "inline"
}

View file

@ -57,6 +57,7 @@ module.exports = (grunt) => {
console.log("---> Resolving symlinks");
const dirs = [
'internal_packages',
'src',
'node_modules',
];
@ -280,14 +281,14 @@ module.exports = (grunt) => {
grunt.registerTask('packager', 'Package build of Nylas Mail', function pack() {
const done = this.async();
const start = Date.now();
console.log('---> Running build with options:');
console.log(util.inspect(grunt.config.get('packager'), true, 7, true));
let time = 1;
const ongoing = setInterval(() => {
console.log(`---> Packaging for ${time}s`);
time += 1;
const elapsed = Math.round((Date.now() - start) / 1000.0)
console.log(`---> Packaging for ${elapsed}s`);
}, 1000)
resolveRealSymlinkPaths(grunt.config('appDir'))

View file

@ -15,9 +15,7 @@ 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.
//
// TODO: Please fix babelrc reference for the build.
const babelPath = path.resolve(path.join(__dirname, "../../../../.babelrc"))
const babelPath = path.resolve(path.join(__dirname, "../../.babelrc"))
var defaultOptions = JSON.parse(fs.readFileSync(babelPath));
defaultOptions.presets = (defaultOptions.presets || []).map((modulename) =>
require.resolve(`babel-preset-${modulename}`)

View file

@ -21,11 +21,11 @@ function unlinkIfExistsSync(p) {
}
}
function copyErrorLoggerExtensions(privateDir) {
const from = path.join(privateDir, 'src')
const to = path.resolve(path.join('packages', 'client-app', 'src'))
unlinkIfExistsSync(path.join(to, 'error-logger-extensions'));
fs.copySync(from, to);
function linkErrorLoggerExtensions(privateDir) {
const from = path.join(privateDir, 'src', 'error-logger-extensions')
const to = path.resolve(path.join('packages', 'client-app', 'src', 'error-logger-extensions'))
unlinkIfExistsSync(to);
fs.symlinkSync(from, to, 'dir');
}
async function installPrivateResources() {
@ -36,7 +36,7 @@ async function installPrivateResources() {
return;
}
copyErrorLoggerExtensions(privateDir)
linkErrorLoggerExtensions(privateDir)
// link private plugins
for (const plugin of fs.readdirSync(path.join(privateDir, 'packages'))) {