-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Esm/Cjs issue? #752
Comments
I have a similar scenario where I'm including a dependency i18next which depends on In the produced // node_modules/i18next/dist/esm/i18next.js
var import_typeof = __toESM(require("@babel/runtime/helpers/esm/typeof"), 1);
var import_classCallCheck = __toESM(require("@babel/runtime/helpers/esm/classCallCheck"), 1);
var import_createClass = __toESM(require("@babel/runtime/helpers/esm/createClass"), 1);
var import_assertThisInitialized = __toESM(require("@babel/runtime/helpers/esm/assertThisInitialized"), 1);
var import_inherits = __toESM(require("@babel/runtime/helpers/esm/inherits"), 1);
var import_possibleConstructorReturn = __toESM(require("@babel/runtime/helpers/esm/possibleConstructorReturn"), 1);
var import_getPrototypeOf = __toESM(require("@babel/runtime/helpers/esm/getPrototypeOf"), 1);
var import_defineProperty = __toESM(require("@babel/runtime/helpers/esm/defineProperty"), 1);
var import_toArray = __toESM(require("@babel/runtime/helpers/esm/toArray"), 1); This results in an error: var import_typeof = __toESM(require("@babel/runtime/helpers/esm/typeof"), 1);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/@babel/runtime/helpers/esm/typeof.js from node_modules/utils-lib/dist/index.cjs not supported.
Instead change the require of typeof.js in node_modules/utils-lib/dist/index.cjs to a dynamic import() which is available in all CommonJS modules. |
Appears related to #628 Essentially, this is a problem caused by transitive dependencies that may not be in the same format as the bundle. I suppose this is the fault of the initial dependency in some sense. To solve my problem, I ended up adding |
First of all my entire codebase is in TS. I have an api which is in CJS. It imports a
common
library in my Monorepo that is in originally in ESM. (type: module in package.json) but this is build with tsup in js files in esm and cjs. BUT the problem is that my Time.cjs file import another file (Random.js) in mycommon
lib and I think tsup don't correctly link this. It keeps the Random.js instead of Random.cjs. Or maybe am I missing something? Thanks in advance for the help.Upvote & Fund
The text was updated successfully, but these errors were encountered: