ericclemmons / start-server-webpack-plugin

Automatically start your server once Webpack's build completes.
MIT License
158 stars 26 forks source link

Please upgrade to Webpack 5 #40

Open budarin opened 4 years ago

budarin commented 4 years ago

the current version is not compatible with Webpack 5

daihaoxin commented 4 years ago

In Webpack5, Use the following code to replace lines 119 and 120 of the project source file and recompile,

this._entryPoint = `${compilation.options.output.path}/${name}`;
douglasgc commented 3 years ago

I published a new package with the name "start-server-nestjs-webpack-plugin" where this problem has been fixed. in case someone has the same need.

igotfr commented 3 years ago

start-server-nestjs-webpack-plugin

please, I install your package: npm i -D start-server-nestjs-webpack-plugin and replace the third line of webpack-hmr.config.js but the problem persists

const StartServerPlugin = require("start-server-nestjs-webpack-plugin");

douglasgc commented 3 years ago

sends me his entire "webpack-hmr.config.js" so i can understand

igotfr commented 3 years ago

sends me his entire "webpack-hmr.config.js" so i can understand


const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const StartServerPlugin = require("start-server-nestjs-webpack-plugin");
//const StartServerPlugin = require('start-server-webpack-plugin');

module.exports = function(options) { return { ...options, entry: ['webpack/hot/poll?100', options.entry], watch: true, externals: [ nodeExternals({ allowlist: ['webpack/hot/poll?100'], }), ], plugins: [ ...options.plugins, new webpack.HotModuleReplacementPlugin(), new webpack.WatchIgnorePlugin([/.js$/, /.d.ts$/]), new StartServerPlugin({ name: options.output.filename }), ], }; };

atassis commented 3 years ago

@douglasgc I have created strongly typed (typescript) repo with the fix provided, also cleaned the code so it is a bit more readable. Also it is quite disguising having a nestjs in name, so I changed a name to shorter and closer to behavior one- run-script-webpack-plugin. The GH repo is located here

Pilo3369 commented 3 years ago

Hi, I have followed all the change but still not working for me it's saying that:

Error The 'compilation' argument must be an instance of Compilation

(node:2593) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback. (Use node --trace-deprecation ... to show where the warning was created) node --trace-deprecation ...

Did I fail something or someone else have the same problem?

atassis commented 3 years ago

@Pilo3369 there are no changes for more than a year. I advise you to use my fork of current repo (link above)

Pilo3369 commented 3 years ago

Hi thanks for the answer but I'm using your fork and I have this trouble with your fork :)

Flo-D commented 3 years ago

@atassis I got the same issue as @Pilo3369 with your fork. The error seems to have been introduced with Webpack v5.10.0, it doesn't occur with v5.9.0.

Unfortunately, even if it compiles successfully with v5.9.0, I got the following error on file change:

/usr/src/app/node_modules/webpack/lib/logging/Logger.js:123
    throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
    ^

Error: No such label 'emitAssets' for WebpackLogger.timeEnd()
    at WebpackLogger.timeEnd (/usr/src/app/node_modules/webpack/lib/logging/Logger.js:123:10)
    at /usr/src/app/node_modules/webpack/lib/Watching.js:80:15
    at /usr/src/app/node_modules/webpack/lib/Compiler.js:757:14
    at eval (eval at create (/usr/src/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
    at /usr/src/app/node_modules/run-script-webpack-plugin/dist/index.js:64:17
    at EventEmitter.<anonymous> (/usr/src/app/node_modules/run-script-webpack-plugin/dist/index.js:108:13)
    at EventEmitter.emit (node:events:390:22)
    at online (node:internal/cluster/master:271:11)
    at Worker.onmessage (node:internal/cluster/master:265:5)
    at ChildProcess.onInternalMessage (node:internal/cluster/utils:48:5)
error Command failed with exit code 1.
atassis commented 3 years ago

@Pilo3369 @Flo-D U would better create an issue then lol=) I'll try to investigate it in next few days, but an issue and example will speed up my work in a matter of times

atassis commented 3 years ago

@Flo-D can't get an error in this version webpack or even higher, so I definitely need an issue in my repo

bkniffler commented 3 years ago

@atassis Unfortunately you've been using the cluster (master) branch of this repository. If installed with beta tag, start-server-webpack-plugin uses child_process instead. The issue with clustering is, we can't use clusters within our own package, because the node process already is a child cluster.

bkniffler commented 3 years ago

Here is the issue: https://github.com/ericclemmons/start-server-webpack-plugin/issues/12

atassis commented 3 years ago

@bkniffler I'll look that through, but still wanna admit, that you can create an issue if something was done wrong in my repo

bkniffler commented 3 years ago

@atassis I've created a PR!

atassis commented 3 years ago

Ok, thats kinda need some cleaning, but still nice I'll fix and merge this in next few days

Pilo3369 commented 3 years ago

Thanks, @atassis looks like it's work at least I don't have the same issue but don't know from where it's come so I write it here for now: Error: [HMR] Hot Module Replacement is disabled. An idea?