From 832597447accd0a04f6aec444ec8a64a1d82c90f Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 1 Aug 2022 17:00:56 +0530 Subject: [PATCH] Add explaining doc --- doc/IMPORT-ISSUES.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/IMPORT-ISSUES.md diff --git a/doc/IMPORT-ISSUES.md b/doc/IMPORT-ISSUES.md new file mode 100644 index 00000000..d4bb62fe --- /dev/null +++ b/doc/IMPORT-ISSUES.md @@ -0,0 +1,11 @@ +## How to import common-js dependency using ES6 syntax +--- +Until [#6632](https://github.com/vitejs/vite/issues/6632) is fixed, such imports should be done as follows: + +```ts +import * as pkg from "off-color"; +// @ts-ignore +const offColor = pkg.offColor ?? pkg.default.offColor; +``` + +This way build, dev server and unit tests should all work.