skypin
TypeScript icon, indicating that this package has built-in type declarations

2.0.11 • Public • Published
Skypin Logo

skypin

Convert NPM imports into Skypack Pinned URL's

About

Skypack is a CDN built for browser modules. This module converts npm module id's into the optimized Skypack URL for optimal performance. Read more here. This could be used in build tools (like rollup) to convert source code into browser-optimized modules.

Usage

NodeJS

import { skypin } from 'skypin';

// Uses version of package found in node_modules (if it exists - otherwise 'latest')
await skypin('hueman')
// ~> https://cdn.skypack.dev/pin/hueman@v2.1.1-ElNqhC8YFxLlgRtjjL9o/min/hueman.js

await skypin('hueman', { pin: false })
// ~> https://cdn.skypack.dev/hueman@2.1.1

await skypin('hueman', { min: false })
// ~> https://cdn.skypack.dev/hueman@2.1.1

// Specify version directly
await skypin('hueman@2.0.0')
// ~> https://cdn.skypack.dev/pin/hueman@v2.0.0-Eh8v1x3dV0iEyJ9rG915/min/hueman.js

Browser Codepen

import { skypin } from 'https://cdn.skypack.dev/skypin'

await skypin('hueman')

API

skypin(module_id, options) -> URL

  • module_id: String that identifies the package in npm (hueman, uhtml@latest, themepark@1.0.0, etc.) (version number optional)
  • options:
    • pin: Boolean (default true). Read more here
    • min: Boolean (default true). Based on normal vs. minified in skypack lookup page
  • Returns: Promise that resolves to URL that can be used as an import statement in the browser

Uses the version of the package found in node_modules. Requires that the module has been installed to the current working directory. May take a few seconds if the package has not been "pinned" on skypack before.

References

License

MIT © Marshall Brandt

Package Sidebar

Install

npm i skypin

Weekly Downloads

12

Version

2.0.11

License

MIT

Unpacked Size

17.7 kB

Total Files

9

Last publish

Collaborators

  • marshallcb