Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile to CommonJS with support for npm #213

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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