Skip to content

Releases: iambumblehead/esmock

mock Array-type default export

04 Nov 02:27
6f2a207
Compare
Choose a tag to compare

catch yarn PnP exception @koshic

23 Oct 16:54
44b1420
Compare
Choose a tag to compare

resolve critical error

20 Oct 18:28
Compare
Choose a tag to compare

mainly this issue resolves a critical error reported here #260

increment resolver

15 Oct 15:44
7466344
Compare
Choose a tag to compare

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

14 Oct 23:54
af69e1f
Compare
Choose a tag to compare

call resolver with builtin moduleIds

13 Oct 19:16
7f03aea
Compare
Choose a tag to compare

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"

add support for custom resolver

13 Oct 18:46
d3ca335
Compare
Choose a tag to compare

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.

const modulePnP = await esmock('../src/parent.js', {
  '../src/PnPchild.js' : () => ['a', 'b']
}, null, {
  resolver: pnpapi.resolveRequest
})

lookup export type based on package.json type

08 Oct 17:40
647c425
Compare
Choose a tag to compare

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

13 Sep 20:11
0b8888d
Compare
Choose a tag to compare

resolve existing ".ts" files, rather than ".js" files, when typescript is detected, thanks @tpluscode

use initialize loader hook

11 Sep 17:39
8cb00f1
Compare
Choose a tag to compare

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