Skip to content

Commit

Permalink
docs: add npm link documentation for local development (apache#201)
Browse files Browse the repository at this point in the history
* NPM link docs (hat tip to Krist)

* formatting changes in prior commit
  • Loading branch information
rusackas authored and zhaoyongjie committed Nov 26, 2021
1 parent b0b0cdf commit a02a3be
Showing 1 changed file with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ superset-ui/
...
```



### Installation

1. clone this repo
Expand All @@ -97,6 +99,69 @@ yarn install
yarn build
```

### Activating plugins for local development

1. Enable `npm link` for the package.

```sh
cd superset-ui
cd packages/superset-ui-chart
npm link
```

2. Link the local package to `incubator-superset`.

```sh
cd incubator-superset
cd superset/assets
npm link @superset-ui/chart \# use package name in package.json, not directory name
```

3) After npm link complete, update the import statements in Superset.

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'
```

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`.

```cd incubator-superset
cd superset/assets
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
```

### Builds, linting, and testing

Each package defines its own build config, linting, and testing. You can have lerna run commands
Expand Down

0 comments on commit a02a3be

Please sign in to comment.