broccoli-ember-preparse
Advanced tools
Comparing version 0.0.3 to 0.0.4
10
index.js
var DefineRewriter = require('./lib/define-rewriter/src/index'); | ||
var merge = require('broccoli-merge-trees'); | ||
var removeFile = require('broccoli-file-remover'); | ||
module.exports = function(distNode, loaderNode, options) { | ||
var input = merge([distNode, loaderNode]) | ||
var node = new DefineRewriter(input, options); | ||
return removeFile(node, { | ||
path: 'loader' | ||
}); | ||
module.exports = function(input, options) { | ||
return new DefineRewriter(input, options); | ||
} | ||
module.exports.DefineRewriter = DefineRewriter; |
@@ -16,2 +16,3 @@ 'use strict'; | ||
var DEFAULT_GLIMMER_EAGER = [ | ||
'glimmer-reference/index', | ||
'ember-glimmer/components/checkbox', | ||
@@ -58,3 +59,8 @@ 'ember-glimmer/components/link-to', | ||
function isEmptyModule(node) { | ||
return node.functionExpression.body.body.length === 0; | ||
if (node.functionExpression.body.body.length === 0 && | ||
node.deps.length === 1 && | ||
node.deps[0] === 'exports') { | ||
return true | ||
} | ||
return false; | ||
} | ||
@@ -101,3 +107,2 @@ | ||
} | ||
this.loaderDeferred = RSVP.defer(); | ||
Filter.call(this, Array.isArray(inputNode) ? inputNode : [ inputNode ], options); | ||
@@ -117,8 +122,3 @@ } | ||
// If given | ||
return this.loaderDeferred.promise.then(function(loader) { | ||
return processEmber(string, relativePath, this.eagerLoad, loader, this.moduleFilter); | ||
}.bind(this)); | ||
} else if (relativePath.indexOf('loader') > -1) { | ||
// If given file is the loader, read and save in deferred for use by preparse | ||
this.loaderDeferred.resolve(string); | ||
return processEmber(string, relativePath, this.eagerLoad, this.moduleFilter); | ||
} | ||
@@ -125,0 +125,0 @@ return string; |
var graphlib = require('graphlib'); | ||
var amdNameResolver = require('amd-name-resolver'); | ||
var amdNameResolver = require('amd-name-resolver').moduleResolve; | ||
var NameSet = require('./name_set'); | ||
@@ -4,0 +4,0 @@ var ModuleNode = require('./module_node'); |
@@ -8,3 +8,3 @@ var babylon = require('babylon'); | ||
module.exports = function processEmber(string, relativePath, eagerLoadList, loader, moduleFilter) { | ||
module.exports = function processEmber(string, relativePath, eagerLoadList, moduleFilter) { | ||
var ast = babylon.parse(string); | ||
@@ -80,3 +80,3 @@ | ||
buffer.push('Em._eager = ' + JSON.stringify(graph.eagerSet.names) + ';'); | ||
buffer.push(generateLoader(loader)); | ||
buffer.push(generateLoader()); | ||
@@ -83,0 +83,0 @@ function pushLines(lines) { |
@@ -26,2 +26,5 @@ (function() { | ||
_define: function define(name, deps, callback) { | ||
if (this.registry[name]) { | ||
return; | ||
} | ||
this.registry[name] = { | ||
@@ -35,4 +38,4 @@ deps: deps, | ||
}, | ||
_require: function require(name, referrerName) { | ||
var exports = this.seen[name]; | ||
_require: function require(_name, referrerName) { | ||
var exports = this.seen[_name]; | ||
if (exports !== undefined) { | ||
@@ -42,8 +45,10 @@ return exports; | ||
exports = this.seen[name] = { default: undefined }; | ||
var mod = this.registry[name]; | ||
var name = _name; | ||
var mod = this.registry[_name]; | ||
if (!mod) { | ||
name = name + '/index'; | ||
name = _name + '/index'; | ||
exports = this.seen[name]; | ||
if (exports !== undefined) { | ||
return exports; | ||
} | ||
mod = registry[name]; | ||
@@ -54,8 +59,12 @@ } | ||
if (referrerName) { | ||
throw new Error('Could not find module ' + name + ' required by: ' + referrerName); | ||
throw new Error('Could not find module ' + _name + ' required by: ' + referrerName); | ||
} else { | ||
throw new Error('Could not find module ' + name); | ||
throw new Error('Could not find module ' + _name); | ||
} | ||
} | ||
console.log(name); | ||
this.seen[name] = exports = { default: undefined }; | ||
var deps = mod.deps; | ||
@@ -81,3 +90,4 @@ var reified = new Array(deps.length); | ||
loader.require.has = function(name) { | ||
return !!loader.registry[name]; | ||
var registry = loader.registry; | ||
return !!registry[name] || !!registry[name + '/index']; | ||
}; | ||
@@ -84,0 +94,0 @@ |
{ | ||
"name": "broccoli-ember-preparse", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Broccoli plugin that applies some compile time performance optimizations to an ember build. ", | ||
@@ -25,12 +25,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"amd-name-resolver": "0.0.2", | ||
"amd-name-resolver": "0.0.5", | ||
"babel-traverse": "^6.5.0", | ||
"babylon": "^6.5.0", | ||
"broccoli-caching-writer": "^2.2.1", | ||
"broccoli-file-remover": "^0.3.1", | ||
"broccoli-merge-trees": "^1.1.1", | ||
"falafel": "^1.2.0", | ||
"broccoli-caching-writer": "^3.0.0", | ||
"graphlib": "^2.0.0", | ||
"rsvp": "^3.2.0", | ||
"walk-sync": "^0.2.6" | ||
"walk-sync": "^0.3.0" | ||
}, | ||
@@ -37,0 +34,0 @@ "devDependencies": { |
@@ -11,7 +11,10 @@ # broccoli-ember-preparse | ||
``` javascript | ||
var emberPreparse = require('broccoli-ember-preparse'); | ||
var preparse = require('broccoli-ember-preparse'); | ||
var Funnel = require('broccoli-funnel'); | ||
// distTree must include the ember.debug.js and ember.prod.js files | ||
// loaderPackageTree must include ember's loader package | ||
var newDistTree = emberPreparse(distTree, loaderPackageTree); | ||
var bowerDist = new Funnel('bower_components/ember', { | ||
exclude: ['.bower.json'] | ||
}); | ||
var options = {}; | ||
var newDist = preparse(bowerDist, options); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
453
20
17437
1
+ Addedamd-name-resolver@0.0.5(transitive)
+ Addedbroccoli-caching-writer@3.0.3(transitive)
+ Addedbroccoli-kitchen-sink-helpers@0.3.1(transitive)
+ Addedwalk-sync@0.3.4(transitive)
- Removedbroccoli-file-remover@^0.3.1
- Removedbroccoli-merge-trees@^1.1.1
- Removedfalafel@^1.2.0
- Removedacorn@1.2.2(transitive)
- Removedamd-name-resolver@0.0.2(transitive)
- Removedblank-object@1.0.2(transitive)
- Removedbroccoli-caching-writer@2.3.1(transitive)
- Removedbroccoli-file-remover@0.3.1(transitive)
- Removedbroccoli-kitchen-sink-helpers@0.2.9(transitive)
- Removedbroccoli-merge-trees@1.2.4(transitive)
- Removedbroccoli-plugin@1.1.0(transitive)
- Removedbroccoli-writer@0.1.1(transitive)
- Removedcan-symlink@1.0.0(transitive)
- Removedfalafel@1.2.0(transitive)
- Removedfast-ordered-set@1.0.3(transitive)
- Removedforeach@2.0.6(transitive)
- Removedfs-tree-diff@0.5.9(transitive)
- Removedheimdalljs@0.2.6(transitive)
- Removedheimdalljs-logger@0.1.10(transitive)
- Removedisarray@0.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedpath-posix@1.0.0(transitive)
- Removedrimraf@2.2.8(transitive)
- Removedrsvp@3.2.1(transitive)
- Removedtmp@0.0.28(transitive)
- Removedwalk-sync@0.1.30.2.7(transitive)
Updatedamd-name-resolver@0.0.5
Updatedwalk-sync@^0.3.0