При создании веб-пакета или запуске веб-сайта с веб-пакетом я получаю случайные ошибки о том, что они не являются функцией.Это происходит в разных модулях в разных точках глубоко вложенного стека вызовов с требуемыми разрешениями.
Я подробно погуглил эту ошибку и обнаружил, что она может быть вызвана множеством различных симптомов.Я перепробовал все из них, которые смог найти, и ни один из них не помог мне.
Я публикую это с решением, чтобы показать, что сработало для меня на случай, если у кого-то еще будет такая же проблема.
Вот соответствующая часть набора веб-пакетов:
/**
* @returns {import('webpack').RuleSetRule}
*/
module.exports = () => ({
test: /\.js$/,
exclude: /node_modules\/(?!(query-string|strict-uri-encode|modernizr|split-on-first)\/).*/,
use: {
loader: 'babel-loader',
options: {
presets: [
[ '@babel/preset-env', {
// - If useBuiltIns: 'usage' is specified in .babelrc then do not include @babel/polyfill in either webpack.config.js entry array
// nor source. Note, @babel/polyfill still needs to be installed.
// - If useBuiltIns: 'entry' is specified in .babelrc then include @babel/polyfill at the top of the entry point to your application
// via require or import
// - If useBuiltIns key is not specified or it is explicitly set with useBuiltIns: false in your .babelrc, add @babel/polyfill
// directly to the entry array in your webpack.config.js.
useBuiltIns: 'usage',
corejs: '2'
} ]
],
plugins: [
['@babel/plugin-transform-modules-commonjs', {
strictMode: false
}]
]
}
}
})
Приведенный выше загрузчик для babel выдает следующие ошибки:
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: __webpack_require__(...) is not a function
at Object.I8a+ (C:\TRAVLR\Repos\Travlr\Webs\WebApp\node_modules\css-loader\dist\cjs.js!C:\TRAVLR\Repos\Travlr\Webs\WebApp\node_modules\postcss-loader\src\index.js??ref--6-2!C:\TRAVLR\Repos\Travlr\Webs\WebApp\node_modules\sass-loader\lib\loader.js!C:\TRAVLR\Repos\Travlr\Library\UiKit\src\scss\app.scss:580:38)
ИЛИ
at eval (webpack:///./node_modules/core-js/modules/_classof.js?:4)
at Object../node_modules/core-js/modules/_classof.js (pkg.core-js.js:889)
at __webpack_require__ (runtime.client.js:782)
at fn (runtime.client.js:150)
at eval (webpack:///./node_modules/core-js/modules/es6.object.to-string.js?:3)
at Object../node_modules/core-js/modules/es6.object.to-string.js (pkg.core-js.js:2167)
at __webpack_require__ (runtime.client.js:782)
at fn (runtime.client.js:150)
at eval (webpack:///./node_modules/core-js/modules/es6.regexp.to-string.js?:11)
at Object../node_modules/core-js/modules/es6.regexp.to-string.js (pkg.core-js.js:2306)```