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.

BUG: Compiler CLI generates malfunctional output (does not use "baseUrl" and "paths" correctly)

See original GitHub issue

🐞 bug report

Affected Package

@angular/compiler-cli

Is this a regression?

Dont know.

Description

When I am trying to compile library, it produces “ivy” code even when "enableIvy" is set to false on some services. This code duplicates import but from wrong module path. Dont know if problem is that “ivy” code is generated and should not be, or just import is generated in bad way.

here https://github.com/ressurectit/ng-common/blob/bug/8.0/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.ts#L3 is import

import {STRING_LOCALIZATION, StringLocalization} from '@anglr/common';

which is using path https://github.com/ressurectit/ng-common/blob/bug/8.0/forms/tsconfig.json#L8 for correct path

        "baseUrl": ".",
        "paths": 
        {
            "@anglr/common": ["../src/common"]
        }

which outputs in https://unpkg.com/@anglr/common@8.0.0-beta.20200903131339/forms/dist/es2015/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js

import { Injectable, Inject, Optional } from '@angular/core';
import { STRING_LOCALIZATION } from '@anglr/common';
import { extend, isString } from '@jscrpt/common';
import { VALIDATION_ERROR_MESSAGES } from '../../misc/types';
import * as i0 from "@angular/core";
import * as i1 from "../../../../src/types/tokens";
import * as i2 from "../../misc/types";

where import * as i1 from "../../../../src/types/tokens"; is used for obtaining STRING_LOCALIZATION same as import { STRING_LOCALIZATION } from '@anglr/common'; but from relative path module which is incorrect and causes failed build of application.

Same code https://github.com/ressurectit/ng-common/blob/bug/8.0/forms/src/directives/hasError/hasError.directive.ts#L4 is used in directive and there it is generated correctly, because no ivy code is generated.

import {StringLocalization, STRING_LOCALIZATION} from '@anglr/common';

https://unpkg.com/@anglr/common@8.0.0-beta.20200903131339/forms/dist/es2015/forms/src/directives/hasError/hasError.directive.js

import { Directive, ElementRef, Optional, SkipSelf, Inject, Input, Injector } from "@angular/core";
import { FormControlDirective, FormControlName, NgModel } from "@angular/forms";
import { generateId, BindThis } from "@jscrpt/common";
import { STRING_LOCALIZATION } from '@anglr/common';
import { Subscription } from "rxjs";
import { ValidationErrorRendererFactory } from '../../services/validationErrorRenderer/validationErrorRenderer.service';
import { SubmittedService } from '../../services/submitted/submitted.service';
import { GroupHasErrorDirective } from '../groupHasError/groupHasError.directive';

🔬 Minimal Reproduction

  • git clone https://github.com/ressurectit/ng-common.git
  • cd ng-common
  • git checkout bug/8.0
  • npm install
  • npm run bundle
  • inspect forms/dist/es2015/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js

🔥 Exception or Error

No error, just not working code.

🌍 Your Environment

Angular Version: 10.1.0 Node Version: 10.19.0 NPM Version: 6.9.0 Windows Version: 10.0.19041 Build 19041

EDIT: updated minimal reproduction steps, since there are new commits and links to correct branch

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kukjevovcommented, Sep 3, 2020

I think that workaround for now could be inject Injector and obtain STRING_LOCALIZATION using Injector so this InjectionToken will not be part of constructor, this could help i think.

But i would rather see this fixed 😃.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 14, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Internal Error when using angularCompilerOptions.baseUrl
I have an Angular 14 project (generated by angular CLI) in Intellij, everything is working as expected, but with relative imports from ...
Read more >
Configuration File | API | Docs - TestCafe
TestCafe tests fail when a page yields a JavaScript error. Use the skipJsErrors option to ignore JavaScript errors. Important. Errors are signs of...
Read more >
Typescript — How to solve the problem with unresolved path ...
The actual cause of the issue is that the tsc compiler does not transpiles correctly the path aliases to absolute (real) paths.
Read more >
Host and deploy ASP.NET Core Blazor WebAssembly
Learn how to host and deploy Blazor WebAssembly using ASP.NET Core, Content Delivery Networks (CDN), file servers, and GitHub Pages.
Read more >
Artifactory REST API - JFrog - JFrog Documentation
To use your API key for Basic Authentication, it must be generated using ... You are using cURL from the unix command line,...
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