beyond
Version:
The Full Stack Universal Typescript Framework
87 lines (73 loc) • 2.57 kB
JavaScript
const DynamicProcessor = global.utils.DynamicProcessor();
const Source = require('./source');
/**
* The files of an extension.
* Example: the "svelte" processor extends the "ts" processor.
* This object would have the "ts" preprocessed files of the "svelte" files.
*/
module.exports = class extends DynamicProcessor {
get dp() {
return 'processor.extender.extension.sources';
}
get extending() {
return this.
}
get preprocessor() {
return this.
}
get processor() {
return this.
}
get valid() {
return this.
}
get hashes() {
return this.
}
get files() {
return this.
}
get overwrites() {
return this.
}
/**
* Processor extension constructor
*
* @param extending {string} The name of the processor that is being extended
* @param preprocessor {object} The preprocessor of the files that extends others processors
*/
constructor(extending, preprocessor) {
super();
this.
this.
this.
super.setup(new Map([['preprocessor', {child: preprocessor}]]));
}
_process() {
const {preprocessed, processor} = this.
const {distribution} = processor;
const extending = this.
/**
* Create the source object
*
* @param sources {object} The files or overwrites map
* @param file {string} The file to be set
* @param extensions {object} The preprocessed extensions of a source
* @return {object}
*/
const createSource = (sources, file, extensions) => {
const extension = extensions.get(extending);
const source = extension && new Source(processor, distribution, extensions.source, extension);
source && sources.set(file, source);
}
this.
preprocessed.files.forEach((extensions, file) => createSource(this.
this.
preprocessed.overwrites.forEach((extensions, file) => createSource(this.
}
}