Skip to content

Angular2 AOT compilation - "Cannot determine the module for class (... many components which are unused)"  #3636

@localyost3000

Description

@localyost3000

OS?

Cross platform, Testing on Windows 10 now.

Versions.

node v6.3.0

Repro steps.

  1. Create some components
  2. reference one of them in an appModule
  3. bootstrap the module with one component
  4. build with @ngtool/webpack loader
  5. see errors for other unused components

The log given by the failure.

Cannot determine the module for class (....) for each component we don't use.

at analyzeNgModules (C:\Repos\Project\PROJECT\client\node_modules\@angular\compiler\bundles\compiler.umd.js:13079:17)
    at OfflineCompiler.compileModules (C:\Repos\Project\PROJECT\client\node_modules\@angular\compiler\bundles\compiler.umd.js:13115:20)
    at CodeGenerator.codegen (C:\Repos\Project\PROJECT\client\node_modules\@angular\compiler-cli\src\codegen.js:58:30)
    at AotPlugin._make (C:\Repos\Project\PROJECT\client\node_modules\@ngtools\webpack\src\plugin.js:187:43)
    at Compiler.<anonymous> (C:\Repos\Project\PROJECT\client\node_modules\@ngtools\webpack\src\plugin.js:151:75)
    at Compiler.applyPluginsParallel (C:\Repos\Project\PROJECT\client\node_modules\tapable\lib\Tapable.js:193:14)
    at C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:468:8
    at Compiler.applyPluginsAsyncSeries (C:\Repos\Project\PROJECT\client\node_modules\tapable\lib\Tapable.js:95:46)
    at Compiler.compile (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:461:7)
    at C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:47:17
    at next (C:\Repos\Project\PROJECT\client\node_modules\tapable\lib\Tapable.js:102:11)
    at Compiler.<anonymous> (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\CachePlugin.js:31:4)

    at next (C:\Repos\Project\PROJECT\client\node_modules\tapable\lib\Tapable.js:104:14)
    at Compiler.<anonymous> (C:\Repos\Project\PROJECT\client\node_modules\browser-sync-webpack-plugin\index.js:26:5)
    at Compiler.applyPluginsAsyncSeries (C:\Repos\Project\PROJECT\client\node_modules\tapable\lib\Tapable.js:106:13)
    at Watching._go (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:45:16)
    at Watching.<anonymous> (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:36:8)
    at Compiler.readRecords (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:371:10)
    at new Watching (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:33:16)
    at Compiler.watch (C:\Repos\Project\PROJECT\client\node_modules\webpack\lib\Compiler.js:205:17)
    at processOptions (C:\Repos\Project\PROJECT\client\node_modules\webpack\bin\webpack.js:332:12)
    at Object.<anonymous> (C:\Repos\Project\PROJECT\client\node_modules\webpack\bin\webpack.js:339:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)

Mention any other details that might be useful.

We have a src directory with modules and our app components. However, we use a shared npm module to provide common components, pipes, directives, etc between partner apps. This works fine for JIT, but seems to want a module for every component in the shared npm module too, even if we don't need it for this partner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions