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

Must use import to load ES Module: path/to/project-root/node_modules/dexie/dist/modern/dexie.mjs #1369

Closed
neilnahid opened this issue Jul 26, 2021 · 5 comments

Comments

@neilnahid
Copy link

neilnahid commented Jul 26, 2021

I'm currently using nextjs 11 + typescript and I followed this example: https://github.com/dfahlander/dexie-todo-list
and then I encountered this error
image

I'm trying to run dexie in the browser.

@neilnahid
Copy link
Author

neilnahid commented Jul 26, 2021

I've resolved this by using the next-transpile-modules plugin

// eslint-disable-next-line
const withDexie = require('next-transpile-modules')(['dexie']);
module.exports = withDexie({
// your other config here...
})

@michaelwooley
Copy link

michaelwooley commented Dec 8, 2021

Thank you @neilnahid . This also turned out to be the fix for a different-but-evidently-related error that I was seeing:

TypeError: class constructors must be invoked with 'new'

image

@jayaddison
Copy link
Contributor

jayaddison commented Jan 4, 2022

Hrm. This same issue appears for this import statement when attempting to upgrade to Dexie@3.2.0.

Based on the example in the README here, that should work, I think. I'm a bit reluctant to add next-transpile-modules as a dependency without understanding a bit more about the cause.

@neilnahid @dfahlander don't suppose you can add any more clues / input? I've tried a few tweaks to the import code mentioned, and can experiment a bit more to help track this down.

@dfahlander
Copy link
Collaborator

dfahlander commented Jan 5, 2022

The issue is reported in #1439. Dexie 3.2.0 cannot be required but could be so in previous versions. A new version 3.2.1-beta.2 is just recently published with an extended "exports" field in package.json that hopefully resolves this.

@jayaddison
Copy link
Contributor

jayaddison commented Jan 5, 2022

Thanks @dfahlander - and confirmed that 3.2.1-beta.2 solves the issue (I'll echo that in #1439 as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants