Commit 054a091
committed
fix(build): use non-destructured require for zod + @strapi/utils
Prevents the same runtime crash that hit magic-link:
Cannot read properties of undefined (reading 'string')
at z.string() during plugin load
Pack-up's rollup-commonjs rewrites `const { z } = require('zod')`
into `_interopDefault(...).default.z`. For dual ESM/CJS packages
like zod 3.25+ and @strapi/utils, that `.default` branch does
NOT expose the named members, so `z` resolves to undefined and
every schema build crashes at plugin boot.
Replaced destructured requires with direct property access:
const { z } = require('zod') → const z = require('zod')
const { errors: strapiErrors } = require('@strapi/utils')
→ const strapiErrors = require('@strapi/utils').errors
Property access after a plain require() is not touched by rollup-
commonjs, so the runtime value matches source semantics.1 parent 9361f24 commit 054a091
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
327 | 334 | | |
328 | 335 | | |
329 | 336 | | |
330 | | - | |
| 337 | + | |
331 | 338 | | |
332 | 339 | | |
333 | 340 | | |
| |||
0 commit comments