fly-apps / fly-apps/litefs-js

Add support for Native ESM

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
TypeScript
Stars
164
Forks
4
PR merge metrics
No merged PRs in 30d

Description

importing 'litefs-js/remix' in ESM project (`"type": "module"` in `package.json` ) is not working

```shell
error TS2307: Cannot find module 'litefs-js/remix' or its corresponding type declarations.

10 import { ensureInstance } from 'litefs-js/remix'
~~~~~~~~~~~~~~~~~
```

add this to `package.json` to fix this issue

```diff
"name": "litefs-js",
"version": "1.1.2",
"description": "JavaScript utilities for working with LiteFS on Fly.io",
"types": "dist/index.d.ts",
"main": "dist/index.js",
+ "exports": {
+ ".": {
+ "types": "./dist/index.d.ts",
+ "default": "./dist/index.js"
+ },
+ "./remix": {
+ "types": "./dist/remix.d.ts",
+ "default": "./dist/remix.js"
+ }
+ },
"scripts": {
```

although the above patch fixed this issue, maybe it is better to add build script to build both dist/esm and dist/cjs each with its own .d.ts files.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.