Description
First of all, many many many thanks for this amazing template. It has helped me a lot to get started.
In this bug report, I wanted to notify you of a problem I encountered, which is caused by the usage of node-polyfill-webpack-plugin. The problem is not limited to this template but happens in every electron project that maps to browserified modules (whether they do it manually in the webpack config or via node-polyfill-webpack-plugin).
You're most likely aware of this, but I'd like to summarize for others: in essence, node-polyfill-webpack-plugin maps node modules (which aren't available in the browser) to their browserified module. For example, if the module 'path' is required by some dependency, the module 'path-browserify' will be provided instead. For most browserified modules, I haven't encountered a problem of performing such mapping. However, for 'path', there is an issue. The module 'path-browserifiy' is not a one on one copy of node's 'path' module. Path-browserify only supports posix paths and does not support win32 paths. This causes errors when, for example, using the function path.resolve() (as well in my own code as in code of modules that my app uses). In path-browserify, path.resolve() only considers a path starting with "/" as an absolute path. When provided a win32 path like "C:\Users\johndoe\Music" it doesn't see it as an absolute path, so to make it an absolute path, it adds the execution directory of the application to it. The path then becomes "C:\Program Files (x86)\MyApp/C:\Users\johndoe\Music". This causes "path not found" errors of which the root cause is very hard to link to path-browserify.
The way I resolved this was to not use browserified modules at all and map to the modules available in the Electron envirmonent instead (which are full blown node modules). I did it by providing the following in angular.webpack.js:
module.exports = {
externals: {
electron: 'commonjs electron',
ipc: 'commonjs ipc',
'ipc-renderer': 'commonjs ipc-renderer',
remote: 'commonjs remote',
fs: 'commonjs fs',
assert: 'commonjs assert',
crypto: 'commonjs crypto',
fs: 'commonjs fs',
http: 'commonjs http',
https: 'commonjs https',
os: 'commonjs os',
path: 'commonjs path',
readline: 'commonjs readline',
stream: 'commonjs stream',
timers: 'commonjs timers',
util: 'commonjs util',
constants: 'commonjs constants',
},
};
I hope this helps someone. I realize though that my webpack and web technologies knowlegde still needs a lot of refining, so I'm very open for more input or feedback on this solution.