Skip to content

Error compiling JavaScript files in Angular 5 CLI project #8991

@daveryderoxford

Description

@daveryderoxford

Versions

  Angular CLI: 1.6.2
    Node: 6.10.0
    OS: darwin x64
    Angular: 5.1.2
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router

    @angular/cli: 1.6.2
    @angular-devkit/build-optimizer: 0.0.36
    @angular-devkit/core: 0.0.22
    @angular-devkit/schematics: 0.0.42
    @ngtools/json-schema: 1.1.0
    @ngtools/webpack: 1.9.2
    @schematics/angular: 0.1.11
    @schematics/schematics: 0.0.11
    typescript: 2.4.2
    webpack: 3.10.0

Repro steps

  • Create an empty CLI (1.6.2) project (ng new test2). The project runs fine.
  • Modify tsconfig.json to include the line allowJs": true, to compile/bundle Javascript files
  • Create a simple Javascript file (eg test.js with content i=1;) in the app folder.
  • Build fails in Angular 5 (ng build) with the error below.

test2.zip

Observed behavior

Build fails with the error below:

"ERROR in error TS5055: Cannot write file 
'/Users/user/Documents/workspace/test2/src/app/test.js' because it would 
overwrite input file.  Adding a tsconfig.json file will help organize 
projects that contain both TypeScript and JavaScript files. Learn more at 
https://aka.ms/tsconfig."

Desired behavior

The js file is copied to the out-tsc directory and included in the output bundle.

Mention any other details that might be useful (optional)

In Angular 4 JS file is compiled to the output directory specified in the outDir parameter and included in the final bundle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions