We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 53bb4d7 commit bb4a5d9Copy full SHA for bb4a5d9
bin/webpack-dev-server.js
@@ -85,8 +85,18 @@ const runCli = (cli) => {
85
const pkgPath = require.resolve(`${cli.package}/package.json`);
86
// eslint-disable-next-line import/no-dynamic-require
87
const pkg = require(pkgPath);
88
- // eslint-disable-next-line import/no-dynamic-require
89
- require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
+
+ if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
90
+ import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
91
+ (error) => {
92
+ console.error(error);
93
+ process.exitCode = 1;
94
+ }
95
+ );
96
+ } else {
97
+ // eslint-disable-next-line import/no-dynamic-require
98
+ require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
99
100
};
101
102
/**
0 commit comments