-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Creating a new package
This document describes how to create and publish a new Blueprint package to NPM (e.g. @blueprintjs/core, @blueprintjs/table, etc).
To start, create a new directory in /packages/, e.g. /packages/loremipsum.
Copy the following files from the datetime package into the loremipsum package, leaving them untouched:
.npmignoreLICENSE
Copy/paste the package.json from the datetime package and change things accordingly:
-
"name"-"@blueprintjs/loremipsum" -
"version"-"1.0.0" -
"description"- enter a short description of the package. -
"style"- the convention is to usedist/blueprint-loremipsum.css. -
"unpkg"-dist/loremipsum.bundle.js. -
"keywords"- keep at least"palantir"and"blueprint", and add other relevant keywords. -
"dependencies"- make sure to add"@blueprintjs/core"as a dependency toloremipsum- this gives us access to core features. keep/delete other packages as needed (quick note -"tslib"is an easy win that emits smaller bundles; best to leave it in). -
"peerDependencies"- delete this since core (which is a dependency) specifies the relevant peer dependencies.
Add a README.md to document the responsibilities of that package—you can probably copy/paste from table or datetime and modify accordingly.
Be aware that the npmjs.com listing uses the README in its UI—for example: https://www.npmjs.com/package/@blueprintjs/table.
Copy/paste the webpack.config.js from datetime and change things accordingly:
entry: {
- core: ...
+ loremipsum: ...
},
...,
output: {
- library: ["Blueprint", "Core"],
+ library: ["Blueprint", "Loremipsum"],
}Copy/paste the karma.config.js from datetime and change things accordingly:
webpack: Object.assign({}, baseConfig.webpack, {
entry: {
- datetime: [
+ loremipsum: [
...,
- path.resolve(__dirname, "dist/blueprint-datetime.css"),
+ path.resolve(__dirname, "dist/blueprint-loremipsum.css"),
],
},Now we'll setup the src/ folder.
- Copy/paste the
tsconfig.json,tsconfig.cjs.jsonfromdatetime. - Write your main package export in
src/index.ts. - Write your main styles in
src/blueprint-loremipsum.scss. - Add an
index.mdfile (copy fromdatetime). Modify theindex.mdto suit the new package. Our docs files conform to Documentalist.
- Add a link to your docs page in
/packages/docs-app/src/_nav.md:# this will look for loremipsum/src/index.md +@page loremipsum
- Create a
loremipsum-examplesdirectory in/packages/docs-app/src/examples, and add example usage components. - Add
@blueprintjs/loremipsumas a dependency in/packages/docs-app/package.json."dependencies": { + "@blueprintjs/loremipsum": "^1.0.0", } - Run
yarnfrom the top-level folder to linkloremipsumtodocs-app. - Update
/packages/docs-app/src/tags/reactExamples.tsto include your examples:import * as LabsExamples from "../examples/labs-examples"; +import * as LoremIpsumExamples from "../examples/loremipsum-examples"; import * as TableExamples from "../examples/table-examples"; ... addPackageExamples("labs", LabsExamples as any); +addPackageExamples("loremipsum", LoremIpsumExamples as any); addPackageExamples("table", TableExamples as any);
- Import the styles in
docs-app/src/index.scss:+@import "~@blueprintjs/select/dist/blueprint-loremipsum.css";
- Create a
test/tsconfig.jsonfile (you can copy/paste thedatetimeone). - Have an
index.tsfile that imports or otherwise runs all your tests. - Copy/paste
test/isotest.jsfromdatetime. You can usually just use it as is (replacing thedatetimepackage name). This is to hook up Blueprint's isomorphic testing framework to ensure your package components can render from the server-side.
💁 Confirm that things are hooked up by running yarn verify from the top-level folder.
Now that the package itself is setup, there's just a few steps to get it working within the entire Blueprint monorepo.
You'll want to add a few things to the top-level /package.json file:
"scripts": {
// add a dev task for your package (include other blueprint dependencies within the scope)
+ "dev:loremipusm": "lerna run dev --parallel --scope '@blueprintjs/{core,loremipsum}'",
- "dist:libs": "lerna run dist --parallel --scope '@blueprintjs/{core,datetime,docs,labs,table}'",
// add your package to the dist:libs task
+ "dist:libs": "lerna run dist --parallel --scope '@blueprintjs/{core,datetime,docs,labs,loremipusm,table}'",
}Lastly you'll want to modify the CircleCI build script to a) run the package's tests and b) publish the new package. Open up /.circleci/config.yml and make the following changes:
jobs:
dist-libs:
steps:
- persist_to_workspace:
paths:
+ - packages/loremipsum/dist
+ test-loremipsum:
+ docker:
+ - image: circleci/node:8
+ steps:
+ - checkout
+ - attach_workspace:
+ at: '.'
+ - restore_cache:
+ key: v1-dependency-cache-{{ checksum "yarn.lock" }}
+ - run: yarn lerna run test --scope '@blueprintjs/loremipsum'
workflows:
compile_lint_test_dist_deploy:
jobs:
+ - test-loremipsum:
+ requires: [compile-libs]
- deploy-preview:
requires:
+ - test-loremipsumAfter that, commit and merge the change, and your new package will be published!
- FAQ
- 6.x Changelog
- 5.x Changelog
- 5.0 pre-release changelog
- 4.x Changelog
- v4.0 & v5.0 major version semantic swap
- v6.0 changes
- Spacing System Migration: 10px to 4px
- react-day-picker v8 migration
- HotkeysTarget & useHotkeys migration
- PanelStack2 migration
- Table 6.0 changes