Dependencies
NoteCustom dependencies are only supported in
@tapcart/tapcart-cli^0.1.10
Tapcart supports importing most software packages to your custom blocks via the CLI.
React Component libraries are not supportedThe Tapcart ecosystem does not support React component libraries like @mui/material. For UI components, you should use the Tapcart component library.
Installing dependencies
This is done by adding the
dependencies to your project via tapcart dependency add command. For example:
yarn tapcart dependency add lodash 4.17.21This will add the lodash library to your app's dependencies. If a dependency
with the same name already exists at a different version, you'll be asked to
confirm the overwrite (or pass --force/-f to skip the prompt).
You must specify
which blocks you want to add the dependency to. This is done by editing the
block's config.json file.
{
"dependencies": ["lodash"]
}Then, you can import the dependency in your block's code.jsx file:
import * as _ from 'lodash';Pushing Dependencies
NoteYou must push dependencies to your application configuration so that your blocks will render correctly in the dashboard or mobile app.
yarn tapcart dependency pushThis will push the dependencies to your application configuration.
Listing and pulling dependencies
To see the dependencies currently configured in your local project:
tapcart dependency listIf you'd rather sync down your app's remote dependency configuration (for example, onto a new machine), overwriting your local configuration:
tapcart dependency pullRemoving a dependency
tapcart dependency remove lodashThis removes the dependency from your local tapcart.config.json. Don't forget to push afterward so the change is reflected on your application configuration.
Troubleshooting
Under the hood, dynamic imports are retrieved from esm.sh's CDN. You can test whether your package version will work by visiting https://esm.sh/PACKAGE_NAME@SEM_VER.
Updated 12 days ago
