angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open ruggedy opened this issue 10 years ago • 4 comments

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.

ruggedy avatar Jun 11 '16 00:06 ruggedy

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:

https://github.com/angular/angular-cli/issues/718#issuecomment-225493863

hmrc87 avatar Jun 13 '16 09:06 hmrc87

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.

ruggedy avatar Jun 13 '16 23:06 ruggedy

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.

filipesilva avatar Jun 17 '16 01:06 filipesilva

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.