Releases: iambumblehead/esmock
mock Array-type default export
- mock Array-type default export, thanks @altearius
- support json import mocking, only working at node v21, see
catch yarn PnP exception @koshic
resolve critical error
mainly this issue resolves a critical error reported here #260
- add node 21 to test pipeline
- use latest node 18 at test pipeline
- update resolver again resolves this issue.
increment resolver
update resolver to latest version, resolves a resolution error that seems to have been introduced by a previous update from the past week.
support yarn PnP @koshic
call resolver with builtin moduleIds
This change affects custom resolvers, which are supported from v2.5.2. Per the spec, resolvers will be called with the builtin moduleIds, such as "node:path" and "fs"
- remove condition to not-call resolver with builtin moduleId
add support for custom resolver
This release adds support for custom using a custom resolver. Specifically, a yarn PnP resolver can be passed to esmock, so that yarn PnP moduleIds can be resolved.
- update resolver to latest version, slightly faster with fewer loops
- add support for resolver configuration option
const modulePnP = await esmock('../src/parent.js', {
'../src/PnPchild.js' : () => ['a', 'b']
}, null, {
resolver: pnpapi.resolveRequest
})
lookup export type based on package.json type
This release updates the resolver to improve module resolution. See resolvewithplus tags v2.0.6 and v2.0.7.
Essentially, the resolver is updated to lookup the export type based on package.json type. For example, if package.json type is "module", the "import" definition is resolved, else if package.json type is undefined or "commonjs", the "require" definition is resolved. Previous versions of esmock usually reslved commonjs/require when those were defined and because most packages are published as commonjs, the issues resolved at this release likely did not affect anyone,
- resolve "exports" before "main". The spec says: the "exports" field takes precedence over "main" in supported versions of Node.js. The updated resolver correctly returns "main" before "exports" (older resolver did not).
- use package.json "type" to return "import" or "require". The older resolver did not read package.json type and returned incorrect "require" values for some packages. For example, if this inferno package where changed to use type "module", the older resolver would return "index.js" rather than "index.esm.js"
improve ts resolution
resolve existing ".ts" files, rather than ".js" files, when typescript is detected, thanks @tpluscode
use initialize loader hook
esmock
is updated to use the new "initialize" node loader hook https://nodejs.org/api/esm.html#initialize and, essentially, esmock
no longer requires --loader=esmock when used with current releases of node