Clean up packages and types

Summary:
This diff removes most deps from the root package.json, which now only contains electron and shared build / test infra structure: lint, prettier, jest, typescript.

This makes it possible to control much better which packages are used where, as all sub packages now have their deps explicitly in their package.json instead of incidentally shared. This allows for example to disable DOM types for all packages by default (flipper-plugin, ui(-core) and app still request it), and in the next diff I hope to add to this that nodeJS types are no longer shared either, so that UI oriented packages will generate compile errors when using Node built-ins

This diff removes most deps that were currently unused, and dedupes a bunch of other ones, so the build should probably be a bit smaller now as well:

{F686704253}

{F686704295}

Reviewed By: antonk52

Differential Revision: D33062859

fbshipit-source-id: 5afaa4f2103d055188382a3370c1fffa295a298a
This commit is contained in:
Michel Weststrate
2021-12-16 14:51:27 -08:00
committed by Facebook GitHub Bot
parent 78413c1ecf
commit dcfeb4a4d5
42 changed files with 303 additions and 1400 deletions

View File

@@ -29,14 +29,13 @@ import {
moveSourceMaps,
} from './build-utils';
import fetch from '@adobe/node-fetch-retry';
import {buildLocalIconPath, Icons} from '../app/src/utils/icons';
import isFB from './isFB';
import copyPackageWithDependencies from './copy-package-with-dependencies';
import {staticDir, distDir} from './paths';
import yargs from 'yargs';
import {WinPackager} from 'app-builder-lib/out/winPackager';
// eslint-disable-next-line no-restricted-imports
import {Icon, getPublicIconUrl} from 'flipper-ui-core/src/utils/icons';
// eslint-disable-next-line node/no-extraneous-import
import type {Icon} from 'flipper-ui-core';
// Used in some places to avoid release-to-release changes. Needs
// to be this high for some MacOS-specific things that I can't
@@ -159,7 +158,9 @@ async function modifyPackageManifest(
) {
// eslint-disable-next-line no-console
console.log('Creating package.json manifest');
// eslint-disable-next-line flipper/no-relative-imports-across-packages
const manifest = require('../package.json');
// eslint-disable-next-line flipper/no-relative-imports-across-packages
const manifestStatic = require('../static/package.json');
// The manifest's dependencies are bundled with the final app by
@@ -392,3 +393,20 @@ async function downloadIcons(buildFolder: string) {
console.log('✨ Done');
process.exit();
})();
export type Icons = {
[key: string]: Icon['size'][];
};
// should match flipper-ui-core/src/utils/icons.tsx
export function getPublicIconUrl({name, variant, size, density}: Icon) {
return `https://facebook.com/assets/?name=${name}&variant=${variant}&size=${size}&set=facebook_icons&density=${density}x`;
}
// should match app/src/utils/icons.tsx
function buildLocalIconPath(icon: Icon) {
return path.join(
'icons',
`${icon.name}-${icon.variant}-${icon.size}@${icon.density}x.png`,
);
}

View File

@@ -33,6 +33,7 @@ import {
browserUiDir,
} from './paths';
// eslint-disable-next-line flipper/no-relative-imports-across-packages
const {version} = require('../package.json');
const dev = process.env.NODE_ENV !== 'production';
@@ -344,6 +345,7 @@ export function buildFolder(): Promise<string> {
});
}
export function getVersionNumber(buildNumber?: number) {
// eslint-disable-next-line flipper/no-relative-imports-across-packages
let {version} = require('../package.json');
if (buildNumber) {
// Unique build number is passed as --version parameter from Sandcastle

View File

@@ -9,11 +9,12 @@
// jest-setup-after will run after Jest has been initialized, so that it can be adapted.
// eslint-disable-next-line node/no-extraneous-import
import {cleanup} from '@testing-library/react';
import {resolve} from 'path';
import os from 'os';
window.FlipperRenderHostInstance = createStubRenderHost();
(window as any).FlipperRenderHostInstance = createStubRenderHost();
import {TestUtils} from 'flipper-plugin';
import {
@@ -52,7 +53,7 @@ if (!test) {
beforeEach(() => {
// Fresh mock flipperServer for every test
window.FlipperRenderHostInstance = createStubRenderHost();
(window as any).FlipperRenderHostInstance = createStubRenderHost();
});
afterEach(cleanup);

View File

@@ -14,7 +14,7 @@ if (isFB && process.env.FLIPPER_FB === undefined) {
}
process.env.FLIPPER_TEST_RUNNER = 'true';
// eslint-disable-next-line import/no-unresolved
// eslint-disable-next-line import/no-unresolved,flipper/no-relative-imports-across-packages
const {transform} = require('../babel-transformer/lib/transform-jest');
module.exports = {

View File

@@ -0,0 +1,52 @@
{
"name": "flipper-scripts",
"private": true,
"version": "0.0.0",
"description": "Utility scripts to manage Flipper",
"repository": "facebook/flipper",
"license": "MIT",
"bugs": "https://github.com/facebook/flipper/issues",
"devDependencies": {
"@adobe/node-fetch-retry": "^2.0.0",
"@babel/code-frame": "^7.15.8",
"@types/adobe__node-fetch-retry": "^1.0.2",
"@types/babel__code-frame": "^7.0.3",
"@types/detect-port": "^1.3.1",
"@types/fs-extra": "^9.0.13",
"@types/node": "^15.12.5",
"ansi-to-html": "^0.7.2",
"app-builder-lib": "22.14.8",
"chalk": "^4.1.2",
"detect-port": "^1.1.1",
"dotenv": "^8.2.0",
"electron-builder": "22.11.7",
"express": "^4.15.2",
"fb-watchman": "^2.0.1",
"flipper-common": "0.0.0",
"flipper-pkg-lib": "0.0.0",
"flipper-plugin-lib": "0.0.0",
"fs-extra": "^9.0.0",
"glob": "^7.2.0",
"ignore": "^5.1.4",
"metro": "^0.66.2",
"metro-minify-terser": "^0.66.2",
"open": "^8.3.0",
"p-filter": "^2.1.0",
"p-map": "^4.0.0",
"promisify-child-process": "^4.1.0",
"socket.io": "^4.4.0",
"tmp": "^0.2.1",
"uuid": "^8.3.2",
"yargs": "^17.0.1"
},
"scripts": {
},
"files": [
"lib/**/*"
],
"homepage": "https://github.com/facebook/flipper",
"keywords": [
"Flipper"
],
"author": "Facebook, Inc"
}

View File

@@ -0,0 +1,24 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"lib": ["DOM", "ES2019"],
"noEmit": true,
"esModuleInterop": true
},
"references": [
{
"path": "../flipper-common"
},
{
"path": "../pkg-lib"
},
{
"path": "../plugin-lib"
},
{
"path": "../flipper-plugin"
}
]
}