This repository was archived by the owner on Feb 18, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message when .tap() used on an undefined plugin (#271)
Previously if `.tap()` was called for a plugin that didn't exist, the `.tap()` call would succeed, but the `.toConfig()` would fail later with: `TypeError: Cannot read property '__expression' of undefined` This scenario can typically occur when trying to customise a plugin added by a previous preset (where the preset only sometimes adds the plugin, such as in development), and forgetting to add a conditional using `.has()` before calling `.tap()`. Whilst #270 changes that exception to a slightly more useful error message, it is still only shown at the time of the `.toConfig()`, where it's much harder to debug the cause. Now the `.tap()` call itself will show the error: `Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('foo').use(<Plugin>) first` Whilst this error check does technically break the (unlikely) scenario of calling `.tap()` in a preset before the plugin is defined by a later preset, that ordering was already broken, since the `.tap()`'s args would have been overwritten by the subsequent preset. Fixes #125.
- Loading branch information