Skip to content

The CLI adds the imports and declarations 3 characters too early #9712

Closed

Description

@dushkostanoeski

Versions

Angular CLI: 1.7.0
Node: 9.5.0
OS: win32 x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

angular/cdk: 5.2.2
angular/cli: 1.7.0
angular/material: 5.2.2
angular-devkit/build-optimizer: 0.3.1
angular-devkit/core: 0.3.1
angular-devkit/schematics: 0.3.1
ngtools/json-schema: 1.2.0
ngtools/webpack: 1.10.0
schematics/angular: 0.3.1
schematics/package-update: 0.3.1
typescript: 2.6.2
webpack: 3.11.0

Repro steps

I am writing an app in a Cyrillic language, and the encoding of the files that the CLI generates don't support the Cyrillic characters (I am getting ��� �� ������ in the browser) so I found this powershell script:

$files = Get-ChildItem 'PATH_TO_APP_FOLDER' -Recurse | ? {Test-Path $_.FullName -PathType Leaf}
                           foreach($file in $files)
{
    $content = Get-Content $file.FullName
    $content | Out-File $file.FullName -Encoding utf8
}

that converts all the files to UTF 8 and that way I can get Cyrillic in the browser. To reproduce the issue simply create a new project, run the script (make sure that the path points to the app folder) and then add a new component to the project. Imports in the module would look something like this:

import { ChangePasswordComponent } from './dialogs/change-password/change-password.componen;
import { TestComponent } from './test/test.component't';

and the same happens with the declarations:

    ChangePasswordCompone,
    TestComponentnt

I don't know if this is connected to #2077, but never the less, changing the encoding of the module file shouldn't break the functionality of the CLI.

Desired behavior

The module shouldn't have any errors after a component is generated.

Mention any other details that might be useful (optional)

I thought it had something to do with the script, so I used Notepad++ to convert the module file to UTF8 and again I got the same result.

EDIT:
I just noticed that the import is added 3 characters too early, but the declaration only 2.

Activity

  1. stiofand commented on Feb 22, 2018

    @stiofand

    I can confirm this also happens without any alternate non utf text:

    ng g c new-component

    result in app.module.ts:

    import { NewComponentComponent } from './new-component/new-component.component'';

    ...

    declarations: [
        AppComponen,
        NewComponentComponentt
    ]
    

    Happens on OSX with two different MPS

    Node: 8.9.4
    OS: darwin x64
    Angular: 5.2.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    @angular/cli: 1.7.1
    @angular-devkit/build-optimizer: 0.3.2
    @angular-devkit/core: 0.3.2
    @angular-devkit/schematics: 0.3.2
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.1
    @schematics/angular: 0.3.2
    @schematics/package-update: 0.3.2
    typescript: 2.5.3
    webpack: 3.11.0
    
  2. dushkostanoeski commented on May 16, 2018

    @dushkostanoeski
    Author

    I got used to using the --skip-import flag and this was the first time I forgot to use it after v6 is out. The issue seems to be fixed :D

  3. clydin commented on Jul 19, 2018

    @clydin
    Member

    Duplicate of #9560

  4. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  5. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions