-
-
Notifications
You must be signed in to change notification settings - Fork 761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use with NextJS - Identifier 'e' has already been declared
#1344
Comments
Hi! I encountered the same issue and found a workaround by modifying the webpack configuration. Here’s an example of how you can implement it in your import TerserPlugin from "terser-webpack-plugin";
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.optimization.minimizer = [
new TerserPlugin({
exclude: /node_modules\/jimp/,
terserOptions: {
mangle: true,
compress: {
drop_console: true,
},
},
}),
];
return config;
},
};
export default nextConfig; Please note that this is a temporary workaround, and I believe there is likely a more optimal solution. I hope this helps, and I’m hoping that someone will come up with a better idea as well. |
@kwerdna19 I am encountering the exact same issue! hope we can bring this to their attention asap! |
I'm also getting this exact same issue from my built files producing the same error let emojiRegex,e,e,e,e,e,e,e,e,e If I set As I understand it from version 15+ of Next.js there will be no way to turn off the use of the SWC compiler so I'm hoping we can find a fix. |
The Next.js build process uses SWC to minify and optimize code for production. However, the JIMP library appears not to be currently compatible with SWC's minification process, causing a naming conflict that results in a syntax error (`Uncaught SyntaxError: Identifier 'e' has already been declared`). This issue only occurs in built files. To resolve the issue, SWC minification has been temporarily disabled, forcing Next.js to fall back to using the slower Terser. This allows the code to be compiled correctly and served without errors. This is a temporary fix and will be reverted in the future. Link to the related GitHub issue: jimp-dev/jimp#1344
Could it be that #1355 is talking about the same issue behind the screens? https://rollupjs.org/troubleshooting/#avoiding-eval is saying things like: A minifier can't mangle variable names in polluted code, because it can't guarantee that the code to be evaluated doesn't reference those variable names. |
Expected Behavior
Hoping to use Jimp on the with NextJS through client components
Current Behavior
next dev
next build && next start
, Jimp causes the JS bundle to break.Failure Information (for bugs)
The page will load with a console error:
The referenced file and line lead to the following minified code:
The syntax error (red underline) begins happening at the
e,e,e,e,e,e,e,e,e
Occasionally (if spamming refresh), I will also see the generic NextJS error page (
Application error: a client-side exception has occurred (see the browser console for more information).
) with console errors indicating:Steps to Reproduce
Minimal repro repo: https://github.com/kwerdna19/next-jimp-test
Steps:
Then navigate to http://localhost:3000/
Context
Node: v20.16
Any ideas or help are appreciated.
Thanks
The text was updated successfully, but these errors were encountered: