
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
gen-pug-source-map
Advanced tools
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.
npm install gen-pug-source-map --save
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.
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.
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
The generated map does not allow to set breakpoint on insert
directives nor in the first line of inserted files.
See changes in the CHANGELOG.
[1.0.0] - 2018-10-14
FAQs
Source map generation for Pug v2.x (aka Jade)
The npm package gen-pug-source-map receives a total of 341 weekly downloads. As such, gen-pug-source-map popularity was classified as not popular.
We found that gen-pug-source-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.