Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Only export as ESM. #216

Merged
merged 5 commits into from
Jan 9, 2023
Merged

feat: Only export as ESM. #216

merged 5 commits into from
Jan 9, 2023

Conversation

ShogunPanda
Copy link
Contributor

@ShogunPanda ShogunPanda commented Dec 14, 2022

This PR changes Lyra to be a ESM only package, since most of our target runtime support ESM by default.
For CJS compatibility, a separate export point is exported which can be used to require Lyra in both the following ways:

const { create, insert } = require('@lyrasearch/lyra/cjs')

create()
  .then(db => insert(db, {/* ... */})
  .catch(console.error)

OR

const { requireLyra } = require('@lyrasearch/lyra/cjs')

requireLyra((err, lyra) => {
  if(err) {
    throw err
  }

  const { create, insert } = lyra
  create()
    .then(db => insert(db, {/* ... */})
    .catch(console.error)
})

Note that tokenize and formatNanoseconds are not export anymore in index.ts nor cjs since they are not async methods.

.swcrc Show resolved Hide resolved
src/commonjs.cts Outdated Show resolved Hide resolved
@ShogunPanda ShogunPanda force-pushed the feat/esm-only branch 2 times, most recently from d48e7a7 to bd6b8a8 Compare January 3, 2023 08:13
@ShogunPanda ShogunPanda marked this pull request as ready for review January 3, 2023 08:23
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/methods/common.ts Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
Copy link
Member

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@micheleriva micheleriva merged commit 86118a5 into main Jan 9, 2023
@micheleriva micheleriva deleted the feat/esm-only branch January 9, 2023 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants