This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ class CachedChildCompilation {
* @type {WebpackCompiler}
*/
this.compiler = compiler;
// Create a singlton instance for the compiler
// Create a singleton instance for the compiler
// if there is none
if (compilerMap.has(compiler)) {
return;
+22 -7
View File
@@ -18,8 +18,8 @@ const LibraryTemplatePlugin = require('webpack/lib/LibraryTemplatePlugin');
const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
/**
* The HtmlWebpackChildCompiler is a helper to allow resusing one childCompiler
* for multile HtmlWebpackPlugin instances to improve the compilation performance.
* The HtmlWebpackChildCompiler is a helper to allow reusing one childCompiler
* for multiple HtmlWebpackPlugin instances to improve the compilation performance.
*/
class HtmlWebpackChildCompiler {
/**
@@ -53,14 +53,14 @@ class HtmlWebpackChildCompiler {
/**
* Returns true if the childCompiler is currently compiling
* @retuns {boolean}
* @returns {boolean}
*/
isCompiling () {
return !this.didCompile() && this.compilationStartedTimestamp !== undefined;
}
/**
* Returns true if the childCOmpiler is done compiling
* Returns true if the childCompiler is done compiling
*/
didCompile () {
return this.compilationEndedTimestamp !== undefined;
@@ -118,7 +118,16 @@ class HtmlWebpackChildCompiler {
}
// Reject the promise if the childCompilation contains error
if (childCompilation && childCompilation.errors && childCompilation.errors.length) {
const errorDetails = childCompilation.errors.map(error => error.message + (error.error ? ':\n' + error.error : '')).join('\n');
const errorDetails = childCompilation.errors.map(error => {
let message = error.message;
if (error.error) {
message += ':\n' + error.error;
}
if (error.stack) {
message += '\n' + error.stack;
}
return message;
}).join('\n');
reject(new Error('Child compilation failed:\n' + errorDetails));
return;
}
@@ -159,12 +168,18 @@ class HtmlWebpackChildCompiler {
* @returns Array<string>
*/
function extractHelperFilesFromCompilation (mainCompilation, childCompilation, filename, childEntryChunks) {
const webpackMajorVersion = Number(require('webpack/package.json').version.split('.')[0]);
const helperAssetNames = childEntryChunks.map((entryChunk, index) => {
return mainCompilation.mainTemplate.getAssetPath(filename, {
const entryConfig = {
hash: childCompilation.hash,
chunk: entryChunk,
name: `HtmlWebpackPlugin_${index}`
});
};
return webpackMajorVersion === 4
? mainCompilation.mainTemplate.getAssetPath(filename, entryConfig)
: mainCompilation.getAssetPath(filename, entryConfig);
});
helperAssetNames.forEach((helperFileName) => {
+1 -1
View File
@@ -1,6 +1,6 @@
// @ts-check
/**
* To use the availble webpack core api
* To use the available webpack core api
* we have to use different child compilers
* depending on the used webpack version
*/
+3 -3
View File
@@ -2,8 +2,8 @@
/** @typedef {import("../typings").HtmlTagObject} HtmlTagObject */
/**
* @file
* This file provides to helper to create html as a object repesentation as
* thoses objects are easier to modify than pure string representations
* This file provides to helper to create html as a object representation as
* those objects are easier to modify than pure string representations
*
* Usage:
* ```
@@ -47,7 +47,7 @@ function htmlTagObjectToString (tagDefinition, xhtml) {
* Static helper to create a tag object to be get injected into the dom
*
* @param {string} tagName
* the name of the tage e.g. 'div'
* the name of the tag e.g. 'div'
*
* @param {{[attributeName: string]: string|boolean}} [attributes]
* tag attributes e.g. `{ 'class': 'example', disabled: true }`