Webpack Encore Jquery 最大调用堆栈大小

Webpack Encore Jquery Maximum call stack size

我在升级到 Symfony 4.1 并切换到 Encore 后遇到问题。

Uncaught RangeError: Maximum call stack size exceeded
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)
at _typeof (bundle.js?v=1.6565:3454)

我试图寻找问题的根源,只有在使用 jquery 从 compose.js 中删除所有内容(并包含)后,错误才消失。但是我当然需要 jquery...

一旦我“从 'jquery' 导入 jQuery”或 'Encore.autoProvidejQuery()',就会发生错误

Webpack.config.js:

const Encore = require('@symfony/webpack-encore');

let publicPath = '/build/';
if (Encore.isProduction()) { // yarn run encore production
    publicPath = '/****_symfony/build/';
}

Encore
    .setOutputPath('public/build/')
    .setPublicPath(publicPath)
    .setManifestKeyPrefix('build/')
    .cleanupOutputBeforeBuild()
    .enableSourceMaps(!Encore.isProduction())
    .addEntry('bundle', './assets/compose.js')
    .enableStylusLoader()
    .enableLessLoader()
    .enableSassLoader()
;

const config = Encore.getWebpackConfig();
for (const rule of config.module.rules) {
    if (rule.hasOwnProperty('use')) {
        for (loader of rule.use) {
            if (loader.loader === 'babel-loader') {
                delete rule.exclude;
            }
        }
    }
}
module.exports = config;

嗯,如果您遇到同样的问题,可能是因为您忘记从 package.json 中删除旧包。

Babel、Gulp 等可能是问题所在。它现在正常工作。