Merge pull request #824 from vector-im/fix-dev-server-1

Fix develop server breaking due to import syntax
This commit is contained in:
R Midhun Suresh 2022-08-01 17:29:52 +05:30 committed by GitHub
commit 7d3f22c106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

11
doc/IMPORT-ISSUES.md Normal file
View File

@ -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.

View File

@ -98,8 +98,9 @@ export class DerivedVariables {
} }
} }
import pkg from "off-color"; import * as pkg from "off-color";
const {offColor} = pkg; // @ts-ignore
const offColor = pkg.offColor ?? pkg.default.offColor;
export function tests() { export function tests() {
return { return {

View File

@ -13,8 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import pkg from 'off-color'; import * as pkg from 'off-color';
const offColor = pkg.offColor; const offColor = pkg.offColor ?? pkg.default.offColor;
export function derive(value, operation, argument, isDark) { export function derive(value, operation, argument, isDark) {
const argumentAsNumber = parseInt(argument); const argumentAsNumber = parseInt(argument);