feat: add node.js api definitions

This commit is contained in:
tkqubo
2016-01-25 13:38:35 +09:00
parent a39e8c409e
commit 51868917c7
2 changed files with 137 additions and 0 deletions
+54
View File
@@ -413,3 +413,57 @@ plugin = new webpack.ExtendedAPIPlugin();
plugin = new webpack.NoErrorsPlugin();
plugin = new webpack.WatchIgnorePlugin(paths);
//
// http://webpack.github.io/docs/node.js-api.html
//
// returns a Compiler instance
webpack({
// configuration
}, function(err, stats) {
// ...
});
// returns a Compiler instance
var compiler = webpack({
// configuration
});
compiler.run(function(err, stats) {
// ...
});
// or
compiler.watch({ // watch options:
aggregateTimeout: 300, // wait so long for more changes
poll: true // use polling instead of native watchers
// pass a number to set the polling interval
}, function(err, stats) {
// ...
});
declare function handleFatalError(err: Error): void;
declare function handleSoftErrors(errs: string[]): void;
declare function handleWarnings(errs: string[]): void;
declare function successfullyCompiled(): void;
webpack({
// configuration
}, function(err, stats) {
if(err)
return handleFatalError(err);
var jsonStats = stats.toJson();
if(jsonStats.errors.length > 0)
return handleSoftErrors(jsonStats.errors);
if(jsonStats.warnings.length > 0)
handleWarnings(jsonStats.warnings);
successfullyCompiled();
});
declare var fs: any;
compiler = webpack({ });
compiler.outputFileSystem = fs;
compiler.run(function(err, stats) {
// ...
var fileContent = fs.readFileSync("...");
});