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

@growing-web/dancf-provider

v0.4.5

Published

Package Import Map Generation Tool

Downloads

51

Readme

DANCF Provider

这是一个 Import Map 生成器的配置,CDN 的提供者将会设置为 dancf.com,它能够在全球加速访问 NPM 的包,包括中国。

Getting Started

安装

Node.js:

npm install @jspm/generator
npm install @growing-web/dancf-provider

@jspm/generator only ships as an ES module, so to use it in Node.js add "type": "module" to your package.json file or write an .mjs to load it.

生成 Import Maps

By default the generator generates import maps against the JSPM CDN by treating the defaultProvider: 'dancf' option. This can be configured to other CDNs or sources including local nodemodules, see the next section on how to achieve this.

generate.mjs

import { Generator } from '@jspm/generator';
import * as dancf from '@growing-web/dancf-provider';

const generator = new Generator({
  mapUrl: import.meta.url,
  env: ['production', 'browser', 'module'],
  defaultProvider: 'dancf',
  customProviders: {
    dancf
  }
});

// Install a new package into the import map
await generator.install('react-dom');

// Install a package version and subpath into the import map (installs lit/decorators.js)
await generator.install('lit@2/decorators.js');

// Install a package version to a custom alias
await generator.install({ alias: 'react16', target: 'react@16' });

// Install a specific subpath of a package
await generator.install({ target: 'lit@2', subpath: './html.js' });

// Install an export from a locally located package folder into the map
// The package.json is used to determine the exports and dependencies.
await generator.install({ alias: 'mypkg', target: './packages/local-pkg', subpath: './feature' });

console.log(JSON.stringify(generator.getMap(), null, 2));
/*
 * Outputs the import map:
 *
 * {
 *   "imports": {
 *     "lit/decorators.js": "https://es.dancf.com/npm:[email protected]/decorators.js",
 *     "lit/html.js": "https://es.dancf.com/npm:[email protected]/html.js",
 *     "mypkg/feature": "./packages/local-pkg/feature.js",
 *     "react": "./local/react.js",
 *     "react16": "https://es.dancf.com/npm:[email protected]/index.js",
 *     "react-dom": "https://es.dancf.com/npm:[email protected]/index.js"
 *   },
 *   "scopes": { ... }
 * }
 */

更多使用说明:jspm/generator

License

MIT