-
Notifications
You must be signed in to change notification settings - Fork 12k
CommonJS or AMD dependencies warnings with absolute path #18057
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
Comments
The same problem occurs when using
{
"architect": {
"build": {
"options": {
"allowedCommonJsDependencies": [
"@core/*"
],
{
"compilerOptions": {
...,
"paths": {
"@core/*": ["./src/app/core/*"]
} |
@alan-agius4: Full {
"compileOnSave": false,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": true,
"lib": ["ES2018", "ES2020", "DOM"],
"module": "ESNext",
"moduleResolution": "node",
"outDir": "./dist/out-tsc",
"resolveJsonModule": true,
"sourceMap": true,
"target": "ES5",
"typeRoots": ["node_modules/@types"],
"paths": {
"@core/*": ["./src/app/core/*"],
"@modules/*": ["./src/app/modules/*"],
"@shared/*": ["./src/app/shared/*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
} |
Hi again, I just tried this locally and wasn't able to reproduce any of the above issues. Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. Thanks |
You can find a minimal app where i can reproduce the problem : https://github.com/grunk/demo_bug_angular_cli ng build should gave you the warning :
If you change the import in shared.module.ts from And build it again. The warning is now gone. Maybe it has something to do with shared module ? |
For us most of the warning messages are coming from local modules as well, when importing components and declaring them in their respective module using absolute paths. Changing the paths to relative fixes the issue as well. The weird thing is that in one of the shared modules, which is located in the same folder/path as another module, not all components that are imported through absolute paths are showing the warning messages, only some. |
Hi, thanks for the reproduction. I have looked at this and this is caused by a combination of 2 things. The first being using non relative imports and the second is that you are using JIT instead of AOT for your development builds. When using JIT, component templates and style sheets are required via a CommonJs require statement. |
@alan-agius4 how about this one:
that would be because AOT is unusable on medium to large projects |
@fxck, see #18019 (comment) |
Switching to AOT in debug build indeed fix the warnings. That's a good enough solution for me. |
We've also been upgrading over the last few years from 5, to 6, to 7, to 8, to 9 and now attempting to upgrade to 10. We've been getting the same cryptic warning messages. The app will still run locally. We use typescript path aliases such as:
And we use them in our app such as:
When attempting to
As a fix (as outlined by @grunk above), enabling
|
I have the |
Still issues here with aot. Please add these issue to the update guide or stop releasing an unfinished and not well tested version that causes developers time lost. |
@Greenek, in that case please provide a reproduction. Otherwise we’ll be unable to investigate your issue. @jimmykane, this feature has been present and finalized since the early beta releases of version 10. None-the-less certain issues were only raised after the stable release. One of the reasons why we do release betas and release candidates is for the community to try out new things and gather feedback and address bugs before the stable version is released. So apologies for the inconvenience but if you didn’t try the betas and raised the issues at that time you also share the responsibility that this bug is now present in the stable version. We cannot possibility think of all the use cases that thousands of users have, which in some cases might be non-standard. |
Are you literally saying I am responsible for this issue (and others) for not trying the betas ? Really man ? |
…plateUrl and styleUrl Currently, when users use either absolute paths, or path mappings in JIT mode, we issue a warning for templateUrl and styleUrl. With this change we suppress those warning. Closes: #18057
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command
Is this a regression?
The warning was no present in v9
Description
When building an app , every import of a module with an absolute path lead to a warning :
import { PasswordStrengthBarComponent } from 'app/components/util/password-strength-bar/password-strength-bar.component';
generate the following warning :
Using a relative path instead fix the warning :
import { PasswordStrengthBarComponent } from '../components/util/password-strength-bar/password-strength-bar.component';
`
I find this warning missleading. According to MDN the module path can be relative or absolute. At least the warning should be different from the real case were commonJS dependencies are used.
🔬 Minimal Reproduction
Import a module with absolute path and
ng build
the project🔥 Exception or Error
🌍 Your Environment
The text was updated successfully, but these errors were encountered: