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

vinyl-sourcemap

v2.0.0

Published

Add/write sourcemaps to/from Vinyl files.

Downloads

7,943,672

Readme

vinyl-sourcemap

NPM version Downloads Build Status Coveralls Status

Add/write sourcemaps to/from Vinyl files.

Usage

sourcemap.add(file, function (err, updatedFile) {
  // updatedFile will have a .sourceMap property
});

// The 2nd argument can be given as a path string
sourcemap.write(file, './maps', function (err, updatedFile, sourcemapFile) {
  // sourcemapFile will be a Vinyl file to be written to some location
  // updatedFile will have the .contents property updated with a sourceMappingURL that resolves to sourcemapFile
});

// If not defined, the sourcemap is inlined
sourcemap.write(file, function (err, updatedFile, sourcemapFile) {
  // sourcemapFile is undefined
  // updatedFile will have the .contents property updated with a sourceMappingURL that is an inlined sourcemap
});

API

sourcemap.add(file, callback)

Takes a Vinyl file object and a callback function. It attempts to parse an inline sourcemap or load an external sourcemap for the file. If a valid sourcemap is found, the sources & sourcesContent properties are resolved to actual files (if possible) and a fully resolved sourcemap is attached as file.sourceMap. If a sourcemap is not found, a stub sourcemap is generated for the file and attached as file.sourceMap.

Once all resolution is complete, the callback(err, updatedFile) is called with the updatedFile. If an error occurs, it will be passed as err and updatedFile will be undefined. Note: The original file is mutated but updatedFile is passed to the callback as a convenience.

If the file is not a Vinyl object or the contents are streaming, an Error will be passed to the callback.

If the file has a .sourceMap property or the contents are null, the callback will be called immediately without mutation to the file.

All filesystem operations are optional & non-fatal so any errors will not be bubbled to the callback.

sourcemap.write(file, [outputPath,] callback)

Takes a Vinyl file object, (optionally) an outputPath string and a callback function.

If outputPath is not passed, an inline sourcemap will be generated from the file.sourceMap property and appended to the file.contents. Once the inline sourcemap is appended, the callback(err, updatedFile) is called with the updatedFile. If an error occurs, it will be passed as err and updatedFile will be undefined. Note: The original file is mutated but updatedFile is passed to the callback as a convenience.

If outputPath is passed, a new Vinyl file will be generated using file.cwd and file.base from the original file, the path to the external sourcemap, and the file.sourceMap (as contents). The external location will be appended to the file.contents of the original file. Once the new file is created and location appended, the callback(err, updatedFile, sourcemapFile) is called with the updatedFile and the sourcemapFile. If an error occurs, it will be passed as err and updatedFile/sourcemapFile will be undefined. Note: The original file is mutated but updatedFile is passed to the callback as a convenience.

If the file is not a Vinyl object or the contents are streaming, an Error will be passed to the callback.

If the file doesn't have a .sourceMap property or the contents are null, the callback will be called immediately without mutation to the file.

License

MIT