Title: No apparent way to use `--bundle-dependencies=all` successfully since 1.5.0 · Issue #8616 · angular/angular-cli · GitHub
Open Graph Title: No apparent way to use `--bundle-dependencies=all` successfully since 1.5.0 · Issue #8616 · angular/angular-cli
X Title: No apparent way to use `--bundle-dependencies=all` successfully since 1.5.0 · Issue #8616 · angular/angular-cli
Description: Prior to the 1.5.0 release, it was possible to pass --bundle-dependencies=all --prod to get an AoT compiled self-contained bundle that worked for server-side rendering (SSR) under Node.js. Since 1.5.0, these flags produce a bundle that, ...
Open Graph Description: Prior to the 1.5.0 release, it was possible to pass --bundle-dependencies=all --prod to get an AoT compiled self-contained bundle that worked for server-side rendering (SSR) under Node.js. Since 1....
X Description: Prior to the 1.5.0 release, it was possible to pass --bundle-dependencies=all --prod to get an AoT compiled self-contained bundle that worked for server-side rendering (SSR) under Node.js. Since 1....
Opengraph URL: https://github.com/angular/angular-cli/issues/8616
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No apparent way to use `--bundle-dependencies=all` successfully since 1.5.0","articleBody":"Prior to the 1.5.0 release, it was possible to pass `--bundle-dependencies=all --prod` to get an AoT compiled self-contained bundle that worked for server-side rendering (SSR) under Node.js. Since 1.5.0, these flags produce a bundle that, as far as I can tell, can never work because they now rely on the existence of browser DOM APIs that don't exist in Node.\r\n\r\nIf there is any way to use `--bundle-dependencies=all` successfully in `--prod` build with 1.5.0+, I'd love to know about it.\r\n\r\n### Versions\r\n```\r\nAngular CLI: 1.5.4\r\nNode: 6.11.0\r\nOS: win32 x64\r\nAngular: 5.0.2\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, platform-server, router\r\n\r\n@angular/cli: 1.5.4\r\n@angular-devkit/build-optimizer: 0.0.33\r\n@angular-devkit/core: 0.0.21\r\n@angular-devkit/schematics: 0.0.37\r\n@ngtools/json-schema: 1.1.0\r\n@ngtools/webpack: 1.8.4\r\n@schematics/angular: 0.1.7\r\ntypescript: 2.4.2\r\nwebpack: 3.8.1\r\n```\r\n\r\n### Repro steps\r\n\r\n* Clone the example repo at https://github.com/SteveSandersonMS/angular-bundledependencies-repro. This is the same as the universal-starter repo, except for [one commit](https://github.com/SteveSandersonMS/angular-bundledependencies-repro/commit/6104ae864b10e2a5d80c95ea836b596d0559c1f8) that gets as close as I can to a scenario where `--bundle-dependencies=all` could work (but still doesn't).\r\n* Run `npm install`\r\n* Observe that it works fine in a non-prod build by running `npm run build:ssr` then `npm run serve:ssr`. If you visit http://localhost:4000, you'll get both server and client rendering.\r\n* Observe that if you build in prod mode (run `npm run build:ssr:prod` then `npm run serve:ssr`), then it does **not** work - you'll get this error:\r\n\r\n```\r\nTypeError: StaticInjectorError[InjectionToken DocumentToken]: \r\n StaticInjectorError[InjectionToken DocumentToken]: \r\n Right-hand side of 'instanceof' is not an object\r\n at ke (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:724114)\r\n at xe (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:723991)\r\n at lr (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:746752)\r\n at _n.insertToken (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:767718)\r\n at C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:726646\r\n at Fe (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:726661)\r\n at I (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:721959)\r\n at Object.parse (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:766648)\r\n at Object.t.createDocument (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:1194422)\r\n at Object.t.createWindow (C:\\path\\angular-bundledependencies-repro\\dist\\server.js:4106:1194526)\r\n```\r\n\r\nIf you trace this into the `server.js` bundle code, what's happening is that it's testing whether `someValue instanceof HTMLElement` (though it's not obvious at first glance because everything is minified and renamed). That code would be OK in a browser, but it's an error in Node, because `HTMLElement` is `undefined`. So the generated bundle isn't going to work for SSR under Node.\r\n\r\n* If you want, verify that removing `--bundle-dependencies=all` from lines 22 and 23 in `package.json` is enough to make it work in both dev and prod builds. So the problem is the combination of `--prod` with `--bundle-dependencies=all` - you can use either on their own, but not both together.\r\n\r\n### Observed behavior\r\n\r\nFails with the `Right-hand side of 'instanceof' is not an object` error shown above.\r\n\r\n### Desired behavior\r\n\r\nSSR works as it did in the non-prod build.\r\n\r\n### Mention any other details that might be useful (optional)\r\n\r\nThe equivalent did work pre-1.5.0 (which was also Angular 4.x).\r\n\r\nThe reason I'm asking about this is because I'm building new Angular CLI-based ASP.NET templates that will be included in the .NET Core SDK and Visual Studio. We want the template to use `--bundle-dependencies=all` by default because then developers don't have to publish their `node_modules` to production, and attempting to publish 20,000+ files from `node_modules` is extremely time-consuming (and not always reliable) from VS. Plus it tends to hit Windows path-length limitations depending on the deployment target.","author":{"url":"https://github.com/SteveSandersonMS","@type":"Person","name":"SteveSandersonMS"},"datePublished":"2017-11-23T17:30:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":44},"url":"https://github.com/8616/angular-cli/issues/8616"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:465ad9ab-6502-2ed0-97c9-58315d1a690e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9326:32D418:1907617:23473ED:698226C2 |
| html-safe-nonce | 50901f66dbd7935c0f72b234b709cf1b29066b204982c8faaf2703c44e869146 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzI2OjMyRDQxODoxOTA3NjE3OjIzNDczRUQ6Njk4MjI2QzIiLCJ2aXNpdG9yX2lkIjoiMTYzMzgyNDA5ODI0NzM4NjgxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9b22370a70aafd7e128328040088554917b999e1d933709ba6b64459f405cb9d |
| hovercard-subject-tag | issue:276442960 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/8616/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4c5b13d725232d811464737c7f8da886e94bed4c84ac41249ba5ef6f34f5dc1/angular/angular-cli/issues/8616 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4c5b13d725232d811464737c7f8da886e94bed4c84ac41249ba5ef6f34f5dc1/angular/angular-cli/issues/8616 |
| og:image:alt | Prior to the 1.5.0 release, it was possible to pass --bundle-dependencies=all --prod to get an AoT compiled self-contained bundle that worked for server-side rendering (SSR) under Node.js. Since 1.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SteveSandersonMS |
| hostname | github.com |
| expected-hostname | github.com |
| None | f29b4256dc96a8de29f6e5fad4bf98fdbfc5cb1dbb313013053581f8470d8a21 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 61292800a4f1180f0b13782adc5da7267ec99b94 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width