Skip to content

Commit

Permalink
Merge pull request #492 from act-org/jc-npm-pack
Browse files Browse the repository at this point in the history
docs: Add instructions for creating local builds using `npm pack`
  • Loading branch information
joncursi authored Nov 13, 2024
2 parents ed7593d + 1c15adf commit 464f792
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,41 @@ To run the DLS locally:

### How to Iterate Locally

For rapid iteration, you can run a local build of this library in your
#### Option 1: Creating a Local Build

When you're ready to pilot your changes to this library in your local project:

1. Run the `npm run pack` command. When it finishes running, it will generate a
`.tgz` file in the `/dist` folder with the following name format
`actinc-dls-<version-number>.tgz`;
2. Access the `package.json` file of your local project in which the
`@actinc/dls` package will be tested, and make the following edit:

```json
"dependencies": {
// Before (pulling from NPM via version number):
"@actinc/dls": "9.2.1",
// After (pointing to the local .tgz file):
"@actinc/dls": "file:../path/to/@actinc/dls/dist/actinc-dls-<version-number>.tgz",
...
}
```

3. Run `npm update @actinc/dls` to refresh your project's `node_modules` folder.

4. You can now run your project with the local changes made to this library!

5. If you want to make any further edits to this library, simply run
`npm run pack` to package up the changes, and then `npm update @actinc/dls`
in your local project to pull them in.

6. When you're done piloting the changes, simply revert your project's
`package.json` file to pull this library from NPM, and run
`npm update @actinc/dls` to refresh your project's `node_modules` folder.

#### Option 2: Real-time Previews

For rapid iteration, you can run a live copy of this library in your
downstream project:

1. In this library, run the watch script: `npm run watch`
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
"copy:changelog": "cp -rf CHANGELOG.md dist",
"copy:license": "cp -rf LICENSE dist",
"copy:readme": "cp -rf README.md dist",
"pack": "cd dist && npm pack",
"prepack": "npm run build && npm run copy",
"prepare": "husky",
"prettier": "prettier --write .",
"release:storybook": "npm run build-storybook && touch ./storybook-static/www/.nojekyll && storybook-to-ghpages -e ./storybook-static/www",
Expand Down

0 comments on commit 464f792

Please sign in to comment.