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

Fix: Importing emmet package as an ECMAScript module doesn't work yet #38

Closed
thiagomini opened this issue Mar 7, 2024 · 1 comment · Fixed by #39 or #41
Closed

Fix: Importing emmet package as an ECMAScript module doesn't work yet #38

thiagomini opened this issue Mar 7, 2024 · 1 comment · Fixed by #39 or #41
Labels
bug Something isn't working CI compatibility
Milestone

Comments

@thiagomini
Copy link
Contributor

Description

When installing emmet on a project that uses ECMAScript module syntax (package.json with type: module), it throws the following error:

file:///home/thiago/Development/pessoal/emmet-example/dist/src/index.js:1
import { getInMemoryEventStore } from '@event-driven-io/emmett';
         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'getInMemoryEventStore' not found. The requested module '@event-driven-io/emmett' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@event-driven-io/emmett';
const { getInMemoryEventStore } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.11.1

We need to investigate what's causing that and fix it.

Acceptance Criteria

On a fresh new repository / project, after installing emmet, we should be able to import artifacts from emmet as follows:

import { CommandHandler, getInMemoryEventStore } from '@event-driven-io/emmett';

const es = getInMemoryEventStore();

console.log(es);

Additional information

@event-driven-io/emmett version 5.0.1
Node.js version 20.11.0
OS WSL 2.1.4.0
Package Manager yarn 4.0.2
@oskardudycz
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CI compatibility
Projects
None yet
2 participants