Skip to content

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

@WRtux

Description

@WRtux

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 🤦)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions