Skip to content

Commit 1402eef

Browse files
committed
fix(build): use non-destructured require for @strapi/utils
Prevents the same runtime crash pattern that hit magic-link: pack-up's rollup-commonjs rewrites `const { errors } = require('@strapi/utils')` into `_interopDefault(...).default.errors`. For the dual ESM/CJS @strapi/utils package, `.default` does not expose `errors`, so the destructured value resolves to undefined at runtime and any call through `errors.XxxError` crashes on plugin boot. Direct property access after a plain require() is not rewritten by rollup-commonjs: const { errors } = require('@strapi/utils') -> const errors = require('@strapi/utils').errors
1 parent 2100783 commit 1402eef

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

server/src/policies/session-required.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
*/
1717

1818
const SESSION_UID = 'plugin::magic-sessionmanager.session';
19-
const { errors } = require('@strapi/utils');
19+
// Avoid destructuring `@strapi/utils` at require time — pack-up's
20+
// rollup-commonjs plugin rewrites the import in a way that resolves to
21+
// undefined at runtime for dual ESM/CJS packages. Direct property access
22+
// after a plain require() sidesteps the rewrite.
23+
const errors = require('@strapi/utils').errors;
2024
const { resolveUserDocumentId } = require('../utils/resolve-user');
2125
const { getPluginSettings } = require('../utils/settings-loader');
2226
const { extractBearerToken } = require('../utils/extract-token');

0 commit comments

Comments
 (0)