Skip to content

Production build does not include custom directives. Works in dev mode tho. #1063

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
ruggedy opened this issue Jun 11, 2016 · 4 comments
Closed

Comments

@ruggedy
Copy link

ruggedy commented Jun 11, 2016

Please provide us with the following information:

  1. Ubuntu 16.04
  1. Versions. Please run ng --version. If there's nothing outputted, please
    angular-cli: 1.0.0-beta.5
    node: 4.4.5
    os: linux x64
  2. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code?
    created the app with CLI
    no changes to the base code, build on top of the app
  3. The log given by the failure. Normally this include a stack trace and some
    more information.

zone.js:101 GET http://localhost:4200/app/trackscroll.directive.js 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:336Zone.scheduleMacroTask @ zone.js:273(anonymous function) @ zone.js:122send @ VM2683:3fetchTextFromURL @ system.src.js:1154(anonymous function) @ system.src.js:1735ZoneAwarePromise @ zone.js:584(anonymous function) @ system.src.js:1734(anonymous function) @ system.src.js:2759(anonymous function) @ system.src.js:3333(anonymous function) @ system.src.js:3600(anonymous function) @ system.src.js:3985(anonymous function) @ system.src.js:4448(anonymous function) @ system.src.js:4700(anonymous function) @ system.src.js:406ZoneDelegate.invoke @ zone.js:323Zone.run @ zone.js:216(anonymous function) @ zone.js:571ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/app/trackscroll.directive.js
at XMLHttpRequest.wrapFn as _onreadystatechange
at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34)
Error loading http://localhost:4200/app/trackscroll.directive.js as "./app/trackscroll.directive" from http://localhost:4200/main.js ; Zone: ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/app/trackscroll.directive.js(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/app/trackscroll.directive.js(…)

  1. Mention any other details that might be useful.

when hosting on live website, I resolve this issue by copying the .directive.js file
directly to the dist folder and host it. but when running production locally, that doesnt work.

Thanks! We'll be in touch soon.

@hmrc87
Copy link

hmrc87 commented Jun 13, 2016

There should be no link in index.html to to any JavaScript-Class then the standard ones, angular-cli creates. All external libraries / or directives need to be loaded via SystemJS for prod-mode to work. Here are some tips, maybe they help you:

#718 (comment)

@ruggedy
Copy link
Author

ruggedy commented Jun 13, 2016

This is not an external library, this was a custom directive I created with angular cli, and it was bootstrapped in main.ts. but it magically disappears when compiled in production mode.

@filipesilva
Copy link
Contributor

There was a problem with stuff inside of app/ that was being used in main, but it should be fixed in beta.6 due to a change in the bundling strategy.

@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

No branches or pull requests

3 participants