New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@makeomatic/gulp-wrap-js

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@makeomatic/gulp-wrap-js

Gulp plugin for templating JavaScript code with source maps support.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
2
Weekly downloads
 
Created
Source

gulp-wrap-js

NPM version Build Status Dependency Status

When using classic templating solutions (like Lo-Dash / Underscore templates / own regexps / etc.) for wrapping JavaScript code, you're manipulating code as strings under the hood, and so losing any inner structure and location information. Such approach is used in gulp-wrap, gulp-wrap-amd, gulp-wrap-umd and that's why source maps are not currently supported in any of them.

In opposite, this plugin is based on AST templating estemplate library, and allows to wrap your JavaScript code into given template (UMD / AMD / whatever) with preserved locations for source maps generation.

Check out gulp-sourcemaps for detailed instructions on working with source maps enabled plugins in Gulp.

Usage

First, install gulp-wrap-js as a development dependency:

npm install --save-dev gulp-wrap-js

Then, add it to your gulpfile.js:

var sourcemaps = require('gulp-sourcemaps');
var wrapJS = require("gulp-wrap-js");

gulp.src("./src/*.js")
    .pipe(sourcemaps.init())
        .pipe(wrapJS('define(function () {%= body %})'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest("./dist"));

API

wrapJS(template, format)

template

Type: String
Required

Template you wish to wrap your code with. Check out estemplate docs for all the possible substitution markers.

Note that in gulp-wrap-js you have only body array of statements passed to template as data.

format

Type: Object Default: escodegen.FORMAT_DEFAULTS

escodegen output format options.

License

MIT License

Keywords

FAQs

Package last updated on 06 Nov 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc