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';
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:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
I think that workaround for now could be inject
Injector
and obtainSTRING_LOCALIZATION
usingInjector
so thisInjectionToken
will not be part of constructor, this could help i think.But i would rather see this fixed 😃.
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.