Skip to content

fix: no template for dependency error #1058

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

Closed
wants to merge 1 commit into from

Conversation

hax0r31337
Copy link

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

An error would thrown when CSS module called in an EJS Template, like this.

  ERROR in ./src/pages/style.scss
  No template for dependency: CssDependency
  Error: No template for dependency: CssDependency
      at JavascriptGenerator.sourceDependency (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:188:10)
      at JavascriptGenerator.sourceModule (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
      at JavascriptGenerator.generate (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
      at NormalModule.codeGeneration (/home/user/data/dev/bloghaze/node_modules/webpack/lib/NormalModule.js:1208:22)
      at /home/user/data/dev/bloghaze/node_modules/webpack/lib/Compilation.js:3332:22
      at /home/user/data/dev/bloghaze/node_modules/webpack/lib/Cache.js:93:5
      at Hook.eval [as callAsync] (eval at create (/home/user/data/dev/bloghaze/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
      at Cache.get (/home/user/data/dev/bloghaze/node_modules/webpack/lib/Cache.js:75:18)
      at ItemCacheFacade.get (/home/user/data/dev/bloghaze/node_modules/webpack/lib/CacheFacade.js:115:15)
      at Compilation._codeGenerationModule (/home/user/data/dev/bloghaze/node_modules/webpack/lib/Compilation.js:3325:9)
   @ ./src/pages/ sync ^\.\/.*$ ./style.scss
   @ ./node_modules/html-webpack-plugin/lib/loader.js!./src/template.ejs 17:20-48

  Child HtmlWebpackCompiler compiled with 1 error

After hours of debugging, I found out that CssDependencyTemplate is not injected to dependencyTemplates which assigned to the Compilation object for generating the code.
I moved the injection hook from thisCompilation to compilation to apply the template to all Compilation objects.

Breaking Changes

Additional Info

Copy link

linux-foundation-easycla bot commented Nov 8, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a valid fix, can you provide a reproducible repo with the problem?

@alexander-akait
Copy link
Member

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants