Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pnodet/pkg-template
Small template to quickly create npm packages
https://github.com/pnodet/pkg-template
helper npm-package typescript
Last synced: about 2 months ago
JSON representation
Small template to quickly create npm packages
- Host: GitHub
- URL: https://github.com/pnodet/pkg-template
- Owner: pnodet
- License: mit
- Created: 2021-08-16T18:37:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-07T23:40:39.000Z (over 2 years ago)
- Last Synced: 2024-11-02T07:49:58.131Z (2 months ago)
- Topics: helper, npm-package, typescript
- Language: TypeScript
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# @pnxdxt/pkg-template
> Small js package I use to help me to create npm packages[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
[![GitHub workflow status](https://img.shields.io/github/workflow/status/pnxdxt/pkg-template/CI)](https://github.com/pnxdxt/pkg-template)
[![npm bundle size](https://img.shields.io/bundlephobia/min/@pnxdxt/pkg-template)](https://bundlephobia.com/package/@pnxdxt/pkg-template)
[![npm downloads](https://img.shields.io/npm/dt/@pnxdxt/pkg-template)](https://www.npmjs.com/package/@pnxdxt/pkg-template)## Install
```
$ npm install pkg-template
```
## ImportThis package is pure [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). It cannot be `require()`'d from CommonJS.
Use `import foo from 'foo'` instead of `const foo = require('foo')` to import the package.
```js
// Load entire build
import * as pkgName from 'pkg-template';// Load by method
import {main} from 'pkg-template';
```
If the package is used in an async context, you could use [`await import(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports) from CommonJS instead of `require(…)`.**You also need to make sure you're on the latest minor version of Node.js. At minimum Node.js 12.20, 14.14, or 16.0.**
Read more here: [sindresorhus/esm-package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
## Usage
```js
main([1,2,3], (element) => typeof element === 'string');
//=> falsemain(['1', '2', '3'], (element) => typeof element === 'string');
//=> true
```## License
MIT © [pnxdxt](https://pnxdxt.com)