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 4670071
Showing
5 changed files
with
155 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,46 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
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`], | ||
}); | ||
|
||
for (let file of files) { | ||
let inputFilePath = path.join(inputPath, file); | ||
let source = fs.readFileSync(inputFilePath, 'utf8'); | ||
|
||
// ember-data and others compile their own source | ||
if (source.indexOf('define(') === 0) { | ||
this.exclude.push(file); | ||
} | ||
} | ||
|
||
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