Skip to content

Add support for Native ESM #5

Open
@onemen

Description

@onemen

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

 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions