Testing with Radpack
Table of contents
There are two main features provided with radpack out of the box to aid with testing of shared dependencies: one for local development and one for soft deployments.
Local Proxy
If you want to test a radpack export in your local application before deploying changes to the export, this is easily achieved by leveraging the radpack local
CLI. This command effectively detects for changes in node_modules
(for radpack exports only), and serves a dynamic radpack.json
registry via a URL set in process.env.RADPACK_LOCAL
.
The radpack local
command has quite a few options (see radpack local --help
), but most of the defaults should suffice.
By using the radpack local
service for loading bundles from the browser or Node, you can serve a radpack.json
that reflects your locally linked radpack dependencies.
Also be sure to check out examples/clients/basic
for a working example.
Node Middleware
As demonstrated in the server usage document, middleware may be leveraged to provide per-route testing of a radpack.json
registry that is not yet live. This is also referred to as a soft deployment.
Example
The role of the middleware is to detect a ?radpack=URL
querystring and load the desired registry by setting res.locals.radpack
to a unique instance to avoid conflict with the shared global instance.
Client Middleware
Just kidding! This middleware is not yet available. But the querystring behavior provided by the Node Middleware would be easy enough to emulate on the client if desired.
Next
Check out frequently asked questions.