Skip to content

Commit

Permalink
Build npm-compatible package in build/npm
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorton committed Oct 3, 2015
1 parent 5a8ec86 commit 0a372fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var buildExtras = new Funnel('build-support', {

var lib = {};
var main = {};
var commonJs = {};
var globalized = {};

packages.forEach(function(package) {
Expand All @@ -89,13 +90,37 @@ packages.forEach(function(package) {
});

main[package.name] = mergeTrees([ lib[package.name] ]);

// Generate npm
var npm = new compileES6Modules(main[package.name], {
format: 'cjs'
});
npm = new transpileES6(npm);
npm = replace(npm, {
files: ['**/*.js'],
pattern: {
match: /require\('orbit/g,
replacement: function() {
return "require('orbit.js/orbit";
}
}
});
npm = new Funnel(npm, {
srcDir: '/',
destDir: '/npm/'
});

// Generate AMD
main[package.name] = new compileES6Modules(main[package.name]);
main[package.name] = new transpileES6(main[package.name]);
main[package.name] = concat(main[package.name], {
inputFiles: ['**/*.js'],
outputFile: '/' + package.name + '.amd.js'
});

// Merge in npm-tree
main[package.name] = mergeTrees([main[package.name], npm]);

var support = new Funnel('build-support', {
srcDir: '/',
files: ['iife-start.js', 'globalize-' + package.name + '.js', 'iife-stop.js'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"broccoli-jshint": "^0.5.3",
"broccoli-merge-trees": "^0.1.4",
"broccoli-sourcemap-concat": "^0.4.3",
"broccoli-string-replace": "0.0.2",
"broccoli-string-replace": "^0.1.0",
"git-repo-version": "^0.1.1",
"testem": "^0.7.6",
"yuidocjs": "^0.8.1",
Expand Down

0 comments on commit 0a372fe

Please sign in to comment.