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

gen-pug-source-map

v1.0.0

Published

Source map generation for Pug v2.x (aka Jade)

Downloads

1,456

Readme

gen-pug-source-map

Windows build Build status npm version License

Source map v3 generation for Pug v2.x (aka Jade).

Designed as a node.js helper for Brunch and Rollup plugins in my current projects, I hope it will be useful to you.

Install

npm install gen-pug-source-map --save

Syntax

genPugSourceMap( compiledFileName, compiledTemplate [, options] ) -> { data, map }

Mustly, compiledFileName will be the name of the root .pug template (the generator adds .js to this) and options will contain basedir with the same value that you pass to the compiler.

Usage

Compile the .pug with compileDebug:true and pass the filename, generated code, and options to the source map generator.

It returns a plain JavaScript object with {data, map} properties, where data is the generated code and map is an object containing a raw source map.

By default, the generator uses file names relative to the current directory, removes the inlined templates and lines with debugging information, and inserts the templates in the source map (useful for remote debugging), but you can change this behavior with this options:

  • basedir - Define the root directory of the source files with relative names.
  • keepDebugLines - Keep the lines with debugging information in the generated code.
  • excludeContent - Does not include the original source(s) in the resulting source map.

If basedir is missing or empty, it defaults to the current directory.

Inlined templates and debugging information are used by the pug runtime to display errors, something useful in development mode. For production, better use the default keepDebugLines:false as the size of the generated code is about 4x with debugging info.

Example

const genPugSourceMap = require('gen-pug-source-map')
const pug = require('pug')

function compile (filename, source, options) {
  options.filename = filename             // REQUIRED
  options.compileDebug = true             // REQUIRED
  options.inlineRuntimeFunctions = false  // recommended, use the global `pug` runtime

  const output = pug.compileClient(source, options)
  const result = genPugSourceMap(filename, output.body, { basedir: options.basedir })

  return result   // {data, map}
}

Note:

The signature of v0.1.0 (filename, source, compiled [, options]) is supported, but the source parameter is deprecated and will be removed in v0.2.x

Known Issues

The generated map does not allow to set breakpoint on insert directives nor in the first line of inserted files.

What's New

See changes in the CHANGELOG.