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

Uncaught TypeError: classes_1.classes is not a function #558

Open
3 of 9 tasks
LotuxPunk opened this issue Jun 26, 2023 · 2 comments
Open
3 of 9 tasks

Uncaught TypeError: classes_1.classes is not a function #558

LotuxPunk opened this issue Jun 26, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@LotuxPunk
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Hello, I have a library that I've compiled and I'm trying to run it in a ReactJS application.

This library uses AutoMapper with the classes strategy, and during startup, there are no compilation issues. However, once on the web console, the following error occurs:

Uncaught TypeError: classes_1.classes is not a function
    node_modules bundle.js:49154
    factory react refresh:6
    Webpack 39
mapper.ts:20
    js mapper.ts:20
    factory react refresh:6
    Webpack 39

The code in my library is similar (if not identical) to the documentation:

import {classes as classesFunction} from "@automapper/classes";
import {CamelCaseNamingConvention, createMapper, Mapper} from "@automapper/core";

export const mapper: Mapper = createMapper({
    strategyInitializer: classesFunction(),
    namingConventions: {
        source: new CamelCaseNamingConvention(),
        destination: new CamelCaseNamingConvention(),
    },
})

The result of the compilation:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

const classes_1 = require("@automapper/classes");
const core_1 = require("@automapper/core");
exports.mapper = (0, core_1.createMapper)({
    strategyInitializer: (0, classes_1.classes)(),
    namingConventions: {
        source: new core_1.CamelCaseNamingConvention(),
        destination: new core_1.CamelCaseNamingConvention(),
    },
});

Do you have any insights regarding this issue? Thank you in advance!

Models/DTOs/VMs

No response

Mapping configuration

No response

Steps to reproduce

No response

Expected behavior

ReactJS application to work without any log errors

Screenshots

No response

Minimum reproduction code

No response

Package

  • I don't know.
  • @automapper/core
  • @automapper/classes
  • @automapper/nestjs
  • @automapper/pojos
  • @automapper/mikro
  • @automapper/sequelize
  • Other (see below)

Other package and its version

No response

AutoMapper version

8.7.7

Additional context

NodeJS 18.6
MacOS 13

@LotuxPunk LotuxPunk added the bug Something isn't working label Jun 26, 2023
@gwen1230
Copy link

Same here !

@gwen1230
Copy link

Found solution : facebook/create-react-app#12700.

Create-react-app doesn't support cjs files.

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

No branches or pull requests

2 participants