Skip to content

Commit

Permalink
fix types resolution when moduleResolution is NodeNext
Browse files Browse the repository at this point in the history
Two issues:

1. The `exports` map in `package.json` needs to include the `types`
key. See: microsoft/TypeScript#51996

2. Explicit `.js` extension is needed for the `export ... from`
statements in `src/index.ts` to satisfy ESM.

Point 2 in turn required a minor tweak to the import statement in
two of the tests (must import `createContainer from `./src/iti`,
not merely `./src`).
  • Loading branch information
tmillican committed Jan 10, 2023
1 parent 0a3a006 commit a6ea749
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion iti/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"source": "src/index.ts",
"exports": {
"require": "./dist/iti.cjs",
"default": "./dist/iti.modern.js"
"default": "./dist/iti.modern.js",
"types": "./dist/src/index.d.ts"
},
"main": "./dist/iti.cjs",
"module": "./dist/iti.module.js",
Expand Down
6 changes: 3 additions & 3 deletions iti/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Main lib
export { createContainer, createContainer as makeRoot, Container } from "./iti"
export { createContainer, createContainer as makeRoot, Container } from "./iti.js"

// Helper types
export type {
GetContainerFormat,
UnPromisify,
UnpackFunction,
Prettify,
} from "./_utils"
export type { Emitter } from "./nanoevents"
} from "./_utils.js"
export type { Emitter } from "./nanoevents.js"
2 changes: 1 addition & 1 deletion iti/tests/dispose-graph.ts.api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, jest, describe, beforeEach, it } from "@jest/globals"
import { createContainer } from "../src"
import { createContainer } from "../src/iti"
import { wait } from "./_utils"
import { A, X, B, C, D, L, K, E, M, F } from "./mock-graph"

Expand Down
2 changes: 1 addition & 1 deletion iti/tests/dispose.ts.api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, jest, describe, beforeEach, it } from "@jest/globals"
import { createContainer } from "../src"
import { createContainer } from "../src/iti"
import { wait } from "./_utils"

describe("Disposing: ", () => {
Expand Down

0 comments on commit a6ea749

Please sign in to comment.