brix / crypto-js

JavaScript library of crypto standards.
Other
15.87k stars 2.39k forks source link

Production build crashes on Next v14.0.2. #477

Open zirlman opened 1 year ago

zirlman commented 1 year ago

I'm having issues with this library and Nextjs >= 14.0.2.

I've elaborated the issue on NextJS in detail Issue: https://github.com/vercel/next.js/issues/58623

TLDR; It looks like the module Math.sqrt is undefinedin your libary when ran on client-side

eyyazubi commented 1 year ago

im have the same error:

13-2f45628bbf53fb8d.js:5 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'sqrt')

function() { function e(e) { return (e - (0 | e)) * 4294967296 | 0 } for (var t = 2, r = 0; r < 64; ) (function(e) { for (var t = Math.sqrt(e), r = 2; r <= t; r++) <--- here if (!(e % r)) return !1; return !0 } )(t) && (r < 8 && (c[r] = e(Math.pow(t, .5))), l[r] = e(Math.pow(t, 1 / 3)), r++), t++ }(),

dez1729 commented 1 year ago

This also breaks pdfkit when trying to generate a pdf in build. Rolling nextjs back to 14.0.1 seem to fix the problem.

ktpm489 commented 11 months ago

Use transpilePackages: [''crypto-js'] in next.config.js file. I build project success in product mode with next js 14.3 .

ktpm489 commented 11 months ago
Screen Shot 2023-12-01 at 11 25 15 AM

Sample

JcobCN commented 3 days ago

Screen Shot 2023-12-01 at 11 25 15 AM Sample

it works.