Skip to content

Commit 60b5edc

Browse files
Add example of exports.types field (#992)
* Add example of exports.types field * Update README.md Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
1 parent c76c41f commit 60b5edc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ The filenames and paths for generated bundles in each format are defined by the
166166
"source": "src/index.js", // input
167167
"main": "dist/foo.js", // CommonJS output bundle
168168
"umd:main": "dist/foo.umd.js", // UMD output bundle
169-
"module": "dist/foo.mjs", // ES Modules output bundle
169+
"module": "dist/foo.mjs", // ES Modules output bundle
170170
"exports": {
171+
"types": "./dist/foo.d.ts", // TypeScript typings for NodeNext modules
171172
"require": "./dist/foo.js", // CommonJS output bundle
172173
"default": "./dist/foo.modern.mjs", // Modern ES Modules output bundle
173174
},
174-
"types": "dist/foo.d.ts" // TypeScript typings directory
175+
"types": "dist/foo.d.ts" // TypeScript typings
175176
}
176177
```
177178

@@ -230,6 +231,8 @@ To ensure Microbundle does not process extraneous files, by default it only incl
230231

231232
If you're using TypeScript with CSS Modules, you will want to set `"include": ["node_modules/microbundle/index.d.ts"]` in your `tsconfig.json` to tell TypeScript how to handle your CSS Module imports.
232233

234+
To ensure that your module's `.d.ts` type info is visible to other TypeScript projects that use [`moduleResolution: 'NodeNext'`](https://www.typescriptlang.org/docs/handbook/esm-node.html), add a [`types` key](https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing) to your `package.json`'s corresponding `exports` mapping.
235+
233236
### CSS and CSS Modules
234237

235238
Importing CSS files is supported via `import "./foo.css"`. By default, generated CSS output is written to disk. The `--css inline` command line option will inline generated CSS into your bundles as a string, returning the CSS string from the import:

0 commit comments

Comments
 (0)