html-rspack-plugin
Advanced tools
+45
-43
@@ -20,2 +20,4 @@ // @ts-check | ||
| const WITH_PLACEHOLDER = 'function __with_placeholder__'; | ||
| /** @typedef {import("../typings.js").HtmlTagObject} HtmlTagObject */ | ||
@@ -129,3 +131,3 @@ /** @typedef {import("../typings.js").Options} HtmlWebpackOptions */ | ||
| : // Replace '[name]' with entry name | ||
| (entryName) => userOptionFilename.replace(/\[name\]/g, entryName); | ||
| (entryName) => userOptionFilename.replace(/\[name\]/g, entryName); | ||
@@ -371,14 +373,14 @@ /** output filenames for the given entry names */ | ||
| ? // If a hard coded public path exists use it | ||
| webpackPublicPath | ||
| webpackPublicPath | ||
| : // If no public path was set get a relative url path | ||
| path | ||
| .relative( | ||
| path.resolve( | ||
| compilation.options.output.path, | ||
| path.dirname(filename), | ||
| ), | ||
| path | ||
| .relative( | ||
| path.resolve( | ||
| compilation.options.output.path, | ||
| ) | ||
| .split(path.sep) | ||
| .join('/'); | ||
| path.dirname(filename), | ||
| ), | ||
| compilation.options.output.path, | ||
| ) | ||
| .split(path.sep) | ||
| .join('/'); | ||
@@ -505,4 +507,4 @@ if (publicPath.length && publicPath.substr(-1, 1) !== '/') { | ||
| if (source.indexOf('__with_placeholder__') >= 0) { | ||
| source = source.replace('__with_placeholder__', 'with'); | ||
| if (source.indexOf(WITH_PLACEHOLDER) >= 0) { | ||
| source = source.replace(WITH_PLACEHOLDER, 'with'); | ||
| } | ||
@@ -600,6 +602,6 @@ | ||
| : Promise.reject( | ||
| new Error( | ||
| 'The loader "' + templateWithoutLoaders + '" didn\'t return html.', | ||
| ), | ||
| ); | ||
| new Error( | ||
| 'The loader "' + templateWithoutLoaders + '" didn\'t return html.', | ||
| ), | ||
| ); | ||
| } | ||
@@ -658,15 +660,15 @@ | ||
| ? // A custom function can overwrite the entire template parameter preparation | ||
| templateParameters | ||
| templateParameters | ||
| : // If the template parameters is an object merge it with the default values | ||
| (compilation, assetsInformationByGroups, assetTags, options) => | ||
| Object.assign( | ||
| {}, | ||
| templateParametersGenerator( | ||
| compilation, | ||
| assetsInformationByGroups, | ||
| assetTags, | ||
| options, | ||
| ), | ||
| templateParameters, | ||
| ); | ||
| (compilation, assetsInformationByGroups, assetTags, options) => | ||
| Object.assign( | ||
| {}, | ||
| templateParametersGenerator( | ||
| compilation, | ||
| assetsInformationByGroups, | ||
| assetTags, | ||
| options, | ||
| ), | ||
| templateParameters, | ||
| ); | ||
| const preparedAssetTags = { | ||
@@ -862,3 +864,3 @@ headTags: this.prepareAssetTagGroupForRendering(assetTags.headTags), | ||
| const source = new compiler.webpack.sources.RawSource( | ||
| /** @type {string | Buffer} */ (buf), | ||
| /** @type {string | Buffer} */(buf), | ||
| false, | ||
@@ -877,3 +879,3 @@ ); | ||
| faviconPath, | ||
| /** @type {string} */ (compilation.hash), | ||
| /** @type {string} */(compilation.hash), | ||
| ); | ||
@@ -957,4 +959,4 @@ } | ||
| ? { | ||
| href: base, | ||
| } | ||
| href: base, | ||
| } | ||
| : base, | ||
@@ -985,5 +987,5 @@ }, | ||
| ? { | ||
| name: metaName, | ||
| content: metaTagContent, | ||
| } | ||
| name: metaName, | ||
| content: metaTagContent, | ||
| } | ||
| : metaTagContent; | ||
@@ -1227,4 +1229,4 @@ }) | ||
| this.options.inject === 'head' || | ||
| (this.options.inject !== 'body' && | ||
| this.options.scriptLoading !== 'blocking') | ||
| (this.options.inject !== 'body' && | ||
| this.options.scriptLoading !== 'blocking') | ||
| ? 'head' | ||
@@ -1294,7 +1296,7 @@ : 'body'; | ||
| : this.executeTemplate( | ||
| compilationResult, | ||
| assetsHookResult.assets, | ||
| { headTags: assetTags.headTags, bodyTags: assetTags.bodyTags }, | ||
| compilation, | ||
| ), | ||
| compilationResult, | ||
| assetsHookResult.assets, | ||
| { headTags: assetTags.headTags, bodyTags: assetTags.bodyTags }, | ||
| compilation, | ||
| ), | ||
| ); | ||
@@ -1301,0 +1303,0 @@ |
+3
-2
@@ -33,2 +33,3 @@ /* This loader renders the template with lodash.template if no other loader was found */ | ||
| const WITH_PLACEHOLDER = 'function __with_placeholder__'; | ||
| const escapeStringChar = (chr) => '\\' + stringEscapes[chr]; | ||
@@ -154,7 +155,7 @@ | ||
| // The following part renders the template with lodash as a minimalistic loader | ||
| // The `function __with_placeholder__` will be replaced with `with` in the next step | ||
| // The WITH_PLACEHOLDER will be replaced with `with` in the next step | ||
| // to make the code compatible with SWC strict mode | ||
| const { compiled, isEscaping } = template(source); | ||
| return ` | ||
| module.exports = function (templateParams) { function __with_placeholder__(templateParams) { | ||
| module.exports = function (templateParams) { ${WITH_PLACEHOLDER}(templateParams) { | ||
| ${isEscaping ? escapeCode : ''} | ||
@@ -161,0 +162,0 @@ // Execute the lodash template |
+1
-1
| { | ||
| "name": "html-rspack-plugin", | ||
| "version": "6.1.1", | ||
| "version": "6.1.2", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Simplifies creation of HTML files to serve your Rspack bundles", |
109807
0.01%2563
0.08%