From 43d7d6008df2e04ca91dcf6a393c3f3798eb705a Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Wed, 27 May 2020 10:36:51 -0700 Subject: [PATCH] docs: simplified npm link for dev debugging (#546) --- .../superset-ui/docs/debugging.md | 75 +++++-------------- .../superset-ui/docs/storybook.md | 23 +----- 2 files changed, 18 insertions(+), 80 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/docs/debugging.md b/superset-frontend/temporary_superset_ui/superset-ui/docs/debugging.md index caa6ef2e18ff..87568978e6fd 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/docs/debugging.md +++ b/superset-frontend/temporary_superset_ui/superset-ui/docs/debugging.md @@ -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. diff --git a/superset-frontend/temporary_superset_ui/superset-ui/docs/storybook.md b/superset-frontend/temporary_superset_ui/superset-ui/docs/storybook.md index 63a37d23eaea..048a55ddd2cb 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/docs/storybook.md +++ b/superset-frontend/temporary_superset_ui/superset-ui/docs/storybook.md @@ -8,25 +8,4 @@ yarn build yarn storybook ``` -### Tips - -When developing, if you would like to see live changes in Storybook. - -Instead of - -```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'; -``` - -Then after you are satisfied with all the changes, `yarn build` the entire project and remove `/src` -from the `import` statement and check Storybook again. This rarely happens, but the minification -sometimes can cause issue and you may see different results ranging from crashing to different -behavior. +The Storybook will [automatically build from the source code](https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-demo/.storybook/main.js#L49-L58) when package names start with `@superset-ui/`. \ No newline at end of file