You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then an error occurred with the message: HtmlRspackPlugin: failed to render template from string: ReferenceError: process is not defined;
So it goes into the logic here:
TemplateRender::Template(content) => {// process with template parametersletmut dj = Dojang::new();// align escape | unescape with lodash.template syntax https://lodash.com/docs/4.17.15#template which is html-webpack-plugin's default behavior
dj.with_options(DojangOptions{escape:"-".to_string(),unescape:"=".to_string(),});
dj.add_function_1("toHtml".into(), render_tag).expect("failed to add template function `renderTag`");
dj.add_with_option(self.url.clone(), content.clone()).expect("failed to add template");
dj.render(&self.url, parameters).map_err(|err| {
miette::Error::msg(format!("HtmlRspackPlugin: failed to render template from string: {err}"))})}
But since it's commented out, it should be ignored, right? So should the module in https://docs.rs/crate/rspack_dojang/latest/source/src/dojang.rs consider ignoring template code within comments?
@hardfist Certainly, I need to confirm that the expectation is to add a configuration that by default does not process comments, but also allows this configuration to be turned off (maintaining the current logic of processing all comments).
I tried to understand the implementation mechanism of the html-webpack-plugin and found that it has similar issues. The template engine might not handle comments and directly process variables. In this case, you can solve the problem through templateParams. Therefore, in terms of aligning with the capabilities of the html-webpack-plugin, the current html-plugin of Rspack seems reasonable and not a bug.
If modifications are needed, it would also be reasonable because the commented-out code should not have any actual code significance and does not need to process variables. This would require changes to the dojang crate, but it seems I didn't find where to modify this crate.
In conclusion, this seems to be a non-essential modification.
System Info
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Memory: 569.81 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.21 - ~/.nvm/versions/node/v20.10.0/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
pnpm: 9.4.0 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
bun: 1.1.5 - ~/.bun/bin/bun
Browsers:
Chrome: 128.0.6613.138
Safari: 17.4.1
Details
I'm not sure if it's a bug or by design. In my code, I used r
spack.HtmlRspackPlugin
, and then myhtml
has a comment:Then an error occurred with the message:
HtmlRspackPlugin: failed to render template from string: ReferenceError: process is not defined;
So it goes into the logic here:
But since it's commented out, it should be ignored, right? So should the module in
https://docs.rs/crate/rspack_dojang/latest/source/src/dojang.rs
consider ignoring template code within comments?Reproduce link
No response
Reproduce Steps
use this html to build(with rspack.HtmlRspackPlugin).
The text was updated successfully, but these errors were encountered: