Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new eta template function only works if some data is specified in loaderOptions #60

Closed
Kiirani opened this issue Dec 8, 2023 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@Kiirani
Copy link

Kiirani commented Dec 8, 2023

Current behaviour

If you create a partial eta template and import it into js without configuring any data in loaderOptions, an exception is thrown because __data__ is null, and the template doesn't work.

Uncaught TypeError: can't convert null to object
    templateFn file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:30
    updatePage file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:131
    <anonymous> file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:126
    EventListener.handleEvent* file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:125
    <anonymous> file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:134
    <anonymous> file://///wsl$/Debian/home/kiirani/code/tmp/hbwp-template-repro/dist/app.js:136

Expected behaviour

The template should work without requiring developers to pass data in through the preprocessor config.

Reproduction Example

https://github.com/Kiirani/hbwp-template-repro

Environment

  • OS: WSL, debian
  • version of Node.js: 21.4.0
  • version of Webpack: 5.89.0
  • version of the Plugin: 3.4.0

Additional context

The test case for this feature (https://github.com/webdiscus/html-bundler-webpack-plugin/tree/master/test/cases/js-tmpl-eta-compile) tests multiple methods of passing data, including through through the config - that's actually how I figured out why it wasn't working....

... possibly splitting that case into separate tests for each data passing mechanism would have caught this? I'm not very familiar with the tooling involved here.

it also might be worth looking at whether this is a problem with the other templating engines

@webdiscus
Copy link
Owner

Hello @Kiirani,

thank you for the issue report. I will fix it.

@webdiscus webdiscus added the bug Something isn't working label Dec 8, 2023
@webdiscus webdiscus added this to the analysis milestone Dec 8, 2023
@webdiscus webdiscus modified the milestones: analysis, done Dec 8, 2023
@webdiscus
Copy link
Owner

webdiscus commented Dec 8, 2023

@Kiirani

the issue is fixed in the version 3.4.2.
Can you please test your code with new version?
Thank you!

@Kiirani
Copy link
Author

Kiirani commented Dec 10, 2023

Yes, it works now, thank you!

@Kiirani Kiirani closed this as completed Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants