Skip to content
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

fix: add v12 support #1083

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ test/**/main.js
test/**/cliEntry.js
test/**/foo.js
test/binCases/config-location/webpack-babel-config/bin/es6.js
packages/utils/validate-identifier.ts
packages/utils/validate-identifier.ts
bin/utils/convert-argv.js
19 changes: 17 additions & 2 deletions bin/utils/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,29 @@ module.exports = function(...args) {

const requireConfig = function requireConfig(configPath) {
let options = (function WEBPACK_OPTIONS() {
const resolvedPath = path.resolve(process.cwd(), configPath);
if (argv.configRegister && argv.configRegister.length) {
module.paths.unshift(path.resolve(process.cwd(), "node_modules"), process.cwd());
argv.configRegister.forEach(dep => {
require(dep);
});
return require(path.resolve(process.cwd(), configPath));
return require(resolvedPath);
} else {
return require(path.resolve(process.cwd(), configPath));
try {
return require(resolvedPath);
} catch (err) {
if (err.stack.indexOf("ERR_REQUIRE_ESM") >= 0) {
if (!process.execArgv.includes("--experimental-modules")) {
// TODO: remove in October
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to Future!? 😅

console.error(
'\u001b[1m\u001b[31m You need to supply the --experimental-modules flag in order to run webpack with node v12\u001b[39m\u001b[22m'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using chalk here would make it more readable.

);
process.exit(0);
}
return import(resolvedPath);
Copy link
Contributor

@ematipico ematipico Sep 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import statement should be moved

}
return require(resolvedPath);
}
}
})();
options = prepareOptions(options, argv);
Expand Down