-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kelly Selden
committed
Jan 28, 2018
1 parent
d293f0a
commit d83a323
Showing
5 changed files
with
154 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const Funnel = require('broccoli-funnel'); | ||
const walkSync = require('walk-sync'); | ||
|
||
// Some addons do their own compilation, which means the addon trees will | ||
// be a mix of ES6 and AMD files. This plugin gives us a way to separate the | ||
// files, as we don't want to double compile the AMD code. | ||
|
||
// It has a very simple method of detecting AMD code, because we only care | ||
// about babel output, which is pretty consistent. | ||
class AmdExcluder extends Funnel { | ||
constructor(inputNode, options) { | ||
super(inputNode, { | ||
exclude: [], | ||
annotation: options.annotation, | ||
}); | ||
|
||
this.options = options; | ||
} | ||
|
||
build() { | ||
let inputPath = this.inputPaths[0]; | ||
|
||
let files = walkSync(inputPath, { | ||
directories: false, | ||
globs: [`**/*.js`], | ||
}); | ||
|
||
return Promise.all(files.map(file => { | ||
let inputFilePath = path.join(inputPath, file); | ||
return fs.readFile(inputFilePath, 'utf8').then(source => { | ||
if (source.indexOf('define(') === 0) { | ||
this.exclude.push(file); | ||
} | ||
}); | ||
})).then(() => { | ||
super.build(); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = AmdExcluder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function registryHasPreprocessor(registry, type) { | ||
return registry.load(type).length > 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters