We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, i'm facing this issue with CJS bundles. I have two files:
// ./a.js export default class A { constructor() { console.log('Hello world!'); } }
// ./b.js import A from './a.cjs'; // should be evaluated dynamically class B extends A { constructor() { super(); console.log("How ya doin'?"); } } new B();
Building two separate files using: tsup ./a.js and tsup ./b.js --external ./a.cjs
tsup ./a.js
tsup ./b.js --external ./a.cjs
Which produces desired cjs files in the dist folder.
cjs
dist
The problem appears if I run:
$ node ./dist/b.cjs ./dist/b.cjs:22 var B = class extends import_a.default { ^ TypeError: Class extends value #<Object> is not a constructor or null
Expected output :
$ node ./dist/b.cjs Hello world! How ya doin'?
ESM works well.
Update: It works well if i remove __toESM from b.cjs:
__toESM
b.cjs
// ./dist/b.cjs // Changed this: var import_a = __toESM(require("./a.cjs"), 1); // To this: var import_a = require("./a.cjs");
The text was updated successfully, but these errors were encountered:
same another workaround i've find to work is:
import A from './a.cjs'; // vvvv class B extends A.default { constructor() { super(); console.log("How ya doin'?"); } }
However it does upset my editor a little bit.
Edit: you may need to place // @ts-ignore above class B extends A.default {
// @ts-ignore
class B extends A.default {
Sorry, something went wrong.
splitting: true does the magic...
splitting: true
// tsup.config.js import { defineConfig } from 'tsup'; export default defineConfig( /** @type {() => import('tsup').Options} */ (options) => ({ clean: true, dts: true, format: ['cjs', 'esm'], entry: ['src/index.ts'], minify: !options.watch, sourcemap: options.watch, splitting: true, }), );
It works fine with this config!
No branches or pull requests
Hi,
i'm facing this issue with CJS bundles. I have two files:
Building two separate files using:
tsup ./a.js
andtsup ./b.js --external ./a.cjs
Which produces desired
cjs
files in thedist
folder.The problem appears if I run:
Expected output :
ESM works well.
Update: It works well if i remove
__toESM
fromb.cjs
:The text was updated successfully, but these errors were encountered: