Webpack apply method made synchronous
This commit is contained in:
parent
ee443b5db9
commit
baa1247b17
4 changed files with 13 additions and 21 deletions
|
@ -23,12 +23,8 @@ export default class AutoIncreaseVersion {
|
||||||
// we have to register AutoIncreaseVersion instead of firing it straight away
|
// we have to register AutoIncreaseVersion instead of firing it straight away
|
||||||
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
|
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
|
||||||
if (this.context.compiler) {
|
if (this.context.compiler) {
|
||||||
this.context.compiler.plugin('emit', async (compilation, cb) => {
|
this.context.compiler.plugin('emit', (compilation, cb) => {
|
||||||
await new Promise((resolve, reject) => {
|
this.start();
|
||||||
this.resolve = resolve;
|
|
||||||
this.reject = reject;
|
|
||||||
this.start();
|
|
||||||
});
|
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -58,8 +54,6 @@ export default class AutoIncreaseVersion {
|
||||||
this.minor();
|
this.minor();
|
||||||
} else if (isArgv('patch')) {
|
} else if (isArgv('patch')) {
|
||||||
this.patch();
|
this.patch();
|
||||||
} else {
|
|
||||||
this.resolve();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ export default class InjectAsComment {
|
||||||
}
|
}
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
return new Promise((resolve) => { resolve(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parseTags(baseOpen, baseClose) {
|
parseTags(baseOpen, baseClose) {
|
||||||
|
|
|
@ -65,6 +65,5 @@ export default class InjectByTag {
|
||||||
}
|
}
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
return new Promise((resolve) => { resolve(); });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
src/main.js
22
src/main.js
|
@ -49,9 +49,9 @@ export default class WebpackAutoInject {
|
||||||
* @param compiler
|
* @param compiler
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
async apply(compiler) {
|
apply(compiler) {
|
||||||
this.compiler = compiler;
|
this.compiler = compiler;
|
||||||
await this.executeWebpackComponents();
|
this.executeWebpackComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,8 +59,8 @@ export default class WebpackAutoInject {
|
||||||
* - runs as soon as possible,
|
* - runs as soon as possible,
|
||||||
* > without waiting for webpack init
|
* > without waiting for webpack init
|
||||||
*/
|
*/
|
||||||
async executeNoneWebpackComponents() {
|
executeNoneWebpackComponents() {
|
||||||
await this.executeComponent([AutoIncreaseVersion]);
|
this.executeComponent([AutoIncreaseVersion]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,11 +68,11 @@ export default class WebpackAutoInject {
|
||||||
* - runs when webpack is initialized
|
* - runs when webpack is initialized
|
||||||
* and plugins is called by webpack
|
* and plugins is called by webpack
|
||||||
*/
|
*/
|
||||||
async executeWebpackComponents() {
|
executeWebpackComponents() {
|
||||||
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
|
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
|
||||||
await this.executeComponent([AutoIncreaseVersion]);
|
this.executeComponent([AutoIncreaseVersion]);
|
||||||
}
|
}
|
||||||
await this.executeComponent([InjectAsComment, InjectByTag]);
|
this.executeComponent([InjectAsComment, InjectByTag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ export default class WebpackAutoInject {
|
||||||
* - general layer for comp execution
|
* - general layer for comp execution
|
||||||
* - used for both, webpack and non webpack comp
|
* - used for both, webpack and non webpack comp
|
||||||
*/
|
*/
|
||||||
async executeComponent(components) {
|
executeComponent(components) {
|
||||||
// no more components,
|
// no more components,
|
||||||
// finish
|
// finish
|
||||||
if (!components.length) {
|
if (!components.length) {
|
||||||
|
@ -92,7 +92,7 @@ export default class WebpackAutoInject {
|
||||||
|
|
||||||
// if component is disabled, call next component
|
// if component is disabled, call next component
|
||||||
if (!this.config.components[ComponentClass.componentName.toLowerCase()]) {
|
if (!this.config.components[ComponentClass.componentName.toLowerCase()]) {
|
||||||
await this.executeComponent(components);
|
this.executeComponent(components);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ export default class WebpackAutoInject {
|
||||||
let inst = new ComponentClass(this);
|
let inst = new ComponentClass(this);
|
||||||
|
|
||||||
// await for apply to finish
|
// await for apply to finish
|
||||||
await inst.apply();
|
inst.apply();
|
||||||
|
|
||||||
// call next tick
|
// call next tick
|
||||||
await this.executeComponent(components);
|
this.executeComponent(components);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue