Skip to content

Commit

Permalink
Merge pull request #103 from iambumblehead/add-esm-subpath-export-con…
Browse files Browse the repository at this point in the history
…dition

add subpath exports
  • Loading branch information
iambumblehead committed Jul 31, 2022
2 parents 58424e6 + b8e560f commit 96d2754
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Expand Up @@ -28,7 +28,7 @@ jobs:
- run: npm run build --if-present
- run: |
{ PER=$(npm run test-cover | tee /dev/fd/3 | grep -oP "All\ files[^\d]*(\d\d?\.?\d?\d?)" | grep -oP "(\d\d?\.?\d?\d?)$"); } 3>&1
echo "COVERAGE=$PER" >> $GITHUB_ENV
echo "COVERAGE=$PER%" >> $GITHUB_ENV
# var REF = 'refs/pull/27/merge.json';
REF=${{ github.ref }}
# console.log('github.ref: ' + REF);
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -47,6 +47,11 @@ await esmock(
{ ...globalmocks }) // mock definitions imported everywhere
```

_note: `esmock` is [unable to mock some export expressions.][20]_ `esmock` is improving in this area. [See the wiki][20] for more details.

[20]: https://github.com/iambumblehead/esmock/wiki#user-content-problems-module-resolution


`esmock` examples
``` javascript
import test from 'node:test'
Expand Down
11 changes: 6 additions & 5 deletions package.json
@@ -1,14 +1,15 @@
{
"name": "esmock",
"version": "1.9.0",
"type": "module",
"version": "1.9.1",
"license": "ISC",
"readmeFilename": "README.md",
"description": "provides native ESM import mocking for unit tests",
"author": "chris <chris@bumblehead.com>",
"main": "src/esmockLoader.js",
"module": "src/esmockLoader.js",
"type": "module",
"types": "src/esmock.d.ts",
"exports": {
"types": "./src/esmock.d.ts",
"import": "./src/esmockLoader.js"
},
"repository": {
"type": "git",
"url": "https://github.com/iambumblehead/esmock.git"
Expand Down
2 changes: 1 addition & 1 deletion src/esmockLoader.js
Expand Up @@ -46,7 +46,7 @@ const resolve = async (specifier, context, nextResolve) => {
// later versions of node v16 include 'node-addons'
const resolved = context.parentURL && (
context.conditions.slice(-1)[0] === 'node-addons'
|| (context.importAssertions || isLT1612))
|| context.importAssertions || isLT1612)
? await nextResolve(specifier, context)
: await nextResolve(specifier)

Expand Down

0 comments on commit 96d2754

Please sign in to comment.