skypin
v2.0.11
Published
Convert NPM imports into Skypack Pinned URL's
Downloads
94
Maintainers
Readme
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/[email protected]/min/hueman.js
await skypin('hueman', { pin: false })
// ~> https://cdn.skypack.dev/[email protected]
await skypin('hueman', { min: false })
// ~> https://cdn.skypack.dev/[email protected]
// Specify version directly
await skypin('[email protected]')
// ~> https://cdn.skypack.dev/pin/[email protected]/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
,[email protected]
, etc.) (version number optional)options
:pin
: Boolean (defaulttrue
). Read more heremin
: Boolean (defaulttrue
). 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