-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The input config supplies 'patterns' which FileList expands into Files. These files are preprocessed and then 'file-list-modified' is fired. The event offers a pair of file lists, {included, served}. The bundle layer maps this pair to a new pair where fewer files are included. By default the bundler copies the inputs to outputs. The bundled files are stored on currentWebFiles which replaces the FileList.files in the middleware/karma.
- Loading branch information
1 parent
3cb26e3
commit 0fd8d09
Showing
9 changed files
with
313 additions
and
215 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
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,45 @@ | ||
/** | ||
Container class for the files included in context.html and served upon | ||
request. Two instances fit into the files pipeline: | ||
1. The result from FileList.files, the list of preprocessed input files. | ||
2. The result of bundling #1 stored in currentWebFiles | ||
*/ | ||
class WebFiles { | ||
constructor (included, served) { | ||
this.included = [...included] | ||
this.served = [...served] | ||
} | ||
} | ||
|
||
let currentWebFiles = new WebFiles([], []) | ||
|
||
function noOpBundler (webFiles) { | ||
return new WebFiles(webFiles.included, webFiles.served) | ||
} | ||
|
||
let bundler = noOpBundler | ||
|
||
function registerBundler (emitter) { | ||
emitter.on('file_list_modified', (modifiedWebFiles) => { | ||
// Any bundler is expected to return a WebFiles object. | ||
// For sourcemap support, //# sourceUrl in the bundler result should | ||
// point back to the input files. | ||
currentWebFiles = Object.assign(currentWebFiles, bundler(modifiedWebFiles)) | ||
emitter.emit('web_files_modified', currentWebFiles) | ||
}) | ||
} | ||
|
||
function createWebFiles (configBundler, instantiatePlugin, emitter) { | ||
if (configBundler) { | ||
bundler = instantiatePlugin('bundler', configBundler) | ||
} | ||
registerBundler(emitter) | ||
return currentWebFiles | ||
} | ||
|
||
createWebFiles.$inject = ['config.bundler', 'instantiatePlugin', 'emitter'] | ||
|
||
module.exports = { | ||
createWebFiles, | ||
WebFiles | ||
} |
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
Oops, something went wrong.