question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Language service "component not in module" error when using `require.context`

See original GitHub issue

🐞 bug report

Affected Package

@angular/language-service

Is this a regression?

No

Description

I use dynamic importing of components (require.context) to import them into angular modules. Angular language service can’t detect that so it issues me the Component 'x' is not included in a module and will not be available inside a template. Consider adding it to a NgModule declaration error on all of my components.

I know that angular can’t do much here to detect those usages, so can I at least disable this error in the language service?

🌍 Your Environment

Angular Version:

Angular CLI: 7.3.2
Node: 12.4.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.2
@angular-devkit/core         7.3.2
@angular-devkit/schematics   7.3.2
@schematics/angular          7.3.2
@schematics/update           0.13.2
rxjs                         6.3.3
typescript                   3.2.4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
atscottcommented, Oct 26, 2020

Hi @mrahhal, thanks for reporting this issue. I’m closing it since the underlying problem is covered by the feature RFC #32663

1reaction
mrahhalcommented, Sep 12, 2019

Yes that would help a lot as we still have it disabled in the whole team, we’re really missing having analysis in our html files. A standalone file like .config.ngls sounds perfect πŸ‘Œ

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get require.context to work with Create React App with ...
I think the TypeError: __webpack_require__(...).context is not a function error was caused by a missing @types/webpack-env dependency however.
Read more >
Dependency Management - webpack
A context module is generated. It contains references to all modules in that directory that can be required with a request matching the...
Read more >
Replacement for `require.context` when running Jest-Vue.js
If someone still run into this issue, you need to know that require.context is a webpack-specific feature, so it doesn't work in jest....
Read more >
Getting started with standalone components - Angular
Angular classes marked as standalone do not need to be declared in an NgModule (the Angular compiler will report an error if you...
Read more >
[error] Drupal\Component\Plugin\Exception\ContextException
Not had time to investigate so don't know if other modules using ctools ... confirmed reverting to composer require 'drupal/ctools:3.9.0'Β ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found