From edcd777cfaedfdb436c62b5dcb3cff6291268e4c Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Sun, 28 Mar 2021 13:51:39 -0500 Subject: [PATCH] Fix/css module types (#823) * fix: Ensures ambient types are included in publish * docs: Adds note on TS + CSS Module usage * docs: Adding changeset --- .changeset/dirty-islands-fail.md | 5 +++++ README.md | 2 ++ package.json | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/dirty-islands-fail.md diff --git a/.changeset/dirty-islands-fail.md b/.changeset/dirty-islands-fail.md new file mode 100644 index 0000000..a1bb835 --- /dev/null +++ b/.changeset/dirty-islands-fail.md @@ -0,0 +1,5 @@ +--- +'microbundle': patch +--- + +Ensures ambient type declaration for CSS Modules is included in the published bundle diff --git a/README.md b/README.md index e7b8bcd..bc292af 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ Just point the input to a `.ts` file through either the cli or the `source` key Microbundle will generally respect your TypeScript config defined in a `tsconfig.json` file with notable exceptions being the "[target](https://www.typescriptlang.org/tsconfig#target)" and "[module](https://www.typescriptlang.org/tsconfig#module)" settings. To ensure your TypeScript configuration matches the configuration that Microbundle uses internally it's strongly recommended that you set `"module": "ESNext"` and `"target": "ESNext"` in your `tsconfig.json`. +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. + ### CSS and CSS Modules 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: diff --git a/package.json b/package.json index 850e3e6..3a52e0c 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ ], "files": [ "src", - "dist" + "dist", + "index.d.ts" ], "author": "Jason Miller (http://jasonformat.com)", "license": "MIT",