Re-use babel transformations
Summary: SORRY FOR BIG DIFF, but it's really hard to split it as all these changes are cross-dependent and should be made at once: 1. Moved transformations to separate package "flipper-babel-transformer" and linked it using yarn workspaces to "static" and "pkg" packages where they are re-used. Removed double copies of transformations we had before int these two packages. 2. Converted transformations to typescript 3. Refactored transformations to avoid relying on file system paths for customisation (FB stubs and Electron stubs for headless build) 4. As babel transformations must be built before other builds - enabled incremental build for them and changed scripts to invoke the transformations build before other build scripts 5. As we need to deploy all the dependencies including the fresh "flipper-babel-transformer" as a part of "static" - implemented script which copies package with all the dependencies taking in account yarn workspaces (hoisting and symlinks) Reviewed By: passy, mweststrate Differential Revision: D20690662 fbshipit-source-id: 38a275b60d3c91e01ec21d1dbd72d03c05cfac0b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
07a6a3b87d
commit
c1bb656a0d
@@ -16,7 +16,13 @@ import fs from 'fs-extra';
|
||||
import {spawn} from 'promisify-child-process';
|
||||
import recursiveReaddir from 'recursive-readdir';
|
||||
import {default as getWatchFolders} from '../static/get-watch-folders';
|
||||
import {appDir, staticDir, pluginsDir, headlessDir} from './paths';
|
||||
import {
|
||||
appDir,
|
||||
staticDir,
|
||||
pluginsDir,
|
||||
headlessDir,
|
||||
babelTransformationsDir,
|
||||
} from './paths';
|
||||
|
||||
async function mostRecentlyChanged(
|
||||
dir: string,
|
||||
@@ -72,7 +78,10 @@ async function compile(
|
||||
watchFolders,
|
||||
serializer: {},
|
||||
transformer: {
|
||||
babelTransformerPath: path.join(staticDir, 'transforms', 'index.js'),
|
||||
babelTransformerPath: path.join(
|
||||
babelTransformationsDir,
|
||||
'transform-app',
|
||||
),
|
||||
},
|
||||
resolver: {
|
||||
resolverMainFields: ['flipper:source', 'module', 'main'],
|
||||
@@ -138,6 +147,7 @@ export async function compileRenderer(buildFolder: string) {
|
||||
|
||||
export async function compileMain({dev}: {dev: boolean}) {
|
||||
const out = path.join(staticDir, 'main.bundle.js');
|
||||
process.env.FLIPPER_ELECTRON_VERSION = require('electron/package.json').version;
|
||||
// check if main needs to be compiled
|
||||
if (await fs.pathExists(out)) {
|
||||
const staticDirCtime = await mostRecentlyChanged(staticDir, ['*.bundle.*']);
|
||||
@@ -147,14 +157,17 @@ export async function compileMain({dev}: {dev: boolean}) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(`⚙️ Compiling main bundle... ${staticDir}`);
|
||||
console.log('⚙️ Compiling main bundle...');
|
||||
try {
|
||||
const config = Object.assign({}, await Metro.loadConfig(), {
|
||||
reporter: {update: () => {}},
|
||||
projectRoot: staticDir,
|
||||
watchFolders: await getWatchFolders(staticDir),
|
||||
transformer: {
|
||||
babelTransformerPath: path.join(staticDir, 'transforms', 'index.js'),
|
||||
babelTransformerPath: path.join(
|
||||
babelTransformationsDir,
|
||||
'transform-main',
|
||||
),
|
||||
},
|
||||
resolver: {
|
||||
sourceExts: ['tsx', 'ts', 'js'],
|
||||
|
||||
Reference in New Issue
Block a user