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

@veldtdevtest/common

v1.1.2

Published

### Use as you would a normal component created with create-react-app:

Downloads

13

Readme

Using and Publishing NPM Component Packages

Use as you would a normal component created with create-react-app:

Importing

// container app

import { TestComponent, TestComponent2 } from '@veldtdevtest/common';

Dependencies

All dependencies should be installed in the container React App, since no node modules will be imported.

// container app
npm install
npm i @veldtdevtest/common

CSS Modules

Use of css modules will prevent component css from clashing with container application css. Access css properties like this in the component app:

// component app

import styles from './css/styles.module.css';

...

<div className={styles.myStyle}></div>

Fonts

The Satoshi font will be referenced in the Service and Wellness components, so ensure they are imported in the index.css of the container application.

// container app

@font-face {
  font-family: "Satoshi-Variable";
  src: url("../fonts/Satoshi-Variable.woff2") format("woff2"),
    url("../fonts/Satoshi-Variable.woff") format("woff"),
    url("../fonts/Satoshi-Variable.ttf") format("truetype");
  font-weight: 300 900;
  font-display: swap;
  font-style: normal;
}

Images

Images should be accessed through the /src/images.js file and imported into the component directly, not through a css file.

// component app

import { images } from './images';

...

<img src={images.imageName} />

Publishing to NPM

The script will build the files in /dist.

The only files distributed will be those in /src/components.

Add components as exports to the /src/components/index.js.

If private adjust the package.json

// component app

"private": true

Increment the version number in package.json or reset if you've been testing locally and the version increment is off.

Update types:

patch 0.1.33 > 0.1.34

minor 0.1.33 > 0.2.0

major 0.1.33 > 1.0.0

npm login

npm version <update type>

npm run publish:npm

npm publish

If public:

npm publish --access public

Note: --access=public is needed for scoped packages (@veldt/mypackage) as they're private by default. If it's not scoped and doesn't have the private field set to true in the package.json, it will be public as well.

Check what will be published before publishing

npm publish --dry-run

Choosing a component version

Be sure to remove the ^ from the version number in package.json

// container app

"@veldtdevtest/common": "0.1.33",

Reinstall

// container app

npm install

NPM Component Setup

Files to add

.npmignore

// component app

node_modules/

public/

src/**/*

.index.d.ts

// component app

declare module '@veldtdevtest/common';

/src/components/index.js

// component app

export { default as TestComponent } from './TestComponent';

/src/components/images.js

// component app

import kv from './images/kv.webp';

export const images = { kv }

Dependencies to install

// component app

npm i --save-dev @babel/cli @babel/preset-react

May need this to quiet a warning

// component app

npm i @babel/plugin-proposal-private-property-in-object

package.json script

// component app

"publish:npm": "rm -rf dist && mkdir dist &&  babel src/components -d dist --copy-files"

Other package.json settings

// component app

"name": "@veldtdevtest/common",
"version": "0.1.33",
"private": false,
"main": "dist/index.js",
"files": [
    "dist/**/*"
  ],
"babel": {
  "presets":[
    "@babel/preset-react"
    ]
  },

Notes on "name"

"name": "@veldtdevtest/common",

Creates this folder structure in node_modules:

@veldtdevtest/common/dist/

Maybe use this for the real repo

"name": "@veldt/deservice",

Local Testing in Container

Commit any changes, then in component app:

npm run localtest

This will create a .tgz file on your Desktop.

In the container app update the version to the one on the Desktop:

"dependencies": {
  "@veldtdevtest/common": "file:~/Desktop/veldtdevtest-common-1.1.0.tgz"
}

Install:

npm install