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

Moleculer ESM Runner export #1146

Open
4 tasks done
h3x3d opened this issue Oct 20, 2022 · 1 comment
Open
4 tasks done

Moleculer ESM Runner export #1146

h3x3d opened this issue Oct 20, 2022 · 1 comment

Comments

@h3x3d
Copy link

h3x3d commented Oct 20, 2022

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository

Current Behavior

Importing MoleculerRunner while having {"type": "module"} in package.json imports cjs version of MoleculerRunner.

Expected Behavior

Esm version on MoleculerRunner should be exported from "index.mjs"

Failure Information

Cjs version of moleculer runner is not compatible with esm project.

Create ESM project, create index.js file:

import { Runner } from 'moleculer';

const runner = new Runner();
runner.start(process.argv);

Run it.

Solution

Replacing index.mjs in moleculer repo with this fixes an issue

import mod from "./index.js";
import MoleculerRunner from './src/runner-esm.mjs';

export default mod;
export const CIRCUIT_CLOSE = mod.CIRCUIT_CLOSE;
export const CIRCUIT_HALF_OPEN = mod.CIRCUIT_HALF_OPEN;
export const CIRCUIT_HALF_OPEN_WAIT = mod.CIRCUIT_HALF_OPEN_WAIT;
export const CIRCUIT_OPEN = mod.CIRCUIT_OPEN;
export const Cachers = mod.Cachers;
export const Context = mod.Context;
export const Discoverers = mod.Discoverers;
export const Errors = mod.Errors;
export const INTERNAL_MIDDLEWARES = mod.INTERNAL_MIDDLEWARES;
export const Loggers = mod.Loggers;
export const METRIC = mod.METRIC;
export const MOLECULER_VERSION = mod.MOLECULER_VERSION;
export const MetricReporters = mod.MetricReporters;
export const MetricTypes = mod.MetricTypes;
export const Middlewares = mod.Middlewares;
export const PROTOCOL_VERSION = mod.PROTOCOL_VERSION;
export const Registry = mod.Registry;
export const Runner = MoleculerRunner;
export const Serializers = mod.Serializers;
export const Service = mod.Service;
export const ServiceBroker = mod.ServiceBroker;
export const Strategies = mod.Strategies;
export const TracerExporters = mod.TracerExporters;
export const Transit = mod.Transit;
export const Transporters = mod.Transporters;
export const Utils = mod.Utils;
export const Validator = mod.Validator;
export const Validators = mod.Validators;
@icebob
Copy link
Member

icebob commented Oct 20, 2022

Good catch. The problem is that, the mjs file is generated with gen-esm-wrapper

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

No branches or pull requests

2 participants