Skip to content

AOT should be handled different way #1490

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

Closed
pleerock opened this issue Feb 7, 2017 · 8 comments
Closed

AOT should be handled different way #1490

pleerock opened this issue Feb 7, 2017 · 8 comments

Comments

@pleerock
Copy link

pleerock commented Feb 7, 2017

This file should not really be in this project. The problem is that it's depend on AppModuleNgFactory which is imported from "../compiled/src/app/AppModule.ngfactory";. But this file is not present in the project until you compile it using ngc. And even if you compile it, what to do with other people having this error? They can run same command, but this is not an option. Another option is to commit these files, but its also bad idea. Having always the error that this file is missing absolutely not an option.

AFAIK angular-cli does not require you to create this file and handles aot specifics by its own.

@shlomiassaf
Copy link
Contributor

shlomiassaf commented Feb 7, 2017

@pleerock This file belongs to the project, no issue with it.

angular-cli creates this file at webpack runtime, but in the same time has a lot of other "enforcements", like having to use it's internal TS loader and other stuff.

There is no issue with this file in the project since it is not an entry point when not in AOT mode hence it's there but not used.

When this file is used, it is in AOT mode which means that the AOT compiler just finished running so the file is referencing an existing file.

The error people get is because the awesome-typescript-loader type checker does not care about the entry point, it parses the whole library so people get errors but they are virtual.

The error should be fixed soon once s-panferov/awesome-typescript-loader#364 is set which is the direct cause of the problem

See #1378

@colinskow
Copy link
Contributor

I've never gotten an error related to this anyway using recent versions of this repo.

@pleerock
Copy link
Author

pleerock commented Feb 8, 2017

@colinskow run typescript compiler without webpack and you'll get it.

@shlomiassaf
Copy link
Contributor

@pleerock that's because the tsconfig is not configured for that task.

@pleerock
Copy link
Author

pleerock commented Feb 8, 2017

@shlomiassaf , no, it is configured. I'm talking about using typescript compiler without anything else (webpack, ngc, etc.). There are nothing in tsconfig that indicates to skip main.browser.aot.ts file (solution may be to exclude main.browser.aot.ts from default tsc compilation). Checkout this repo from scratch, don't use webpack or ngc, just use tsc and you'll see typescript compiler error.

@shlomiassaf
Copy link
Contributor

@pleerock I'm not saying the running tsc as you describe will not yield an error, it will.

When I say

that's because the tsconfig is not configured for that task.

I mean that the way you use it is not the way it is intended to be used.

tsc is a command line tool based on a static JSON file, if you want multiple configurations you need multiple files.

This repository is based on webpack, not tsc, we use webpack tools to dynamically control the tool chain. We don't exclude main.browser.aot.ts in our tsconfig because we relay on webpack entryPoint for that.

You are trying to use one of the tools in the toolchain without providing the proper environment to it, which we do using webpack.

Anyway, I can't think of any use case to run tsc outside of webpack, the output will not work even if no error.

@pleerock
Copy link
Author

pleerock commented Feb 8, 2017

Anyway, I can't think of any use case to run tsc outside of webpack, the output will not work even if no error.

actually it will depend on use case if you configure it properly.

The problem is IDE compiler. IDE uses tsc to compile the code and it does not care about webpack. You'll have this error in IDE until you run webpack which will run ngc which will create "compile" directory with file required for compilation. Bad workflow.

@brud
Copy link

brud commented Feb 22, 2017

Which exact command I should execute to get /compiled/ directory in project? When I execute npm run build:aot it doesn't create any new folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants