egoist / egoist/tsup

Error: ImportEquals should have a literal source.

Open
#1,328 4 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

## Issue
Is it possible to build code using `Import Equals` with `tsup`?
Currently, when I try to build it, I get the following error.

### error

```
Error: ImportEquals should have a literal source.

5 |
6 | import * as runtime from './runtime/library.js';
> 7 | import $Types = runtime.Types // general types
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 | import $Public = runtime.Types.Public
9 | import $Utils = runtime.Types.Utils
10 | import $Extensions = runtime.Types.Extensions
at Transformer.convertImportDeclaration (/node_modules/tsup/dist/rollup.js:5997:19)
at Transformer.convertStatement (/node_modules/tsup/dist/rollup.js:5897:23)
at new Transformer (/node_modules/tsup/dist/rollup.js:5836:16)
at convert (/node_modules/tsup/dist/rollup.js:5827:27)
at Object.transform (/node_modules/tsup/dist/rollup.js:6227:29)
at handleDtsFile (/node_modules/tsup/dist/rollup.js:6343:48)
at Object.transform (/node_modules/tsup/dist/rollup.js:6382:20)
at /node_modules/rollup/dist/shared/rollup.js:1073:40
```

### config
```ts
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
minify: true,
sourcemap: true,
treeshake: true,
dts: true,
clean: true,
format: ['esm', 'cjs'],
outExtension(ctx) {
return { js: ctx.format === 'esm' ? '.mjs' : '.cjs' }
}
})

```

Thank you for the great library 🙏 It's been really helpful!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure from src/index.ts with the shown tsup configuration, especially dts: true and the ESM/CJS formats. Trace the stack through tsup's declaration transformation in dist/rollup.js and compare the ImportEquals case with the supported literal-source cases. Done means the example builds successfully with declarations enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.