Commit Graph

149 Commits

Author SHA1 Message Date
Michel Weststrate
54dacb7e5d Make sure icons are bundled
Summary: Make sure icons are prefetched for flipper-server prod builds, like we do for electron, so that the user doesn't need an internet connection to see icons

Reviewed By: nikoant

Differential Revision: D33296389

fbshipit-source-id: bfa92d78d8d77030238e5cca10d7aa6dcfb88e8b
2021-12-24 02:16:48 -08:00
Michel Weststrate
72fa481d27 Fix generation of bundled.json, make source maps work in prod builds
Summary:
This diff fixes several issues around loading plugin, such as:

* make suresource maps work in the flipper-server production build
* make sure default plugins are no symlinked, which wouldn't work anywhere else but on the the system where it was build
* support release channel param for flipper-server

Bundled flipper-server is now 42MB (with icons (see later diffs) and plugins
```
ll flipper-server-v0.0.0.tgz
-rw-r--r--  1 mweststrate  staff    42M 23 Dec 15:29 flipper-server-v0.0.0.tgz
```

Reviewed By: nikoant

Differential Revision: D33294677

fbshipit-source-id: 63538dc8127f883fee6a3608673ad11ce239b350
2021-12-24 02:16:48 -08:00
Michel Weststrate
b1d960e4c4 Make sure plugin loading works in NPX builds
Summary: Make sure non-bundled plugins load correctly . Note that sourcemaps don't load yet

Reviewed By: nikoant

Differential Revision: D33278639

fbshipit-source-id: 9951286ec6df65f33149e4687261a43e6c072c31
2021-12-24 02:16:48 -08:00
Michel Weststrate
86b6d2c99d Make flipper-server NPX-able
Summary: Make sure flipper-server is bundled in such a way that it is self-contained NPX-able. Also added some checks to make sure that dev dependencies don't accidentallly end up in in Flipper buidls

Reviewed By: nikoant

Differential Revision: D33190254

fbshipit-source-id: 443162e537d8ca9f956acac2d7bd52cbf0c92172
2021-12-24 02:16:48 -08:00
Michel Weststrate
6ff4abbc67 Make flipper-server stand-alone servable
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
2021-12-24 02:16:48 -08:00
Michel Weststrate
e46fcba0b2 Make sure that test stuff doesn't end up in bundles
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
2021-12-17 14:12:50 -08:00
Michel Weststrate
e0afebeb32 Disabled consistently failing OSS test (#3188)
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
2021-12-17 14:03:53 -08:00
Michel Weststrate
cea7be7fde Clean up globals
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
2021-12-17 10:04:23 -08:00
Michel Weststrate
5df34a337c Unshare global types
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
2021-12-17 07:36:07 -08:00
Michel Weststrate
dcfeb4a4d5 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
2021-12-16 14:54:59 -08:00
Michel Weststrate
5ce5d897c8 Make loading of bundled plugins working and robust
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
2021-12-13 05:48:17 -08:00
Michel Weststrate
3ef1923b29 Use uniform Socket message size to avoid disconnects
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
2021-12-13 05:48:17 -08:00
Michel Weststrate
7e9ad72baa Fix --no-bundled-plugins was not respected
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
2021-12-13 05:48:17 -08:00
Michel Weststrate
6f9983eb42 Add --open / --no-open to yarn flipper-server
Summary: As a convenience, open the browser by default when starting up

Reviewed By: timur-valiev

Differential Revision: D32984536

fbshipit-source-id: 540abf594f2f2553880f587bcd7d4811ea36fe74
2021-12-13 05:48:16 -08:00
Michel Weststrate
73c6e8ee05 Make flipper server debuggable
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
2021-12-13 05:48:16 -08:00
Michel Weststrate
ae56f2b62f change server build process to respect babel transforms
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
2021-12-13 05:48:16 -08:00
Andrey Goncharov
adb2573a1f Forbid imports from nested directories of flipper-common, flipper-plugin, flipper-ui-core
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
2021-12-10 06:36:12 -08:00
Michel Weststrate
2b2cbb1103 Move offline icon storage to app/
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
2021-12-08 04:30:57 -08:00
Michel Weststrate
86995e0d11 Introduce static resource URLs
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
2021-12-08 04:30:57 -08:00
Michel Weststrate
2a4fe77404 Extract environment config initialisation to server-core
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
2021-12-08 04:30:56 -08:00
Michel Weststrate
de59bbedd2 Make plugin loading async
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
2021-12-08 04:30:56 -08:00
Michel Weststrate
64747dc417 move plugin management from ui-core to server-core
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
2021-12-08 04:30:56 -08:00
Michel Weststrate
f9b72ac69e Move RenderHost initialisation to Jest
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
e7f841b6d2 Move flipper plugin from flipper-lib types to flipper-common
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
2bf8ae2364 Get rid of perf_hooks package in Flipper UI
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
2b81be6c29 Cleanup plugin watch folders
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
2021-12-08 04:30:54 -08:00
Andrey Goncharov
225a2a7e34 Refactor Stella plugin
Summary:
1. Replace old FileSelector with the new FileSelector
2. Remove showOpenDialog from FlipperLib

Reviewed By: mweststrate

Differential Revision: D32667103

fbshipit-source-id: be8da034c2695f83b397b6c7d35bc6aee78d66e5
2021-11-26 08:30:13 -08:00
Michel Weststrate
14c0a7965e Don't print debug logs in jest
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
2021-11-19 04:01:02 -08:00
Michel Weststrate
4dde5b4508 Unmount React tree automatically in tests
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
2021-11-17 02:40:29 -08:00
Michel Weststrate
7e50c0466a Move app/src (mostly) to flipper-ui-core/src
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
2021-11-16 05:29:21 -08:00
Michel Weststrate
2e7015388c Remove remaining Electron imports from product code: paths & env
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
2021-11-03 07:01:21 -07:00
Pascal Hartig
2525a5efd4 Fix Flipper lints #9
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
2021-10-28 05:47:40 -07:00
Pascal Hartig
f8117240af Fix async filtering (#3008)
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
2021-10-28 05:36:52 -07:00
Michel Weststrate
75b5783fd0 Clean up QPL integration
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
2021-09-14 02:55:01 -07:00
Pascal Hartig
50f19ed3a0 Fix Flipper lints #17
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
2021-09-13 02:32:07 -07:00
Michel Weststrate
c3b2fe836d Fix issue where Flipper start starved
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
2021-09-08 09:59:38 -07:00
Michel Weststrate
a78b6124d7 Add option to jest to run tests only locally, or on linux (#2609)
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
2021-07-21 05:43:11 -07:00
Pascal Hartig
0e1f8e45ec Refactor out strip source map fn
Summary: Remove the duplicate function and centralise it as nikoant suggested.

Reviewed By: fabiomassimo

Differential Revision: D29548480

fbshipit-source-id: 3e931cc88198415017c557c6b7c81cb35c3f22c9
2021-07-05 06:37:09 -07:00
Pascal Hartig
04616ad647 Allow saving source maps during build
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
2021-07-05 06:05:43 -07:00
Anton Nikolaev
9fc85730ba Show plugin documentation in Flipper
Reviewed By: passy

Differential Revision: D29392524

fbshipit-source-id: 675de1fc070b1b8b22d0b27721c16dbd6f7076ef
2021-06-29 13:02:05 -07:00
Pascal Hartig
8df81d2dc0 Generate source maps for releases
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
2021-06-21 11:11:38 -07:00
Michel Weststrate
db3d0486e7 Make sure all tests run in same TimeZone
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
2021-06-10 13:00:49 -07:00
Pascal Hartig
f18a00d451 Ignore naked console.error in build script
Summary: This only matters in Flipper proper.

Reviewed By: cekkaewnumchai

Differential Revision: D28964466

fbshipit-source-id: 6fae980cb091900c9b8325f443a2a6a9e81bbfe6
2021-06-10 05:22:28 -07:00
Pascal Hartig
6d1cecdeee Retry icon download
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
2021-05-27 06:26:48 -07:00
Anton Nikolaev
8d508c8634 Build script updated to allow specifying directory with default plugins
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
2021-05-25 01:41:57 -07:00
Anton Nikolaev
d57c4d687c Fix build-plugin script
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
2021-05-24 02:46:42 -07:00
Anton Nikolaev
5ae104cc59 Merge plugin package.json from public and fb-internal parts
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
2021-05-21 07:15:28 -07:00
Anton Nikolaev
a4eb2a56d6 Option for "yarn start" and "yarn build" scripts to pre-install default plugin packages instead of bundling them
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
2021-05-18 08:08:30 -07:00
Anton Nikolaev
b5d8f6c63d Output unpacked plugin dir in addition to tar from "build-plugin" command
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
2021-05-13 05:32:07 -07:00
Anton Nikolaev
ef091e7a07 Allow specifying min required Flipper version on "build-plugin" command call
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
2021-05-12 07:49:13 -07:00