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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get error "Module not found: Error: Can't resolve" after build when I import d.ts file #15411

Closed
dxvladislavvolkov opened this issue Aug 22, 2019 · 5 comments

Comments

@dxvladislavvolkov
Copy link

馃悶 bug report

Description

I created a component in which I use types from a d.ts file. Import to d.ts is not deleted in js file after build and I get the error "Module not found: Error: Can't resolve "

馃敩 Minimal Reproduction

For reproduction, you can use this project
and the following steps:

  1. npm i
  2. ng build my-lib
  3. ng build

After it, you get the error

馃敟 Exception or Error


ERROR in ./dist/my-lib/fesm2015/my-lib.js
Module not found: Error: Can't resolve 'devextreme/bundles/dx.all' in 'C:\Users\volkov.vladislav\Downloads\downloadnew\ivy-missing-deps-master\ivy-missing-deps-master\dist\my-lib\fesm2015'

馃實 Your Environment

Angular Version:




Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.802.2
@angular-devkit/build-angular      0.802.2
@angular-devkit/build-ng-packagr   0.802.2
@angular-devkit/build-optimizer    0.802.2
@angular-devkit/build-webpack      0.802.2
@angular-devkit/core               8.2.2
@angular-devkit/schematics         8.2.2
@angular/cli                       8.2.2
@ngtools/webpack                   8.2.2
@schematics/angular                8.2.2
@schematics/update                 0.802.2
ng-packagr                         5.5.0
rxjs                               6.4.0
typescript                         3.5.3
webpack                            4.38.0

Anything else relevant?

Perhaps this is due to this issue. But I do not understand why this issue was closed. The problem is still reproducing.

@mgechev mgechev transferred this issue from angular/angular Aug 22, 2019
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Aug 23, 2019

Hi, I just had a quick look and there is devextreme/bundles/dx.all JS bundle, there is only a type definition for it, and hence the failure is correct.
image

DevExtreme also seems to offer an Angular package https://js.devexpress.com/Documentation/Guide/Angular_Components/Getting_Started/Add_DevExtreme_to_an_Angular_CLI_Application/#Import_DevExtreme_Modules

More more thing which is unrelated to the issue is that import to your library in app.component https://github.com/ovchinnikov/ivy-missing-deps/blob/ae27b1ae00b02a957cbe7b47b0e0a42fa42443dc/src/app/app.module.ts#L5 is incorrect as it should point to the library module using it's name and not the relative path to dist.

From

import { MyLibModule } from '../../dist/my-lib';

To

import { MyLibModule } from 'my-lib';

That said, this seems to be a support request and not a bug in Angular CLI. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular-cli.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

@dxvladislavvolkov
Copy link
Author

Why is the failure correct? I want to use types from d.ts in my lib. It can be another d.ts, not only dx.all. After build, I have unnecessary import in a js file and I get the error

@dxvladislavvolkov
Copy link
Author

Perhaps this is due to this issue. But I do not understand why this issue was closed. The problem is still reproducing.

@alan-agius4
Copy link
Collaborator

You are right, for types only it should matter the import.
This issue is however being tracked here: angular/angular#21280

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants