mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
This is in addition to registering for extensions. Note that only the new SourceProcessor APIs allow this, not registerSourceHandler. The filename in question is the basename of the file. The file can be found in any directory in any package. If you want to be more picky, you can just ignore other ones in your processFilesForTarget. This introduces the SourceProcessorSet abstraction, which simplifies a lot of repeated code around matching filenames with processors and avoiding duplicates. Missing tests. See also #3985.
76 lines
1.5 KiB
JavaScript
76 lines
1.5 KiB
JavaScript
const buildPluginModule = require('./build-plugin.js');
|
|
|
|
class InputFile extends buildPluginModule.InputFile {
|
|
constructor(source, options = {}) {
|
|
super();
|
|
|
|
this._source = source;
|
|
this._arch = options.arch;
|
|
this._minifiedFiles = [];
|
|
}
|
|
|
|
getContentsAsBuffer() {
|
|
return this._source.contents();
|
|
}
|
|
getPathInPackage() {
|
|
throw new Error("Compiled files don't belong to any package");
|
|
}
|
|
getPackageName() {
|
|
throw new Error("Compiled files don't belong to any package");
|
|
}
|
|
getSourceHash() {
|
|
return this._source.hash();
|
|
}
|
|
getArch() {
|
|
return this._arch;
|
|
}
|
|
|
|
/**
|
|
* @summary Returns the path of the compiled file in the bundle.
|
|
* @memberof InputFile
|
|
* @returns {String}
|
|
*/
|
|
getPathInBundle() {
|
|
return this._source.targetPath;
|
|
}
|
|
|
|
/**
|
|
* @summary Returns the source-map associated with the file.
|
|
* @memberof InputFile
|
|
* @returns {String}
|
|
*/
|
|
getSourceMap() {
|
|
return this._source.sourceMap;
|
|
}
|
|
}
|
|
|
|
export class JsFile extends InputFile {
|
|
// - data
|
|
// - sourceMap
|
|
// - path
|
|
// - hash?
|
|
addJavaScript(options) {
|
|
const self = this;
|
|
self._minifiedFiles.push({
|
|
data: options.data,
|
|
sourceMap: options.sourceMap,
|
|
path: options.path
|
|
});
|
|
}
|
|
}
|
|
|
|
export class CssFile extends InputFile {
|
|
// - data
|
|
// - sourceMap
|
|
// - path
|
|
// - hash?
|
|
addStylesheet(options) {
|
|
this._minifiedFiles.push({
|
|
data: options.data,
|
|
sourceMap: options.sourceMap,
|
|
path: options.path
|
|
});
|
|
}
|
|
}
|
|
|