我在調試我的 preact 項目時遇到了一些問題,大多數 js 錯誤都沒有出現在控制臺中。例如,我將這段代碼添加到我的組件中:<button onClick={() => { const someVar = someUnknownVariable;}}> fire error</button>當我點擊按鈕時,沒有出現錯誤,說 someUnknownVariable is not defined,其他 js 錯誤也沒有出現。這是我的 preact.config.js 文件:import compose from 'lodash.compose';export default (config, env, helpers) => { return compose(addEmotionPlugin, configRules)(config, env, helpers);};function addEmotionPlugin(config) { let babel = config.module.rules.filter(loader => loader.loader === 'babel-loader')[0] .options; babel.plugins.push([ 'emotion', { hoist: true, sourceMap: false, autoLabel: true, labelFormat: '[local]', extractStatic: false, outputDir: '', }, ]); return config;}function configRules(config, env) { if (env.isProd) { config.devtool = 'source-map'; config.output.filename = '[name].js'; config.output.publicPath = process.env.NODE_ASSETS || '/'; } return config;}在我的 index.js 文件中,我在開頭有這段代碼。if (process.env.NODE_ENV==='development') { require("preact/debug");}這是在我升級 preact 版本后發生的,請提供任何幫助。
升級 Preact 版本后調試無法正常工作
倚天杖
2022-11-27 16:19:25