-
-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Esbuild in webpack plugin #2127
Comments
esbuild doesn't support decorator, so this can't be a drop'in replacement for every user. evanw/esbuild#509 But for people searched here, you can easily do so to adopt esbuild, if you are not using Decorator Metadata:
webpack.rules.js {
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: 'esbuild-loader',
options: {
loader: 'tsx',
tsconfigRaw: require('./tsconfig.esbuild.json'),
target: 'es2015',
},
},
}, webpack.plugins.js const { ESBuildPlugin } = require('esbuild-loader');
module.exports = [
new ESBuildPlugin(), webpack.main.config.js const webpack = require('webpack');
const { ESBuildPlugin } = require('esbuild-loader');
const { webpackAlias } = require('./webpack.alias');
module.exports = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: './src/main/main.ts',
// Put your normal webpack config below here
module: {
rules: require('./webpack.rules'),
},
resolve: {
alias: webpackAlias,
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
},
plugins: [new ESBuildPlugin()],
}; |
And this might be a workaround evanw/esbuild#257 (comment) |
I'm not inclined to add yet another template just for esbuild + webpack support. It's possible to create a third party template with this configuration if you wish to make it. |
@linonetwo hot reload is not working. when reloading getting blank white screen. any ideas ? I used the same configuration. as you mentioned above. in main.ts I am using mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY); is this a reason ? but for first time while starting app everything rendered correctly. while reloading screen gets white. |
I use |
Thank !! @linonetwo I have customized header menu options, so In the reload action I am using BrowserWindow.getFocusedWindow()?.webContents.reload() . while doing this getting blank white screen. previously it was worked. |
I'm doing the exactly same thing, https://github.com/tiddly-gittly/TidGi-Desktop/blob/feat/execute-graph/src/services/view/index.ts#L195 but works very fine. And MAIN_WINDOW_WEBPACK_ENTRY |
Thanks for the reply @linonetwo, I tried everything, and when I reloaded all the files in the source tab, and hangs showing only white screen. is this because of large bundle ? .webpack folder size is 136 MB |
Preflight Checklist
Problem Description
ESBuild is super fast, and is becoming popular ( See https://2020.stateofjs.com/en-US/technologies/build-tools/ )
Hope electron forge webpack can utilize esbuild to speed up.
Proposed Solution
Replace ts-loader with esbuild directly, see link for details:
esbuild:https://esbuild.github.io/
esbuild-loader:https://github.com/privatenumber/esbuild-loader
Alternatives Considered
Maybe an esbuild plugin? But I think this is not necessary, because esbuild can be used in webpack.
Additional Information
An expert in ByteDance uses esbuild to speed up his building up to 144% ! (From 71s to 29s, with 0.05MLoc )
The text was updated successfully, but these errors were encountered: