Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling JavaScript files in Angular 5 CLI project #8991

Closed
daveryderoxford opened this issue Dec 25, 2017 · 8 comments
Closed

Error compiling JavaScript files in Angular 5 CLI project #8991

daveryderoxford opened this issue Dec 25, 2017 · 8 comments
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix

Comments

@daveryderoxford
Copy link

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.

@masfaraud
Copy link

Same behavior observed.

@filipesilva
Copy link
Contributor

There is a work in progress PR for this bug in #8930.

@filipesilva filipesilva added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix labels Dec 26, 2017
@wilsoncook
Copy link

Same problem with ts + js

@gregjacobs
Copy link

@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?

@hansl hansl removed their assignment Feb 6, 2018
@filipesilva
Copy link
Contributor

#8930 was merged and should be out in the 1.7 release.

@gregjacobs
Copy link

Thanks @filipesilva!

@daveryderoxford
Copy link
Author

@filipesilva Many thanks. Working fine now.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Projects
None yet
Development

No branches or pull requests

6 participants