JSPM

gen-pug-source-map

v0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 317
  • Score
    100M100P100Q110567F
  • License MIT

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

Package Exports

  • gen-pug-source-map

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gen-pug-source-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm Version License

gen-pug-source-map

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

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

Install

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

Usage

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

It returns a plain JavaScript object with {data, map}, where data is the generated code and map is a JSON representation of the source map (as string).

By default, the generator removes lines with debugging information (used by the pug runtime to display errors), and copy the source template(s) in the source map (useful for remote debugging), but you can ovewrite this with options:

  • keepDebugLines - Keep the lines with debugging information from the generated code.
  • excludeContent - Does not include the original source(s) in the source map.

Example

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

function compile (filename, source, options) {
  options.filename = filename
  options.compileDebug = true     // important!

  const output = pug.compileClient(source, options)
  const result = genSourceMap(filename, output.body, source)

  return result   // {data, map}
}