@metamask/utils ships with Node-specific functions, but in order to use them you have to import them a special way. Instead of saying
import { ... } from '@metamask/utils';
you have to say
import { ... } from '@metamask/utils/node';
However, this syntax only works if TypeScript is configured to use a module and moduleResolution option of nodenext (or node16), because then TypeScript will consult the exports field of @metamask/utils to know how to resolve @metamask/utils/node (which it does not do with the current value for this option).
module-lint wasn't using this TypeScript configuration option; it used a hack to manually resolve @metamask/utils/node to the right place. This hack will no longer work in newer versions of @metamask/utils, and in order to make this work we now have to use the aforementioned TypeScript configuration option.
At the same time, the superstruct package will not compile when using this configuration option, so to fix this, we also switch to our fork of superstruct, which does work.
@metamask/utils
ships with Node-specific functions, but in order to use them you have to import them a special way. Instead of sayingyou have to say
However, this syntax only works if TypeScript is configured to use a
module
andmoduleResolution
option ofnodenext
(ornode16
), because then TypeScript will consult theexports
field of@metamask/utils
to know how to resolve@metamask/utils/node
(which it does not do with the current value for this option).module-lint
wasn't using this TypeScript configuration option; it used a hack to manually resolve@metamask/utils/node
to the right place. This hack will no longer work in newer versions of@metamask/utils
, and in order to make this work we now have to use the aforementioned TypeScript configuration option.At the same time, the
superstruct
package will not compile when using this configuration option, so to fix this, we also switch to our fork ofsuperstruct
, which does work.