webpack-encore
webpack-encore copied to clipboard
Fix error with eslint due to variable initialization before checking, eslint was set
In some projects, with symfony 6 with encore used, to work with sass+vue, without external eslint configuration, there may be error while building final dist/build files. The reason was, it could not init eslint, even it was disabled in webpack configuration (or more precisly: not enabled). Webpack-encore still wanted to run it, before checking if "useEslintPlugin" was set.
To fix this, I moved variable initialization to the block, after checking this variable, because it is used only inside if-block anyway. So there is no need to init these before.
Here is my compare: https://github.com/symfony/webpack-encore/commit/bc34f910dfa189016a6f7563927ea752479c0695
Hi there!
What is the exact error that you get when building for production? And was it necessary to move all of those require
statements? Or is there just 1 specifically that fixes the problem.
Your situation makes sense... but I am having a hard time seeing why any of those require
statements would cause a problem. But seeing the error might help clarify :).
Cheers!
The same here. With fix https://github.com/symfony/webpack-encore/commit/bc34f910dfa189016a6f7563927ea752479c0695 from @wesoledi everything works. Before fix I got errors:
yarn run v1.22.17
$ /usr/home/account/domains/domain.com/node_modules/.bin/encore dev
Running webpack ...
events.js:377
throw er; // Unhandled 'error' event
^
Error: listen EPERM: operation not permitted 0.0.0.0:20868
at Server.setupListenHandle [as _listen2] (net.js:1314:21)
at listenInCluster (net.js:1379:12)
at Server.listen (net.js:1465:7)
at Object.<anonymous> (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/worker.js:68:8)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1358:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EPERM',
errno: -1,
syscall: 'listen',
address: '0.0.0.0',
port: 20868
}
[webpack-cli] Failed to load '/usr/home/account/domains/domain.com/webpack.config.js' config
[webpack-cli] Error: Timed out waiting for sync-rpc server to start (it should respond with "pong" when sent "ping"):
events.js:377
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:20868
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
Emitted 'error' event on Socket instance at:
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 20868
}
at waitForAlive (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:85:11)
at start (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:41:3)
at sendMessage (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:133:17)
at createClient (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:173:27)
at Object.<anonymous> (/usr/home/account/domains/domain.com/node_modules/@symfony/webpack-encore/lib/plugins/eslint.js:13:32)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
error Command failed with exit code 2.
Yes :) yes, it was it: sync-rpc error. Thx @lu43n.
Interesting, maybe we can reconsider solutions described in https://github.com/symfony/webpack-encore/pull/985#issuecomment-848018655...
But for now, can someone of you can open a PR for https://github.com/symfony/webpack-encore/commit/bc34f910dfa189016a6f7563927ea752479c0695 ? Thanks
created
Thanks!