Lookup URLs
Lookup URLs are the easiest way to load JavaScript packages in your application. All you need is a package name to get started.
Behavior
Lookup URLs perform a live lookup on the npm registry, and will always return the latest package available data from npm. You can provide a version range in the URL to customize or restrict this version lookup behavior.
When you find a package that you are happy with, we recommend committing Pinned URL to your codebase so they can skip the slower lookup and prevent unexpected changes over time as new packages are released to npm.
API - Package Matching
Lookup by Package Name
If only a package name is given, Skypack will check npm and return the latest version of the package. This is the equivalent of running npm install [package-name]
or yarn add [package-name]
without a version in a Node.js project.
Lookup by Package + Version Range (Semver)
Returns the latest package release that matches that version. Basic SemVer matchers (~
& ^
) are supported to automatically accept future releases to the package within a range.
Lookup by Package + Dist Tag
Returns the package release that matches that "dist-tag" in npm. Learn more about dist-tags.
API - Resource Matching
By default, Lookup URLs return the main entrypoint of a package, just like if you had imported the package by name alone in Node.js.
However, some packages are designed to import custom files and entrypoints deep within a package. Skypack supports most uses of this as well.
Lookup a Package Export
Export Maps are the latest standard from the Node.js team for documenting the specific interface of a package. Any files not documented in the export map are meant to be private, and inaccessible from Node.js and other tools.
Skypack ships with support for Export Maps and will use them to optimize a package if one exists.
Lookup a Package File
If no export map exists, it is still possible to lookup any file within Skypack.
Limitation: When a JavaScript file is loaded this way, Skypack won't run automatic Common.js (CJS) -> ESM transformation on the file. Legacy packages are only able to be handled when a package is imported by name (aka the main entrypoint) or when an Export Map exists for that package.
API - Customizing the Response
Minification
By default, Lookup URLs will return code unminified. You can add the minify
URL param to reduce the number of bytes sent over the wire.
Forced Browser Support
By default, Lookup URLs will return code optimized to the specific browser that loads it. Modern browsers will get less unnecessary transpilation and polyfills than legacy browsers, and load faster as a result.
You can disable this automatic browser detection by hardcoding your own ?dist
param into the URL.
TypeScript Declarations
If you're using Skypack with Deno or any other Typescript-first environment, you can add the ?dts
query param to the URL to return X-TypeScrpt-Declarations
that Deno will read automatically.
Package Metadata
See Package Metadata API.
Last updated
Was this helpful?