This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: simplified npm link for dev debugging (#546)
- Loading branch information
Showing
2 changed files
with
18 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,25 @@ | ||
## Debugging Superset plugins in Superset app | ||
# Debug Superset plugins in Superset app | ||
|
||
### Activating plugins for local development | ||
## Activate plugins for local development | ||
|
||
1. Enable `npm link` for the package. | ||
1. First, make sure you have run `yarn` and `yarn build` in `superset-ui` or your own plugin repo. | ||
2. Go to [sueprset-frontend](/~https://github.com/apache/incubator-superset/tree/master/superset-frontend), | ||
use `npm link` to create a symlink of the plugin source code in `node_modules`: | ||
|
||
```sh | ||
cd superset-ui | ||
cd packages/superset-ui-chart | ||
npm link | ||
``` | ||
```sh | ||
cd incubator-superset/superset-frontend | ||
# npm link ~/path/to/your/plugin | ||
npm link ../../superset-ui/plugins/plugin-chart-word-cloud | ||
``` | ||
|
||
2. Link the local package to `incubator-superset`. | ||
3. Start developing with webpack dev server: | ||
|
||
```sh | ||
cd incubator-superset/superset-frontend | ||
npm link @superset-ui/chart \# use package name in package.json, not directory name | ||
``` | ||
```sh | ||
npm run dev-server | ||
``` | ||
|
||
3. After npm link complete, update the import statements in Superset. | ||
The dev server will automatically build from the source code under `path/to/your-plugin/src` and watch the changes. | ||
|
||
Instead of | ||
## Deactivate plugins | ||
|
||
```js | ||
import { xxx } from '@superset-ui/plugin-chart-horizon'; | ||
``` | ||
|
||
which will point to the transpiled code. | ||
|
||
do refer to `src` | ||
|
||
```js | ||
import { xxx } from '@superset-ui/plugin-chart-horizon/src'; | ||
``` | ||
|
||
4. After that you can run `dev-server` as usual. | ||
|
||
```sh | ||
npm run dev-server | ||
``` | ||
|
||
Now when you change the code in `@superset-ui`, it will update the app immediately similar to code | ||
inside `incubator-superset`. | ||
|
||
### Deactivating plugins for local development | ||
|
||
1. Change the `import` statements back. | ||
|
||
2. Unlink the package from `incubator-superset`. | ||
|
||
```sh | ||
cd incubator-superset/superset-frontend | ||
npm unlink @superset-ui/chart | ||
``` | ||
|
||
Note: Quite often, `npm link` mess up your `node_modules` and the `unlink` command above does not | ||
work correctly, making webpack build fails or other unexpected behaviors. If that happens, just | ||
delete your `node_modules` and `npm install` from scratch. | ||
|
||
3. Clean up global link. | ||
|
||
```sh | ||
cd superset-ui | ||
cd packages/superset-ui-chart | ||
npm unlink | ||
``` | ||
To deactivate a plugin, simply run `npm install` in `incubator-superset/superset-frontend` again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3399bff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: