Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nestarz/heritage
Tiny Package Manager for the Web
https://github.com/nestarz/heritage
browser cdn es6 import-maps package-manager pika snowpack
Last synced: about 1 month ago
JSON representation
Tiny Package Manager for the Web
- Host: GitHub
- URL: https://github.com/nestarz/heritage
- Owner: nestarz
- License: mit
- Created: 2020-05-11T00:28:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-04T11:39:51.000Z (over 3 years ago)
- Last Synced: 2024-11-22T00:51:50.603Z (about 1 month ago)
- Topics: browser, cdn, es6, import-maps, package-manager, pika, snowpack
- Language: JavaScript
- Homepage:
- Size: 114 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# heritage
Tiny Package Manager for the Web based on the [WICG/import-maps](https://github.com/WICG/import-maps) spec. No lock-in.- Depends only on **two** packages, `acorn` for AST parsing and `node-fetch` to request packages.
- Customize to any registry, CDN or filesystems... It's up to you
- Default to Pika and Unpkg registries
- Only retrive ES6 browser compatible assets and modules
- TypeScript definition resolution can be achieve using yarn/npm
- Easy-to-use## Use
1. Install Heritage
```bash
yarn add -D @eliaspourquoi/heritage
```2. Manage Dependencies, feels like Yarn...
```bash
# Add Dependencies
heritage add three three/examples/jsm/loaders/GLTFLoader.js [email protected] react react-dom es-module-shims# Remove Dependencies
heritage remove vue# Install Dependencies
heritage
```3. Add the generated `import-map.json` to your `index.html`.
```html```
4. Optional. For now you may need to polyfill the [WICG/import-maps](https://github.com/WICG/import-maps) spec.
Here a working example:
```bash
heritage add es-module-shims
```
```htmlimport React from "react"; // If you have installed react for example...
```
That's all.
## Information
Heritage use `package.json` to register required packages under the `webDependencies` field, exactly like Snowpack.
The `lock` file is the generated `import-map.json` used to manage imports by the browser. Default use of the the Pika CDN and fallback to Unpkg if target not found.To have the command `heritage` available you need to have `yarn bin`or `npm bin` in your `PATH` like so:
```
export PATH=$(yarn bin):$PATH
```
Otherwise you need to use this command `./node_modules/.bin/heritage` from the root of your package.## Custom Registry
Place a `heritage.config.js` at the root of your project using this API:```js
module.exports = [{
registryName,
entrypoint: (name: String, target: String, version: String) => String,
resolveImport: (importValue: String) => ,
pkgTarget,
pkgVersion,
}>,
exists: (name: String, target: String, version: String) => ,
version: (name: String, target: String, version: String) => ,
source: (entrypoint: String) => ,
},
...
];
```
You can see the Pika Registry Resolver here https://github.com/nestarz/heritage/blob/master/src/registries/pika.js