Plugin refactor
Description:
The goal of this refactor is to remove plugins from the core-js, and client-js packages and improve their composability with resolvers This PR introduces a new plugin-js package where the PluginWrapper and PluginPackage classes are located.
Features:
- client-js
- Polywrap Client now re-exports the config builder and uri-resolvers (in addition to core) packages. This is done to improve dev exp and remove the need for users to import those package themselves.
- For users who do not need those package and are using
noDefaultsthere will be a separate PR that refactor core client functionality into a core-client package that does not depend on the config builder and uri-resolvers packages, but has no defaults.
- For users who do not need those package and are using
- Polywrap Client now re-exports the config builder and uri-resolvers (in addition to core) packages. This is done to improve dev exp and remove the need for users to import those package themselves.
- config-builder-js
- Added
addRedirects,addWrappers,addPackagesmethods to theClientConfigBuilder, so users can add many items at once. - Added
buildDefaultto theClientConfigBuilderwhich builds aClientConfigusing default resolvers.
- Added
- plugin-js
- New package for plugins
- Can create plugin packages with
PluginPackage.from- Accepts
manifestand aPluginModuleor an inlinePluginModule
- Accepts
- uri-resolvers-js
- Added
StaticResolverandStaticResolver.fromto optimize building resolvers withIUriRedirect,IUriWrapperandIUriPackage.
- Added
- schema-bind-js
- In the module template,
PluginModuleis now imported fron plugin-js instead of core-js
- In the module template,
Breaking changes:
- client-js
- The Polywrap Client with
noDefaults: falseno longer accepts apluginsfield, but it acceptswrappersandpackages.resolverfield has been replaced withresolvers, since with default client the resolver used is theRecursiveResolverwith thePackageToWrapperCacheResolver.
- The Polywrap Client with
noDefaults: true, no longer accepts apluginsfield. It is expected that devs using this option will manually configure their own resolver. - removed
getPluginsandgetPluginByUri. Will addgetWrapper,getWrapperByUri,getPackage,getPackageByUri, in a follow up PR. createPolywrapClientfunction has been deleted from the client-js package as it is unnecessary
- The Polywrap Client with
- config-builder-js
- Now uses the
CustomClientConfigwhich doesn't havepluginsand aresolver, but now haswrappers,packagesandresolvers - Calling build returns an instance of the
CustomClientConfig, which can be used with defaults from thePolywrapClient, but can not be used ifnoDefaults: trueis passed to thePolywrapClientconstructor. - Removed
addPluginfrom theClientConfigBuilder, users can now useaddWrapperoraddPackagewhere appropriate. - Renamed
addUriRedirecttoaddRedirectto keep it inline withaddWrapperandaddPackage(IUriRedirect, IUriWrapper, IUriPackage)
- Now uses the
- core-js
- Plugins are no longer a part of this package, they have been moved to the plugin-js package
- Renamed
UriRedirecttoIUriRedirectto matchIUriWrapperandIUriPackage IUriRedirect,IUriWrapperandIUriPackageare now generic and their generic param implementsUri | string- Removed
optionsargument fromclient.getManifestmethod since all wrappers have a deserialized manifest
- react-js
- Replaced
pluginson thePolywrapProviderwithwrappersandpackages
- Replaced
- uri-resolvers-js
- Replaced helper func
buildUriResolverwithUriResolver.from - Constructors of built-in resolvers like
RecursiveResolverandPackageToWrapperCacheResolvernow accept a concreteIUriResolverwhile their staticfrommethods accept aUriResolverLike - Remove
PluginsResolverandPluginResolver, users can now useWrapperResolverorPackageResolver
- Replaced helper func
This pull request introduces 200 alerts when merging f4b5f9280ee1d139aa1dada9f22cfe6d34b43b78 into dadd0f8f957f0eb6aa5b3a542a65fb798006a428 - view on LGTM.com
new alerts:
- 197 for Syntax error
- 3 for Unused variable, import, function or class
This pull request introduces 6 alerts when merging 2f11deedca9a302e13a66368375dbe0149b3f93e into 30f7f64f342d610f997af5daeaff0eb4b59d8f2d - view on LGTM.com
new alerts:
- 6 for Unused variable, import, function or class
nit feel free to ignore: i am noticing a pattern in plugin tests where we have a
getClientfunction - would it makes sense to use the config builder so we start to use this pattern in the toolchain?
@cbrzn
Only in the places where we want to test the config builder and or the default client config.
Ideally, tests test just a single functionality, so they should depend on the least amount of deps and use a client with only the necessary packages configured.
That's why in most of the tests I'm using noDefaults: true on the client ctor.