Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gluejs

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gluejs - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

lib/require/index.js

17

index.js

@@ -13,2 +13,12 @@ var os = require('os'),

this.files = new List();
// exclude matching paths from traversal - this is applied during the
// initial traversal because going into source control directories is
// potentially very expensive
this.files.exclude([
function(p) { return p.match(/\/.svn/); },
function(p) { return p.match(/\/.git/); },
function(p) { return p.match(/\/.hg/); },
function(p) { return p.match(/\/CVS/); }
]);
// default options

@@ -70,5 +80,10 @@ this.options = {

this.options[key] = value;
if(key == 'verbose') {
if(key == 'verbose' && value) {
Minilog.enable();
}
// --reset-exclude should also reset the pre-processing exclusion
// which prevent
if(key == 'reset-exclude' && value) {
this.files.exclude(null);
}
return this;

@@ -75,0 +90,0 @@ };

58

lib/runner/package-commonjs/index.js

@@ -15,2 +15,3 @@ var fs = require('fs'),

getCommands = require('./get-commands.js'),
reqWrap = require('../../require/index.js'),

@@ -26,4 +27,3 @@ log = require('minilog')('package-commonjs'),

// unpack options
var exportVariableName = options['export'] || 'App',
packageRootFileName,
var packageRootFileName,
// normalize basepath

@@ -117,19 +117,22 @@ basepath = (options.basepath ? path.normalize(options.basepath) : ''),

// produce the file
var packageTasks = [];
var packageTasks = [],
wrapOpts = {
'export': options['export'] || 'App',
'root-file': packageRootFileName,
// `--amd` and `--umd` are synonyms (since umd provides a superset of the amd features)
type: (options['amd'] || options['umd'] ? 'umd' : (options['node'] ? 'node' : 'global')),
// options: global-require: export the require() implementation into the global space
'global-require': options['global-require'] || false,
require: (options.require !== false ? 'min' : 'max')
};
packageTasks.push(function(out, done) {
// top level boundary
out.write('(function(){');
// the require() implementation
if(options.require !== false) {
out.write(fs.readFileSync(__dirname + '/resources/require.min.js'));
} else {
out.write(fs.readFileSync(__dirname + '/resources/require.fallthrough.js'));
}
// top level boundary + require() implementation
out.write(reqWrap.prelude(wrapOpts));
// the registry definition
out.write('\nrequire.m = [];\n');
out.write('r.m = [];\n');
done();
});
// for each module, write `require.m[n] = { normalizedName: .. code .. , };`
// for each module, write `r.m[n] = { normalizedName: .. code .. , };`

@@ -142,3 +145,3 @@ list.packages.forEach(function(packageObj, current) {

log.info('Processing package:', (packageObj.name ? packageObj.name : 'root'));
out.write('require.m['+current+'] = {\n');
out.write('r.m['+current+'] = {\n');
// store replaced and remapped for all packages

@@ -166,3 +169,3 @@ if(replaced) {

// require.m[n]['foo'] = { c: 1, m: 'lib/index.js' }
// r.m[n]['foo'] = { c: 1, m: 'lib/index.js' }
out.write(

@@ -259,27 +262,4 @@ JSON.stringify(name) + ': ' + JSON.stringify({

packageTasks.push(function(out, done) {
// requireJS export
//
// Note that at least RequireJS 2.1.4 is quite stupid.
// If, after a define('foo', 'bar') you do a synchronous require:
// require('foo');
// it'll complain about the module not being loaded for context.
// However, it picks up the change if you do:
// require(['foo'], function(foo){ console.log(foo); });
//
if(options['amd']) {
out.write('if (typeof define === "function" && define.amd) {');
out.write('define(' + JSON.stringify(exportVariableName) +
', function() { return require(\'' + packageRootFileName + '\'); });\n');
out.write('}\n');
}
// export the package root into `window`
out.write(exportVariableName + ' = require(\'' + packageRootFileName + '\');\n');
// options: global-require: export the require() implementation into the global space
if(options['global-require']) {
out.write('window.require = require.relative("", 0);');
}
// finally, close the package file
out.write('}());');
out.write(reqWrap.postlude(wrapOpts));

@@ -286,0 +266,0 @@ delete list.structured;

{
"name": "gluejs",
"description": "Build CommonJS modules for the browser via a chainable API",
"version": "2.2.2",
"version": "2.3.0",
"author": {

@@ -31,3 +31,3 @@ "name": "Mikito Takada",

"minimatch": "~0.2.12",
"minitask": "~0.1.1",
"minitask": "~0.1.2",
"optimist": "~0.5.2",

@@ -40,4 +40,5 @@ "bytes": "~0.2.1",

"devDependencies": {
"mocha": "1.x"
"mocha": "1.x",
"uglify-js": "~2.4.8"
}
}

@@ -5,3 +5,3 @@ # gluejs V2

New version! gluejs v2.1 is now out with a bunch of new features ([v1 branch](https://github.com/mixu/gluejs/tree/master))
New version! gluejs v2 is now out with a bunch of new features ([v1 branch](https://github.com/mixu/gluejs/tree/master))

@@ -72,2 +72,16 @@

# What's new in v2.3
gluejs v2.3 adds UMD support and performance / robustness improvements.
- UMD support: you can now run the same build result in Node and AMD and in the browser. This enables three use cases:
- you can use gluejs bundles in AMD/Require.js (via config.js, see the relevant section below)
- you can share the same file between AMD and Node
- you can use gluejs to produce a minified/obfuscated version of your codebase that's usable in Node
- chained require() resolution. The gluejs `require()` shim has been redesigned so that if a `require` function is already defined, then it will fall back to that function. This has two implications:
- if `--global-require` is set (exporting the `require()` function), you can split your app into multiple bundles loaded separately in the browser and they will appropriately chain require() calls as long they are loaded in prerequisite order
- UMD bundles running under Node will fall back to using Node's native `require` for modules that are not in the bundle
- Added pre-filters to skip .git / svn / hg / cvs directories for better performance
- Improved the behavior of the cache when the metadata is corrupted or in an unexpected format
## What's new in v2.2

@@ -430,8 +444,38 @@

## --amd
## --umd (new in v2.3)
`--amd` / `.set('amd', true)`: AMD compatible export, invokes `define('foo', ...)` to register the package with a AMD loader using the name specified in `--global`.
`--umd` / `.set('umd', true)`: UMD compatible export.
Note that Require.js will not pick up modules defined like this unless you do at least one asynchronous require() call, e.g. you need to run the no-op code `require(['foo'], function(foo){ });` before `require('foo')` will work. This seems to be a quirk in the Require.js AMD shim.
The resulting bundle can be loaded in Node (directly via require()), in AMD (as an external module) or alternatively as a global (in the browser). All you need to do is to add `--umd` to your build to include the UMD wrapper.
Creating the bundle:
gluejs \
--umd \
--include ./lib/ \
--include ./node_modules/microee/ \
--global App \
--main lib/index.js \
--out app.js \
In node:
node -e "console.log(require('./app.js'););"
In AMD/Require.js,`config.js`, assuming `--global` was set to `App`:
{
paths: { "myapp": "/app.js" },
myapp: {
deps: [ ... ],
exports: 'App'
}
}
after which the module is accessible as `myapp`.
Note that Require.js might not pick up modules defined like this unless you do at least one asynchronous require() call, e.g. you need to run the no-op code `require(['foo'], function(foo){ });` before `require('foo')` will work. This seems to be a quirk in the Require.js AMD shim.
Upgrade note: `--amd`, an older option which was only compatible with AMD/requirejs, is now equivalent to `--umd`.
## --verbose

@@ -438,0 +482,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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