Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
define-commonjs
Advanced tools
This is yet another CommonJS implementation.
<script src="define.js"></script>
<!-- Add define-async.js only if define.async is needed -->
<script src="define-async.js"></script>
<script src="bundle.js"></script>
// bundle.js is like this
define('a', function (require, exports, module) {
module.exports = 'hello';
});
define('b', function (require, exports, module) {
module.exports = 'world';
});
define('app', function (require, exports, module) {
var a = require('a');
var b = require('b');
console.log(a + ', ' + b);
});
// define a dependency asynchronously, needs define-async.js
define.async('async/a', 'http://script/to/a.js');
define.async('async/b', function () {
// should resolve the script code
return getCodeFromSomewhereElse();
});
define.use('app');
Assume we have a project with three files:
// src/a.js
module.exports = 'hello';
// src/b.js
module.exports = 'world';
// src/app.js
var a = require('./a');
var b = require('./b');
console.log(a + ', ' + b);
Using gulp:
const pack = require('define-commonjs/pack/gulp');
const concat = require('gulp-concat');
gulp.task('pack', () => {
const collect = pack();
return gulp.src('src/*.js')
.pipe(collect)
.pipe(collect.pack({main: 'src/app.js'}))
.pipe(concat())
.pipe(gulp.dest('dist'));
});
gulp.task('pack-with-custom-paths', () => {
const collect = pack();
return gulp.src('src/*.js')
.pipe(collect)
.pipe(collect.pack({
main: 'src/app.js',
getPath(file) {
// This is useful if we have changed files before packing, e.g. concat'ed.
return file.relative === 'main.js' ? 'src/app.js' : file.path;
},
}))
.pipe(concat())
.pipe(gulp.dest('dist'));
});
FAQs
Yet another CommonJS implementation
The npm package define-commonjs receives a total of 8 weekly downloads. As such, define-commonjs popularity was classified as not popular.
We found that define-commonjs 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.