gulp-wrap-js
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 = ;var wrapJS = ; gulp ;
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.