`TypeError: Cannot read properties of undefined (reading 'then')` when using ESM to export config
palapapa opened this issue · 2 comments
palapapa commented
Bug report
What is the current behavior?
Running npx webpack --config config/webpack.config.js
gives this error:
[webpack-cli] TypeError: Cannot read properties of undefined (reading 'then')
at WebpackCLI.isPromise (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:27:29)
at loadConfigByPath (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:1354:26)
at async Promise.all (index 0)
at async WebpackCLI.loadConfig (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:1375:35)
at async WebpackCLI.createCompiler (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:1643:22)
at async WebpackCLI.runWebpack (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:1738:20)
at async Command.<anonymous> (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:885:21)
at async Command.parseAsync (C:\JavaScript\wiki-translator\node_modules\webpack-cli\node_modules\commander\lib\command.js:935:5)
at async Command.<anonymous> (C:\JavaScript\wiki-translator\node_modules\webpack-cli\lib\webpack-cli.js:1292:13)
at async Command.parseAsync (C:\JavaScript\wiki-translator\node_modules\webpack-cli\node_modules\commander\lib\command.js:935:5)
webpack.config.js
:
export let config =
{
"entry": "dist/popup.js"
}
dist/popup.js
:
"use strict";
console.log("Hello World!");
package.json
:
{
"name": "wiki-translator",
"version": "0.1.0",
"description": "A Chrome extension that automatically detects the longest language of a Wikipedia atricle and translates it.",
"private": true,
"scripts":
{
"watch": "tsc-watch --project config/tsconfig.json --onSuccess \"webpack --mode=development --config config/webpack.config.js\"",
"build": "tsc --project config/tsconfig.json; webpack --mode=production --config config/webpack.config.js"
},
"devDependencies":
{
"@types/chrome": "^0.0.181",
"copy-webpack-plugin": "^10.2.4",
"css-loader": "^6.7.3",
"file-loader": "^6.2.0",
"mini-css-extract-plugin": "^2.7.5",
"prettier": "^2.8.4",
"ts-loader": "^9.2.8",
"tsc-watch": "^6.0.0",
"typescript": "^4.6.3",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1",
"webpack-merge": "^5.8.0"
},
"type": "module"
}
If the current behavior is a bug, please provide the steps to reproduce.
Run npx webpack --config config/webpack.config.js
in this repo:
wiki-translator.zip
What is the expected behavior?
Webpack should run successfully.
Other relevant information:
webpack version: 5.76.2
webpack-cli version: 5.0.1
Node.js version: 18.15.0
Operating System: Windows 10 10.0.19044
alexander-akait commented
We support only default
export, please use:
export default
{
"entry": "dist/popup.js"
}
alexander-akait commented
We don't know what is config
named export so we don't support named exports