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

Production build service problem #953

Closed
petoknm opened this issue May 29, 2016 · 6 comments
Closed

Production build service problem #953

petoknm opened this issue May 29, 2016 · 6 comments

Comments

@petoknm
Copy link

petoknm commented May 29, 2016

I am trying to use a generated service in the main component. When I try to use a generated service in dev environment everything is fine. But when I switch to production is cannot find the service => GET http://localhost:4200/app/flights.service.js 404 (Not Found). The service is not present in the dist folder. Am I doing something wrong? Build is successful but for some reason the service is not there. If it is being bundled into index.js then it should not be requested from flights.service.js, right?

OS: Linux x64, Fedora 23
ng-cli : 1.0.0-beta.5
node: 5.11.1

Reproduction Steps:
Generate a new app using ng new ng-app
Generate a new service using ng g service flights
Then use the service in the app by adding it to the bootstrap list of dependencies and injecting it into the main component.
Serve it in production mode ng serve -prod
Load the app in the browser => GET http://localhost:4200/app/flights.service.js 404 (Not Found)

The app that shows the problem: https://github.com/petoknm/angular2-cli-issue
screenshot from 2016-05-29 10-40-52
screenshot from 2016-05-29 10-41-45

Thank you 😄

@butters16
Copy link

I can confirm that I've seen the same problem. None of my angular-cli generated services or pipes end up in the dist/app folder when using the -prod option. These files show up as expected using the default (nothing explicitly specified, so defaults to dev) or explicitly specifying -dev. I am using [email protected]. Since @petoknm says this issue still exists in the current version 1.0.0-beta.5, I have not tried upgrading.

@riblee
Copy link

riblee commented May 31, 2016

I can confirm the problem still exists in 1.0.0-beta.5.

@borntodesign
Copy link

I have just battled against this issue, I added all my files to the index.ts file for applicable sections ("articles/index.ts", "users/index.ts") and updates all the imports. Also for the main app bootstrapping when declaring global services I exported them from the main index file "app/index.ts". This fixed most things although I personally forgot to then order my files based on how things export and the order in which they do so. Now I am trying to figure out why the cli removes my js files from my public folder and where it puts them lol

@filipesilva
Copy link
Contributor

filipesilva commented Jun 1, 2016

@borntodesign is right - the issue was that the services should not be added to main.ts but instead to your app component. main.ts serves only to bootstrap the app.

Most app files shouldn't appear on dist/ after ng build -prod though, since prod builds are bundled up.

@borntodesign can you open a new issue for the js files in vendor? I think they should be copied over.

@filipesilva
Copy link
Contributor

#1028 was merged in and should be included in beta.6. It should reduce alleviate the scenarios where bundling is broken between main.ts and subpackages of app.

@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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants