-
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.
In this example, our new package is named @blueprintjs/time-travel.
To start, create a new directory in this repository at /packages/time-travel
.
Copy the following files from packages/core
into the new package directory, leaving them untouched:
.npmignore
LICENSE
Copy/paste the package.json
file from the core package and change things accordingly:
-
"name"
-"@blueprintjs/time-travel"
-
"version"
-"0.1.0"
- usually you should start new packages in the v0.x range to allow for development flexibility while you iterate on and stabilize the public API
-
"description"
- enter a short description of the package. -
"style"
-lib/css/blueprint-time-travel.css
. -
"unpkg"
-dist/time-travel.bundle.js
. -
"sideEffects"
- replace with["**/*.css"]
-
"keywords"
- keep at least"palantir"
and"blueprint"
, and add other relevant keywords. -
"dependencies"
- remove all dependencies except for"tslib"
. Add a dependency on"@blueprintjs/core"
.
Add a README.md
to document the responsibilities of and motivations behind the new package. Review the other package READMEs to match their style and content.
Be aware that the npmjs.com listing for each package renders this README in its UI (example).
Copy over the webpack.config.js
file from packages/core
and change things accordingly:
entry: {
- core: ...
+ "time-travel": ...
},
...,
output: {
- library: ["Blueprint", "Core"],
+ library: ["Blueprint", "TimeTravel"],
}
Create a boilerplate test config at packages/time-travel/karma.conf.js
:
/*
* Copyright 2022 Palantir Technologies, Inc. All rights reserved.
*/
const { createKarmaConfig } = require("@blueprintjs/karma-build-scripts");
module.exports = function (config) {
const baseConfig = createKarmaConfig({
dirname: __dirname,
});
config.set(baseConfig);
config.set({
// overrides here
});
};
Now we'll setup the src/
folder.
- Copy over the
tsconfig.json
file frompackages/core
. - Write your main package export in
src/index.ts
. - Write your main styles in
src/blueprint-time-travel.scss
. - Add an
index.md
file (copy fromdatetime/src/
). Modify theindex.md
to suit the new package. Our documentation files use Documentalist syntax & layout.
- Add a link to your docs page in
/packages/docs-app/src/_nav.md
:# this will look for time-travel/src/index.md +@page time-travel
- Create a
time-travel-examples
directory in/packages/docs-app/src/examples
, and add example usage components. - Add
@blueprintjs/time-travel
as a dependency in/packages/docs-app/package.json
."dependencies": { + "@blueprintjs/time-travel": "^0.1.0", }
- Run
yarn
from the repository root folder to linktime-travel
todocs-app
. - Update
/packages/docs-app/src/tags/reactExamples.ts
to include your examples:import * as SelectExamples from "../examples/select-examples"; +import * as TimeTravelExamples from "../examples/time-travel-examples"; import * as TableExamples from "../examples/table-examples"; ... ...getPackageExamples("select", SelectExamples as any); +...getPackageExamples("time-travel", TimeTravelExamples as any); ...getPackageExamples("table", TableExamples as any);
- Import the styles in
docs-app/src/index.scss
:+@import "~@blueprintjs/time-travel/lib/css/blueprint-time-travel.css";
- Create a
test/tsconfig.json
file (you can copy/paste the one frompackages/datetime
). - Have an
index.ts
file that imports or otherwise runs all your tests. - Copy/paste
test/isotest.js
fromdatetime
. You can usually just use it as is (replacing thedatetime
package 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": {
// OPTIONAL: add a dev task for your package (include other blueprint dependencies within the scope)
+ "dev:time-travel": "lerna run dev --parallel --scope '@blueprintjs/{time-travel,docs-app}'",
// add your package to the dist:libs task
- "dist:libs": "lerna run dist --parallel --scope '@blueprintjs/{core,...,timezone}'",
+ "dist:libs": "lerna run dist --parallel --scope '@blueprintjs/{colors,...,timezone,time-travel}'",
}
Lastly you'll want to modify the CircleCI build script to run the package's tests. Open up /.circleci/config.yml
and make the following changes:
test-react-16: &test-react
...
6) yarn lerna run --scope "@blueprintjs/table" test:karma ;; \
7) yarn lerna run --scope "@blueprintjs/timezone" test:karma ;; \
+ 8) yarn lerna run --scope "@blueprintjs/time-travel" test:karma ;; \
esac
when: always
...
After that, commit and merge the change, and your new package will be published!
- react-day-picker v8 migration
- HotkeysTarget & useHotkeys migration
- PanelStack2 migration
- Table 6.0 changes