这是indexloc提供的服务,不要输入任何密码
Skip to content

TypeError: __require.resolve is not a function #369

@mvrlin

Description

@mvrlin

Hello! I have an issue with the tsup, I have a TypeScript project with require.resolve function, with pure tsc it works, but when I try to build with tsup-node I get this error:

TypeError: __require.resolve is not a function

I made a reproduction repo for this issue:
https://github.com/mvrlin/tsup-require-resolve

I came across this "solution":

// Before
var __require = (x) => {
  if (typeof require !== "undefined")
    return require(x);
  throw new Error('Dynamic require of "' + x + '" is not supported');
};

// After
var __require = (x) => {
  throw new Error('Dynamic require of "' + x + '" is not supported');
}

if (typeof require !== "undefined") {
  __require = require
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions