Skip to content

Invalid invocation of hexoid in [email protected] #871

Closed as not planned
Closed as not planned
@mwaibel-go

Description

@mwaibel-go

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): no
  • Affecting a production system? (yes/no): no

Context

  • Node.js version: v16.13.0
  • Release Line of Formidable (Legacy, Current, Next): Legacy
  • Formidable exact version: 2.0.1
  • Environment (node, browser, native, OS): node
  • Used with (popular names of modules): dependency of [email protected], which is a dependency of [email protected]. This issue appears to surface in other projects, as well.

What are you trying to achieve or the steps to reproduce?

I’m compiling a test suite with webpack. The tests require supertest, which through its dependency superagent relies on [email protected].

The offending lines are lines 8 and 15 in Formidable.js,

const hexoid = require('hexoid');
// ...
const toHexoId = hexoid(25);

You appear to be relying on hexoid’s behaviour prior to this commit in which the export mechanism was changed.

[Edit: It turns out I jumped to conclusions there, as the change in that repository was not published. I’m thinking this issue might actually be related to the switch to ES modules merged in 70517da (release 3.0.0), but JS modules are beyond me.]

Changing the import in line 8 to

const hexoid = require('hexoid').default;

fixes the error for me.

Unfortunately, the author of that library didn’t bump their version after the breaking change. I suggest you either released the fix I suggested above (if @^2.0.0 is still supported), or you pinned the exact git commit in your dependencies.

What was the result you got?

When I try to compile my tests using webpack, the compiler throws this Error:

TypeError: hexoid is not a function
    at Object../node_modules/formidable/src/Formidable.js ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/node_modules/formidable/src/Formidable.js:15:1)
    at __webpack_require__ ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/webpack/bootstrap:19:1)
    at Object../node_modules/formidable/src/index.js ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/node_modules/formidable/src/index.js:5:20)
    at __webpack_require__ ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/webpack/bootstrap:19:1)
    at Object../node_modules/superagent/lib/node/index.js ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/node_modules/superagent/lib/node/index.js:46:20)
    at __webpack_require__ ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/webpack/bootstrap:19:1)
    at Object../node_modules/supertest/lib/test.js ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/node_modules/supertest/lib/test.js:11:21)
    at __webpack_require__ ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/webpack/bootstrap:19:1)
    at Object../node_modules/supertest/index.js ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/node_modules/supertest/index.js:8:14)
    at __webpack_require__ ($PROJECT_DIR/dist/webpack:/$PROJECT_NAME/webpack/bootstrap:19:1)

($PROJECT_DIR and $PROJECT_NAME are replacements of my actual file path and project name.)

What result did you expect?

No compile-time error.

Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions