Skip to main content
PESDK/Web

Webpack - Uncaught ReferenceError x is not defined

The Uncaught ReferenceError: x is not defined error message will appear if the optimization.innerGraph option is enabled during the production build. The inner graph analysis of the Webpack build system will break the namespace imports inside the photoeditorsdk package which causes the error.

Disabling the optimization option#

We found that disabling the optimization.innerGraph option is the best way to prevent this issue.

webpack.config.js
const path = require('path');
module.exports = () => {
return {
mode: 'production',
entry: './src/main.js',
devtool: 'source-map',
+ optimization: {
+ innerGraph: false,
+ },
output: {
path: path.resolve('src/libs/'),
filename: '[name].js',
publicPath: 'src/libs/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
};
};