Summary:
This diff makes flipper-server stand-alone servable as a single package.
It basically works as follows:
- (default) plugins are build as usually into static folder
- static folder is copied into flipper-server/static (as far as relevant)
- `flipper-server/src/index.tsx` is bundled into `flipper-server/dist/index.js`
- `flipper-ui-browser/src/index.tsx` is bundled into `flipper-server/static/bundle.js`
If flipper-server is started without the `--bundler` config, the `bundle.js` will be served statically, rather than starting up the Metro bundler with all the typical transforms (in a distributed version of the package those all wouldn't resolve)
Things to be done in next diffs:
* make sure plugins actually load in the non bundled setup
* make sure flipper-server gets published properly
* make sure build is created as part of CI
At the end of this stack, running `npx flipper-server` on any machine should basically be a viable approach to get flipper up and running locally :)
Reviewed By: nikoant
Differential Revision: D33171107
fbshipit-source-id: 4af8ac2699467a0b55283fe084640482700744c2
Summary: When bundling a production bundle of flipper-ui / flipper-server, noticed that a lot of irrelevant stuff ends up. Like: `jest`, `metro`, `testing-library`. The whole jungle basically. Will add safety checks in the next diffs that this no longer happens
Reviewed By: passy
Differential Revision: D33186531
fbshipit-source-id: 1e2034153c8c4a3fac02cd9ce27d99224223df7a
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/3188
Fixes failing typescript issue (probably case sensitivity thing, on windows it was complaining about `Metro` not being resolvable while we use `metro` everywhere). Put a `ts-ignore` on it, since the metro typings we use are empty anyway
Disabled a test that failed consistently on GH CI. Maybe timing or Node version issue?
Reviewed By: fabiomassimo
Differential Revision: D33191515
fbshipit-source-id: 18a143024824eeeafaffe4941df474591fb7b70a
Summary: This diff is some boyscouting on cleaning up our globals, and stop using them inconsistently icmw global or window
Reviewed By: aigoncharov
Differential Revision: D33171108
fbshipit-source-id: 400893e5f31523631a7ab6fda428524c751901f1
Summary:
This diff adds `types` fields on the compiler config for every project. This way we can make sure that for example node types and packages are not available in flipper-ui-core. Without an explicit types field, all types would be shared between all packages, and implicitly included into the compilation of everything. For the same reason `types/index.d.ts` has been removed, we want to be intentional on which types are being used in which package.
This diff does most of the work, the next diff will fine tune the globals, and do some further cleanup.
As an alternative solution I first tried a `nohoist: **/node_modules/types/**` and make sure every package list explicitly the types used in package json, which works but is much more error prone, as for example two different react types versions in two packages will cause the most unreadable compiler error due to the types not being shared and not literally the same.
Reviewed By: lawrencelomax
Differential Revision: D33124441
fbshipit-source-id: c2b9d768f845ac28005d8331ef5fa1066c7e4cd7
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
Summary:
Bundled plugins so far didn't load because the defaultPlugins was not generated yet. Fixed follow up errors that resulted from node modules not being available in the browser, and made the process more robust so that one plugin that fails to initialise doesn't kill all bundled plugins from being loaded.
Cleaned up the server scripts, and reused the BUILTINS list that is already maintained in the babel transformer.
Report errors during the build process if modules are referred that are stubbed out (later on we could maybe error on that)
Reviewed By: aigoncharov
Differential Revision: D33020243
fbshipit-source-id: 3ce13b0049664b5fb19c1f45f0b33c1d7fdbea4c
Summary: During startup the socket connection would close a few times, among others because Scribe dumps 1.3 MB of data after startup, and the maximum payload of `socket.io` defaults to 1MB. This diff changes it to 100MB (the max size used by `ws` library). We know that we need at least > 10 MB, as that is what plugins like Network cap at.
Reviewed By: aigoncharov
Differential Revision: D33017653
fbshipit-source-id: 1233af6fbdc4b9eed42786ee418cfd6d43b2b433
Summary: Even with the `--no-bundled-plugins` flag, still a hundred plugins were loaded when running flipper-server
Reviewed By: timur-valiev, aigoncharov
Differential Revision: D32987158
fbshipit-source-id: 19e51e7e5f8ec9e664eb48cf2f2b8936f2f5ed73
Summary: As a convenience, open the browser by default when starting up
Reviewed By: timur-valiev
Differential Revision: D32984536
fbshipit-source-id: 540abf594f2f2553880f587bcd7d4811ea36fe74
Summary: This diffs adds debugging support to flipper server, by adding VSCode config for it
Reviewed By: timur-valiev, aigoncharov
Differential Revision: D32982874
fbshipit-source-id: 8e187ad05a05566a598db04b97e8b08e3de7e835
Summary:
The build process for the server was a simple ts-node that compiled all deps. However, that didn't do any source transformations we need, like replacing `fb-stubs` with `fb` in facebook builds.
This diff works out the dev build process to align more with how other parts of the code base is build, by starting metro to build and bundle the server (only the sources of flipper-server, flipper-server-core and other flipper packages are bundled, node-deps are left as is).
To achieve this, since metro doesn't have support for 'external' packages like any arbitrarily other bundler, we recycle the electronRequire work around that is used in the desktop app as well
Reviewed By: aigoncharov
Differential Revision: D32949677
fbshipit-source-id: 00d326bb17b68aece6fb43af98d0def13b335e74
Summary:
Forbid imports from nested directories of flipper-common, flipper-plugin, flipper-ui-core
In the stack of D32926830 I occasionally imported from flipper-plugin/src/... which is not allowed. This should fix any auto-import related issues once and for all.
Reviewed By: timur-valiev
Differential Revision: D32987054
fbshipit-source-id: f19f6278219961ad283cacfec094a6c703ca93f8
Summary:
This diff splits Facebook management into a ui-core and electron part:
* Cleaned up code and introduces a uniform Icon type to describe a requested icon
* Computing icon urls is done in the ui-core
* Introduced a RenderHost hook that can transform the request icon into a different url, in this case, a url to load icons from disk in production builds
For the browser UI, the urls are currently no rewritten since we have only dev builds (which always used only FB urls already). We could do the same rewrite in the future and download the static assets during build time. But for now this means that in the browser implementation we depend on normal browser caching, with the biggest downside that icons might not appear if the user has no internet connections.
With this change we lost our last usage of staticPath computations in ui-core
Reviewed By: aigoncharov
Differential Revision: D32767426
fbshipit-source-id: d573b6a373e649c7dacd380cf63a50c2dbbd9e70
Summary: Introduced an API that converts a filepath, relatively to the `desktop/static/` folder in a url that can be resolved by the render environment. This will generate `file://` urls in Electron, and root relative `/` urls in browser envs
Reviewed By: aigoncharov
Differential Revision: D32767427
fbshipit-source-id: 378da7709bcb19449873358a8703b9c5a5809c57
Summary: This diff makes most stuff that is read from the `os` package, and version info etc available from the `serverConfig` object, so that flipper-ui-core no longer needs the `os` package.
Reviewed By: passy
Differential Revision: D32694848
fbshipit-source-id: 93af1e95d898da9aaf351a6970b5a7652ee835c8
Summary: This diff makes plugin loading async, which we'd need in a browser env (either because we'd use `import()` or we need to fetch the source and than eval it), and deals with all the fallout of that
Reviewed By: timur-valiev
Differential Revision: D32669995
fbshipit-source-id: 73babf38a6757c451b8200c3b320409f127b8b5b
Summary:
Follow up of D32665064, this diff moves all plugin management logic from flipper-ui to flipper-server. Things like downloading, installing, querying new plugins.
Loading plugins is handled separately in the next diff.
Reviewed By: nikoant
Differential Revision: D32666537
fbshipit-source-id: 9786b82987f00180bb26200e38735b334dc4d5c3
Summary:
This diff moves RenderHost initialisation to jest, which is thereby treated as just another 'Host' like flipper-ui, the electron app etc. A benefit is that it provides a mocked flipperServer by default that can be used to mock or intercept requests. See LaunchEmulator.spec as example.
Also made the jest setup scripts strongly typed by converting them to TS.
This change allows the test stub configuration, which was OS dependent, out of flipper-ui-core.
Reviewed By: nikoant
Differential Revision: D32668632
fbshipit-source-id: fac0c09812b000fd7d1acb75010c35573087c99f
Summary: Moved all types related to plugin descriptions from plugin-lib (which handles downloads and such) to flipper-common. The goal of that is to remove all plugin-lib usage from ui-core to server-core, so that the UI itself doesn't do any file operations anymore related to plugins. That will be done in next diffs, this just moves types but no code.
Reviewed By: nikoant, aigoncharov
Differential Revision: D32665064
fbshipit-source-id: 86d908e7264569b0229b09290a891171876c8e00
Summary:
perf_hooks is no longer needed as these APIs are widely available in both browser and electron.
Still needed in unit tests, as they run from Node
Reviewed By: lblasa, aigoncharov
Differential Revision: D32648253
fbshipit-source-id: 5718ea99b57f96f6858311fd0815ad18c476c99e
Summary:
Watch folders weren't updated for cross plugin/flipper boundaries that have recently been removed
Fix changes in several source folders not being picked up when fast refresh wasn't enabled
Reviewed By: passy, aigoncharov
Differential Revision: D32626139
fbshipit-source-id: 2c830ec8154ff859ce1e3ee101e5963162d2e0a2
Summary:
1. Replace old FileSelector with the new FileSelector
2. Remove showOpenDialog from FlipperLib
Reviewed By: mweststrate
Differential Revision: D32667103
fbshipit-source-id: be8da034c2695f83b397b6c7d35bc6aee78d66e5
Summary:
Don't print console.debug logs during unit tests
These diffs together reduce the amounts of logs printed during unit tests from 6000 to 3000.
Reviewed By: passy
Differential Revision: D32557595
fbshipit-source-id: eef2b742157f16638d9ce270cf8b3d8d0f4e2952
Summary: In the next diff, tests started to fail suddenly, probably as side effect of a changed module loading order or smthg, and started showing DOMs of different tests in test results. Figured that testing-library/react + jest doesn't automatically doesn't clean up the DOM as I hoped it would
Reviewed By: timur-valiev
Differential Revision: D32463402
fbshipit-source-id: 48d26badf774482e7320632e486dfc6358946484
Summary:
This diff moves all UI code from app/src to app/flipper-ui-core. That is now slightly too much (e.g. node deps are not removed yet), but from here it should be easier to move things out again, as I don't want this diff to be open for too long to avoid too much merge conflicts.
* But at least flipper-ui-core is Electron free :)
* Killed all cross module imports as well, as they where now even more in the way
* Some unit test needed some changes, most not too big (but emotion hashes got renumbered in the snapshots, feel free to ignore that)
* Found some files that were actually meaningless (tsconfig in plugins, WatchTools files, that start generating compile errors, removed those
Follow up work:
* make flipper-ui-core configurable, and wire up flipper-server-core in Electron instead of here
* remove node deps (aigoncharov)
* figure out correct place to load GKs, plugins, make intern requests etc., and move to the correct module
* clean up deps
Reviewed By: aigoncharov
Differential Revision: D32427722
fbshipit-source-id: 14fe92e1ceb15b9dcf7bece367c8ab92df927a70
Summary:
This diff removes most remaining Electron imports, by storing env and path constants on the RenderHost. As nice side effect those paths are all cached now as well.
To make sure RenderHost is initialised before Flipper itself, forced loading Flipper through a require. Otherwise the setup is super sensitive to circular import statements, since a lot of module initialisation code depends on those paths / env vars.
Reviewed By: nikoant
Differential Revision: D31992230
fbshipit-source-id: 91beb430902272aaf4b051b35cdf12d2fc993347
Summary:
This introduces a few more lints in fact because I renamed the icon functions
to make clear that they use sync methods under the hood.
Reviewed By: timur-valiev
Differential Revision: D31964701
fbshipit-source-id: d0beb58b5b301f5428fdbfe8c65784df0d86eaad
Summary:
I relied too much on the types which in this case don't help at all.
Filtering on a promise will just automatically get all values to pass.
Pull Request resolved: https://github.com/facebook/flipper/pull/3008
Test Plan: `yarn build --mac` works again on the GH checkout.
Reviewed By: mweststrate
Differential Revision: D31991576
Pulled By: passy
fbshipit-source-id: f632d29ddfc09b7130b68b4b17264fd30e1969ce
Summary:
Removed the Flipper QPL integration, see:
https://fb.workplace.com/groups/flippersupport/permalink/1200183003795689/
It complicates our build setup significantly, without actually being used anywhere for the past year. Apparently it doesn't solve a gap compared to the scuba logging we have already in place.
Reviewed By: passy
Differential Revision: D30911573
fbshipit-source-id: 836e2aba0c92c0eed9fed0dfb12bd8bdcb8c7d71
Summary: Mostly disabling warnings for scripts which are fine to use `console.error` directly.
Reviewed By: timur-valiev
Differential Revision: D30812956
fbshipit-source-id: 7fdc5bdf08f72d0d849ece6a4194d6a115d693f0
Summary: `yarn start` basically starves if watchman is still scanning the system, until that is completed (which took 40 minutes for me last time). Added a timeout of 1 minute, to signal that you can better to some dishes, instead of trying to hunt a bug that looks like an exception has been eaten somewhere (guess what I did..)
Reviewed By: timur-valiev
Differential Revision: D30806512
fbshipit-source-id: a2ebc3672d82f3388fc7b00f41c7e9c4f37794b3
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/2609
Make it possible to mark some tests to run on non-CI, or unix only
Reviewed By: nikoant
Differential Revision: D29813506
fbshipit-source-id: 140f8a4eaed5af3282ab9d139b46a52818be0934
Summary: Remove the duplicate function and centralise it as nikoant suggested.
Reviewed By: fabiomassimo
Differential Revision: D29548480
fbshipit-source-id: 3e931cc88198415017c557c6b7c81cb35c3f22c9
Summary: This makes it possible to save source maps to a separate folder so we can upload them from CI.
Reviewed By: nikoant
Differential Revision: D29521599
fbshipit-source-id: a137659092b7648858b97ecf5b5c60c88889517a
Summary:
Allows for optional generation of source maps while building plugins.
Caveat: This will leave a broken `//# sourceMappingURL` comment at the bottom. If you set it to `null`, as the documentation suggests, you will instead get an inlined source map in addition to the written one.
Reviewed By: nikoant
Differential Revision: D29265385
fbshipit-source-id: 1e21e49d2516ecc5909b086e7797736b298b86ab
Summary:
Not being able to have timestamps in Jest snapshots, as they would differ across machines required jumping through a lot of hoops.
Run this into once again more by a test suite that didn't trigger on CI, but failed for me locally.
With this fix everyone can happily commit time based snapshots and they will always be assumed to be running in UTC :)
Reviewed By: nikoant
Differential Revision: D29025759
fbshipit-source-id: 426d1b065afdd4a2ed75b47203b13fff0ece1272
Summary: This only matters in Flipper proper.
Reviewed By: cekkaewnumchai
Differential Revision: D28964466
fbshipit-source-id: 6fae980cb091900c9b8325f443a2a6a9e81bbfe6
Summary:
In public CI (only?), asset downloads sometimes fail with a spurious 404.
We already have retrying in place, but it will obviously not do that on a 500.
Reviewed By: nikoant
Differential Revision: D28744817
fbshipit-source-id: b6a185d8e9db45e02c6427233a0171b00c552751
Summary: This change allows passing a directory containing plugin packages to include them into Flipper distributive. This is used by release command on Sandcastle (see D28626715).
Reviewed By: passy
Differential Revision: D28628425
fbshipit-source-id: 9c5d7527721f99b43991bace0b5e2f3a4ede0d13
Summary: This diff fixes "build-plugin" script which is failing for fb-internal plugins, because "fb/package.json" not exist. Because of that release of "fb/mobilebuilds" plugin failed recently: https://www.internalfb.com/intern/sandcastle/job/13510799309874638.
Reviewed By: passy
Differential Revision: D28624924
fbshipit-source-id: e00da98cfef992f5d49045afc9d404764a0d13ac
Summary: Allow splitting package.json to public one and fb-internal one located in "fb/package.json". When plugin is packaged, fields in package.json are overwritten by fields from "fb/package.json" if they exist. This give us a way to specify additional metadata which only make sense internally (e.g. oncall and internal links to docs and support).
Reviewed By: mweststrate
Differential Revision: D28542101
fbshipit-source-id: c0167461897a994e5731aaf0fe625de052eda864
Summary:
Sorry for long diff! I can try to split it if necessary, but many changes here are 1-1 replacements / renames.
**Preambule**
Currently we bundle default plugins into the Flipper main bundle. This helps us to reduce bundle size, because of plugin dependencies re-use. E.g. if multiple plugins use "lodash" when they are bundled together, only one copy of "lodash" added. When they are bundled separately, the same dependency might be added to each of them. However as we're not going to include most of plugins into Flipper distributive anymore and going to rely on Marketplace instead, this bundling doesn't provide significant size benefits anymore. In addition to that, bundling makes it impossible to differentiate whether thrown errors are originated from Flipper core or one of its plugins.
Why don't we remove plugin bundling at all? Because for "dev mode" it actually quite useful. It makes dev build start much faster and also enables using of Fast Refresh for plugin development (fast refresh won't work for plugins loaded from disk).
**Changes**
This diff introduces new option "no-bundled-plugins" for "yarn start" and "yarn build" commands. For now, by default, we will continue bundling default plugins into the Flipper main bundle, but if this option provided then we will build each default plugin separately and include their packages into the Flipper distributive as "pre-installed" to be able to load them from disk even without access to Marketplace.
For "yarn start", we're adding symlinks to plugin folders in "static/defaultPlugins" and then they are loaded by Flipper. For "yarn build" we are dereferencing these symlinks to include physical files of plugins into folder "defaultPlugins" of the produced distributive. Folder "defaultPlugins" is excluded from asar, because loading of plugins from asar archive might introduce some unexpected issues depending on their implementation.
Reviewed By: mweststrate
Differential Revision: D28431838
fbshipit-source-id: f7757e9f5ba9183ed918d70252de3ce0e823177d
Summary: "plugin-build" command will produce dir with unpacked plugin sources in addition to tar package. This is required because for publishing to Marketplace we need to retrieve few files from the output package, like "readme.md" and "package.json" and it's better to have it already unpacked rather than pack and then unpack to get these files.
Reviewed By: passy
Differential Revision: D28409930
fbshipit-source-id: 51c8eeb848a72850a2f126eb91a563d52851ed41
Summary: Added an arg for "build-plugin" command to easily set min required flipper version when plugin is packaged. Before that we only saved engine version in Marketplace metadata, but it's better to save it into the package as well, so we can check compatibility for installed packages even when we have no Marketplace metadata for them.
Reviewed By: passy
Differential Revision: D28350276
fbshipit-source-id: 916d891540263a1f99c1f6d2033eb13e1c36d78f
Summary:
Changed retrieving of Flipper version. Now it will be always retrieved from package.json. Before this change we used "remote.app.getVersion()" API which instead returned electron version for dev builds, e.g. "11.2.3". This is not convenient, because we now use Flipper version to check plugin compatibility and unrelated Electron version here makes things more complicated. After this change, if version is not properly bumped then "0.0.0" will be used: 1) when running using "yarn start", 2) when local building with "yarn build --mac" without setting new version, 3) when running tests "yarn test".
In addition to that I added a new command-line argument and env var which allow overriding version number for Flipper. This is useful for testing plugin updates, because compatibility between plugins and Flipper is checked by comparing Flipper version with the min version set in the plugin metadata.
Reviewed By: passy
Differential Revision: D28287354
fbshipit-source-id: 2f9482080e3612b95a24300050d98150c6db6cb7
Summary: Fixed loading of source maps when dev server is running with --fast-refresh flag set. Looks like it was broken after last metro upgrade because it changed the way how module paths are passed to dev server. We also had a hack to workaround bug when requested module paths were malformed, but it looks this hack is not needed now, so I deleted it as well.
Reviewed By: passy
Differential Revision: D28120080
fbshipit-source-id: 03a39c9840da8f4c8c72be6189c0b71c62fac7f0
Summary:
This is not doing much in terms of size. We're talking 780 bytes after
PACK compression but we're losing a lot of information in our errors
(before have symbolication).
We may reenable this at some point but I think it might be safe to leave it to this.
Reviewed By: nikoant
Differential Revision: D27887636
fbshipit-source-id: 15affeac588db667914320cbd098f7041b8b9c09