MetaMask / module-lint

Analyzes one or more repos for divergence from a template repo.
1 stars 3 forks source link

Use module/moduleResolution of 'nodenext' #92

Closed mcmire closed 1 month ago

mcmire commented 1 month ago

@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.

socket-security[bot] commented 1 month ago

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/superstruct@3.0.0 None 0 436 kB metamaskbot

View full report↗︎