Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cacheDirectory = cache && (
(typeof cache === 'string')
? path.resolve(context, cache)
: findCacheDir({ name: wwp, cwd: context }) || path.resolve(context, '.wwp-cache')
);
const cacher = cacheDirectory
? `!${require.resolve('cache-loader')}?${JSON.stringify({ cacheDirectory })}`
: ''
;
new SingleEntryPlugin(context, `!${cacher}${loader}!${logo}`, path.basename(logo)).apply(compiler);
if (compilation.hooks) {
compilation.hooks.webappWebpackPluginBeforeEmit = new AsyncSeriesWaterfallHook(['result']);
}
// Compile and return a promise
return new Promise((resolve, reject) => {
compiler.runAsChild((err, [chunk] = [], { hash, errors = [], assets = {} } = {}) => {
if (err || errors.length) {
return reject(err || errors[0].error);
}
// Replace [hash] placeholders in filename
const output = getAssetPath(compilation, filename, { hash, chunk });
const result = msgpack.decode(Buffer.from(eval(assets[output].source()), 'base64'));
delete compilation.assets[output];
trigger(compilation, 'webapp-webpack-plugin-before-emit', result, (error, { tags = [], assets = [] } = {}) => {
compiler.hooks.compilation.tap('HtmlWebpackPluginHooks', compilation => {
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
compilation.hooks.htmlWebpackPluginAlterChunks = new SyncWaterfallHook(['chunks', 'objectWithPluginRef']);
compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration = new AsyncSeriesWaterfallHook(['pluginArgs']);
compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing = new AsyncSeriesWaterfallHook(['pluginArgs']);
compilation.hooks.htmlWebpackPluginAlterAssetTags = new AsyncSeriesWaterfallHook(['pluginArgs']);
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing = new AsyncSeriesWaterfallHook(['pluginArgs']);
compilation.hooks.htmlWebpackPluginAfterEmit = new AsyncSeriesWaterfallHook(['pluginArgs']);
});
}
constructor(resolverFactory) {
super();
this.hooks = {
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
contextModuleFiles: new SyncWaterfallHook(["files"]),
alternatives: new AsyncSeriesWaterfallHook(["modules"])
};
this._pluginCompat.tap("ContextModuleFactory", options => {
switch (options.name) {
case "before-resolve":
case "after-resolve":
case "alternatives":
options.async = true;
break;
}
});
this.resolverFactory = resolverFactory;
}
export const makeLogParseHooks = (): ILogParseHooks => ({
parseCommit: new AsyncSeriesWaterfallHook(['commit']),
omitCommit: new AsyncSeriesBailHook(['commit'])
});
constructor(context, resolverFactory, options) {
super();
this.hooks = {
resolver: new SyncWaterfallHook(["resolver"]),
factory: new SyncWaterfallHook(["factory"]),
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
createModule: new SyncBailHook(["data"]),
module: new SyncWaterfallHook(["module", "data"]),
createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
createGenerator: new HookMap(
() => new SyncBailHook(["generatorOptions"])
),
generator: new HookMap(
() => new SyncHook(["generator", "generatorOptions"])
)
};
this._pluginCompat.tap("NormalModuleFactory", options => {
switch (options.name) {
case "before-resolve":
case "after-resolve":
constructor(resolverFactory) {
super();
this.hooks = {
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
contextModuleFiles: new SyncWaterfallHook(["files"]),
alternatives: new AsyncSeriesWaterfallHook(["modules"])
};
this._pluginCompat.tap("ContextModuleFactory", options => {
switch (options.name) {
case "before-resolve":
case "after-resolve":
case "alternatives":
options.async = true;
break;
}
});
this.resolverFactory = resolverFactory;
}
constructor(context, resolverFactory, options) {
super();
this.hooks = {
resolver: new SyncWaterfallHook(["resolver"]),
factory: new SyncWaterfallHook(["factory"]),
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
createModule: new SyncBailHook(["data"]),
module: new SyncWaterfallHook(["module", "data"]),
createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
createGenerator: new HookMap(
() => new SyncBailHook(["generatorOptions"])
),
generator: new HookMap(
() => new SyncHook(["generator", "generatorOptions"])
)
};
this._pluginCompat.tap("NormalModuleFactory", options => {
switch (options.name) {
case "before-resolve":
case "after-resolve":
options.async = true;
constructor({ action, farm, workerOptions, persistent, context }) {
this.action = action;
this.workerOptions = workerOptions;
this.persistent = persistent;
this.context = context;
this.farm = farm;
this.tasks = [];
this.hooks = {
createTask: new SyncHook(['task']),
before: new AsyncSeriesWaterfallHook(['tasksApi']),
success: new AsyncSeriesWaterfallHook(['result']),
failure: new AsyncSeriesWaterfallHook(['error']),
};
}