callstack / haul

Haul is a command line tool for developing React Native apps, powered by Webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module.createRequireFromPath() is deprecated.

sraka1 opened this issue · comments

Environment

Node v13.8.0

Description

Module.createRequireFromPath() is deprecated since Node v12.2.0. An error is thrown when it is used on v13.

Reproducible Demo

Use haul in a project with Node version > 13.

Proposed fix

In

// Create resolver for this module.
something like the following could be implemented (to main compatibility with Node 10-12)

  const createRequireWrapper = Module.createRequire || Module.createRequireFromPath
  // Create resolver for this module.
  const currentResolve = ((createRequireWrapper(
    module.filename
  ) as unknown) as {
    resolve: RequireResolve;
  }).resolve;

The method seems to be identical in function, only its naming has changed.