[TIMOB-27478] Webpack: Use thread-loader in production builds
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | None |
| Status | Closed |
| Resolution | Won't Do |
| Resolution Date | 2020-01-24T00:10:24.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Tooling |
| Labels | n/a |
| Reporter | Jan Vennemann |
| Assignee | Jan Vennemann |
| Created | 2019-10-17T11:07:22.000+0000 |
| Updated | 2020-01-24T00:10:24.000+0000 |
Description
To speed up production builds we should include [thread-loader](https://github.com/webpack-contrib/thread-loader) before other expensive loaders, like babel-loader.
The thread-loader is currently having some issues with platform specific files which needs to be investigated. We override Webpack's default compiler input filesystem with [PlatformAwareFilesystem](https://github.com/appcelerator/titanium-webpack-devkit/blob/a6af9bea700d2aeaa776defcbea96fe573047060/packages/webpack-target-titanium/src/plugins/PlatformAwareFileSystemPlugin.js#L12) to easily switch out files based on the current platform. For example, a require to
@/components/Platform.vue uses @/components/Platform.ios.vue if available.
This works fine in other loaders because they use the internal compiler filesystem. However, therad-loader has no access to that in workers, so it resorts to Node's [fs](https://github.com/webpack-contrib/thread-loader/blob/488300f5ad86c2eb794848de4cbc71c0cc5637da/src/worker.js#L107) module.
There are other issues with with vue-loader and our custom titanium-vue-template-compiler as well. We need to specify our custom vue template compile function, which is not supported by thread loader. Since this will just result in a slight build time improvements i'll close this ticket for now. We can open it again should the need for thread-loader come up again.