Title: Support for Electron and Externals · Issue #4227 · angular/angular-cli · GitHub
Open Graph Title: Support for Electron and Externals · Issue #4227 · angular/angular-cli
X Title: Support for Electron and Externals · Issue #4227 · angular/angular-cli
Description: Please provide us with the following information: OS? All OSes Versions. 1.0.0-beta.26 Repro steps. clone my electron starter project git clone https://github.com/gregvis/angularcli-electron.git cd into it npm i npm start error in consol...
Open Graph Description: Please provide us with the following information: OS? All OSes Versions. 1.0.0-beta.26 Repro steps. clone my electron starter project git clone https://github.com/gregvis/angularcli-electron.git cd...
X Description: Please provide us with the following information: OS? All OSes Versions. 1.0.0-beta.26 Repro steps. clone my electron starter project git clone https://github.com/gregvis/angularcli-electron.git cd...
Opengraph URL: https://github.com/angular/angular-cli/issues/4227
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support for Electron and Externals","articleBody":"\u003e Please provide us with the following information:\r\n\u003e ---------------------------------------------------------------\r\n\r\n### OS?\r\n\u003e All OSes\r\n\r\n\r\n### Versions.\r\n\u003e1.0.0-beta.26\r\n\r\n\r\n### Repro steps.\r\n\u003e clone my electron starter project\r\n\u003e git clone https://github.com/gregvis/angularcli-electron.git\r\n\u003e cd into it\r\n\u003e npm i\r\n\u003e npm start\r\n\u003e error in console \"Uncaught TypeError: fs.existsSync is not a function\"\r\n\r\n\r\n### The log given by the failure.\r\n\u003e \"Uncaught TypeError: fs.existsSync is not a function\"\r\n\r\n\r\n### Mention any other details that might be useful.\r\n\r\n\u003e In app.component.ts, i have this code:\r\n`import { Component } from '@angular/core';\r\nconst remote = require('electron').remote;\r\n@Component({\r\n selector: 'app-root',\r\n templateUrl: './app.component.html',\r\n styleUrls: ['./app.component.css']\r\n})\r\nexport class AppComponent {\r\n title = 'app works!';\r\n constructor() {\r\n remote.dialog.showOpenDialog({ title: 'Electron Works!' });\r\n }\r\n}`\r\n\r\nThe remote.dialog.showOpenDialog does a call to a nodejs fs function. In order to fix this, I need the require('electron') to be ignored by webpack. \r\n\r\nThere are 2 ways to do this. In \"webpack-build-common\", \r\n1.\r\n`target: 'electron-renderer'`\r\nThis basically adds a bunch of 'externals' that webpack ignores for packing. You can see the code here:\r\nhttps://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L70-L185\r\n\r\nThis does fix the issue, however, there are cases where I would like to be able to add other externals, such as the npm package \"drivelist\" which uses a \"child_process\" to get a list of drives connected to the system. It doesn't work properly if it is bundled by webpack. \r\n\r\nSo in order for me to use both electron AND drivelist, i added the following to \"webpack-build-common\"\r\n\r\n2. \r\n`externals: {\r\n 'electron' : 'commonjs electron',\r\n 'drivelist' : 'commonjs ' + nodeModules + '/drivelist'\r\n }`\r\n\r\n\r\nSo ideally, I need a way to add target and/or externals to the webpack build. ","author":{"url":"https://github.com/gregvis","@type":"Person","name":"gregvis"},"datePublished":"2017-01-25T16:26:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":22},"url":"https://github.com/4227/angular-cli/issues/4227"}
| 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:2f56497c-097e-5cff-b929-954630a13458 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 94EE:60C4F:24AF95:323344:698EF098 |
| html-safe-nonce | 9f47bea9fadc21ed005f22fa071e13af91bb264de2454081ece6bb4abd551a68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NEVFOjYwQzRGOjI0QUY5NTozMjMzNDQ6Njk4RUYwOTgiLCJ2aXNpdG9yX2lkIjoiNTI1ODg0NTMzNDU2Njk1NDQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | db3d99d4839901ed78bb3c888ef94745c2dc3c509d40cccef5e20d0137fde234 |
| hovercard-subject-tag | issue:203150815 |
| 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/4227/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dca15c602ef115b53552cdd2628eff8ce4650fa5fba598b19c8282ac0e8a02b3/angular/angular-cli/issues/4227 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dca15c602ef115b53552cdd2628eff8ce4650fa5fba598b19c8282ac0e8a02b3/angular/angular-cli/issues/4227 |
| og:image:alt | Please provide us with the following information: OS? All OSes Versions. 1.0.0-beta.26 Repro steps. clone my electron starter project git clone https://github.com/gregvis/angularcli-electron.git cd... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gregvis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f7bf82d8907f81525d95af82e60354b419d083df9534c8631d06bb9c0bf07ac |
| 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 | bc36007ff5167349dcfee9a75c7fa7184ab272c4 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width