`@rollup/plugin-typescript` seems not recognizing `.d.[ext].ts` style definition files?

Open
#1,858 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, typescript, wasm

Research direction

Start with the StackBlitz reproduction and run npm run build to confirm the failure involving src/main.ts and src/chromaprint_bg.d.wasm.ts. Then inspect how @rollup/plugin-typescript handles the .d.wasm.ts declaration file; done means the reproduction builds successfully without the declaration file reaching Rollup's JavaScript parser.

Written by the indexing model from the issue text.

Description

x⁷ ⋅ stale
Expected Behavior

Bundle successfully built with npm run build.

Actual Behavior
src/main.ts → dist...
[!] RollupError: src/chromaprint_bg.d.wasm.ts (2:9): Expected ',', got '?' (Note that you need plugins to import files that are not JavaScript)
src/chromaprint_bg.d.wasm.ts (2:9)
1: export default function (
2:   imports?: WebAssembly.Imports
            ^
3: ): Promise<WebAssembly.Instance>;
    at Object.getRollupError (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/parseAst.js:285:41)
    at ParseError.initialise (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/rollup.js:15820:40)
    at convertNode (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/rollup.js:17714:10)
    at convertProgram (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/rollup.js:16957:12)
    at Module.setSource (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/rollup.js:18695:24)
    at async ModuleLoader.addModuleSource (/home/projects/rollup-repro-w7wg6yag/node_modules/rollup/dist/shared/rollup.js:22265:13)
…
Additional Information

I was trying to integrate WASM in a TS project, utilizing TypeScript 5.0 allowArbitraryExtensions compiler option (where I provide defs with a .d.wasm.ts file) and got errors on it. It seems that the def file was not transformed or dropped by TypeScript plugin and went to later stages.
I guess maybe it's @rollup/plugin-typescript not recognizing the def file? (though I did not actually dig into the code to verify the idea 🤦)

Dominant language
JavaScript
Stars
3.8k
Forks
635
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rollup/plugins

All issues in rollup/plugins

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.