npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@burnsred/ui-chakra

v1.6.2

Published

This is the foundational UI component library, built on top of [Chakra UI](https://chakra-ui.com/).

Downloads

75

Readme

UI-Chakra

This is the foundational UI component library, built on top of Chakra UI.

It exports a theme for @chakra-ui/react, composite components that address common requirements in BurnsRED projects. Components which have third-party dependencies are defined in their own package.

To develop, fire up @burnsred/styleguide, and consume the UI library from there.

Installing in a client project

npm i @burnsred/engage-ui

Installing fonts

npm install @fontsource/open-sans @fontsource/montserrat

Include fonts:

// src/App.tsx

// whichever weights required
import '@fontsource/montserrat/700.css';
import '@fontsource/open-sans/400.css';

Configure the theme:

// src/theme/index.ts
export const theme: Partial<ChakraTheme> = extendTheme({
  // ...

  fonts: {
    heading: `'Montserrat', sans-serif`,
    body: `'Open Sans', sans-serif`,
  },

  // ...
});

Optional dependencies

# recommended - tree-shakable, includes Material icons and many more
# https://react-icons.github.io/react-icons/
npm i react-icons

Developing

npm -w @burnsred/ui-chakra run dev
npm -w @burnsred/ui-chakra run test
npm -w @burnsred/ui-chakra run build

Note that whilst we're building the library with the Typescript compiler, vite is installed to facilitate testing via vitest, which is configured via tsconfig.node.json.

Gotcha: consuming local engage-ui in client projects

When actively developing engage-ui and testing consumption in a client project, the development cycle may look like this:

  • update code in engage-ui
    • npm run clean && npm run build
  • consume the functionality in the client project
    • rm -rf node_modules/@burnsred && npm i && npm run dev

GOTCHA in development (only), vite pre-bundles dependencies:

Vite converts ESM dependencies with many internal modules into a single module to improve subsequent page load performance

https://vitejs.dev/guide/dep-pre-bundling.html

Vite may not identify changes to engage-ui code even when rebuilt as above, resulting in errors like:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@burnsred_ui-chakra.js?v=25e3c47a' does not provide an export named 'recentlyUpdated' (at myFile.tsx:5:10)

To resolve this, refresh vite's pre-bundled dependencies by running vite --force.

Suggest adding the following dev:clean script to client's package.json:

{
  "scripts": {
    "dev": "vite --port 3000",
    "dev:clean": "vite --port 3000 --force # refresh engage-ui files"
  }
}

Add a "vite clean" command · Issue #10986 · vitejs/vite

Relative imports are required in library code

In consuming apps, it's convenient to import via barrel files at the top level of the project (facilitated by compilerOptions.baseUrl in tsconfig.json), but attempting such imports in sharable components in this library may produce an error in the consuming app:

Failed to resolve import "components" from "../../packages/ui-chakra/dist/components/CompositeComponent.js". Does the file exist?

Hence, compilerOptions.baseUrl is not configured in @burnsred/ui-chakra; instead use relative links, preferably from barrel files:

// components/index.ts (barrel file)
export * from './MyComponent';

// components/CompositeComponent.tsx
import { MyComponent } from '..';

Publishing to NPM

Note: $version is not provided below, because you must decide the appropriate version according to the Semantic Versioning spec.

Usually, you'd use pass an option to npm version to bump by either major, minor, or patch (eg npm version patch), and the version operation would automatically git tag for you, BUT in a monorepo we're required to do git tag manually (see notes below).

When reading the steps below (until this is scripted), take note of the version produced by npm version, and use it in the git tag call.

# merge feature to main, then
git checkout main

# build and test
npm -w @burnsred/ui-chakra i && \
  npm -w @burnsred/ui-chakra run build && \
  npm -w @burnsred/ui-chakra test

# https://docs.npmjs.com/cli/v8/commands/npm-version
npm -w @burnsred/ui-chakra version $version

# Note that `npm version` does not git commit or tag in a monorepo - see comments below
git commit package*.json packages/ui-chakra/package*.json -m "[@burnsred/ui-chakra] v$version"
git tag "release/@burnsred/ui-chakra/$version"
git push && git push --tags

# login as `burnsred`; see 1password
npm login
npm -w @burnsred/ui-chakra publish

Success is indicated by the last line of output displaying the package and version number:

npm notice Publishing to https://registry.npmjs.org/ with tag latest and public access
+ @burnsred/[email protected]

Additional reading: How to publish packages to npm (the way the industry does things) | Zell Liew

Error: No matching version found for...

npm version 2.0.0-beta

npm ERR! notarget No matching version found for @burnsred/ui-chakra@^0.0.0

Pre-release tags don't seem to be matched, resulting in this error; note that if npm version returns an error, then the root package-lock.json will not be updated.

Behavior of npm version in a monorepo

...npm version -w x does not generate a git commit. The decision was made at the time of implementing npm version for workspaces to do this because the existing git tag config wasn't very conducive to workspaces.

tag-version-prefix defaults to v, and is not something that can be templated or otherwise changed per workspace in a single command. Rather than block npm version for workspaces altogether it was implemented bypassing git tagging altogether.

[BUG] Wrong behaviour of npm version inside workspaces · Issue #4017 · npm/cli

[RRFC] workspace-tag-version-prefix config · Issue #570 · npm/rfcs

Tag naming conventions

To allow use to differentiate between package releases, tags should be named:

"release/@burnsred/$package_name/$version"

tags are organized in directories and files (all git references are, run tree .git/refs/tags to see that), so I would suggest naming the tags:

myapp1/1.0.0
myapp1/1.0.1
 ...
myapp2/2.1.0
myapp2/2.2.0

This will group versions for each app together, and some commands will treat the numbers "naturally"

git - Monorepo Version Tags Conventions - Stack Overflow