Socket
Socket
Sign inDemoInstall

gulp-commonjs-wrapper

Package Overview
Dependencies
65
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-commonjs-wrapper

wrap files to CommonJS modules


Version published
Weekly downloads
1
Maintainers
1
Install size
1.64 MB
Created
Weekly downloads
 

Readme

Source

You need a require.register function in the scope where you add the wrapped files. It's recommended to use commonjs-require for this purpose.

gulpfile.js

var commonjsWrapper = require('gulp-commonjs-wrapper');

gulp.src('src/**/*.{js,coffee}')
.pipe(commonjsWrapper())
.pipe(gulp.dest('build/'))

its compile from:

src/sub/Cat.js

module.exports = function(){
	alert('cat');
};

src/Main.coffee

Cat = require 'sub/Cat'

module.exports = ->
	Cat()	

to:

build/sub/Cat.js

require.register('sub/Cat', function (exports, require, module) {
	module.exports = function(){
		alert('cat');
	};
});

build/Main.coffee

require.register 'Main', (exports, require, module)->
	Cat = require 'sub/Cat'

	module.exports = ->
		Cat()	

Keywords

FAQs

Last updated on 28 Sep 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc