Angular-cli: Error compiling JavaScript files in Angular 5 CLI project

Created on 25 Dec 2017  路  8Comments  路  Source: angular/angular-cli

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.

1 (urgent) bufix

Most helpful comment

@filipesilva Any update on this issue? We have a massive Angular 1 + Angular 5 project, and about 500 source files that are still .js

For some reason the @ngtools/webpack plugin is trying to write out our .js files over themselves when compiling with AOT (even though those .js files are ng1)

Is there perhaps a way we can have the plugin force overwrite these files for the moment (since it's all done in memory anyway), or ignore them?

All 8 comments

Same behavior observed.

There is a work in progress PR for this bug in https://github.com/angular/angular-cli/pull/8930.

Same problem with ts + js

@filipesilva Any update on this issue? We have a massive Angular 1 + Angular 5 project, and about 500 source files that are still .js

For some reason the @ngtools/webpack plugin is trying to write out our .js files over themselves when compiling with AOT (even though those .js files are ng1)

Is there perhaps a way we can have the plugin force overwrite these files for the moment (since it's all done in memory anyway), or ignore them?

https://github.com/angular/angular-cli/pull/8930 was merged and should be out in the 1.7 release.

Thanks @filipesilva!

@filipesilva Many thanks. Working fine now.

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._

Was this page helpful?
0 / 5 - 0 ratings