Skip to content

Plugin seems to prefer "*.mts" file over "*.d.mts" file. #317

@eXory2024

Description

@eXory2024

Checklist

  • I can reproduce this issue when running this plugin on its own.
    Other plugins, such as node-resolve are known to cause issues.
  • I am running this plugin on .d.ts files generated by TypeScript.
    The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • This issue is not related to rolling up @types.
    The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Code Snipped

Entry point: (test.d.mts):

// Your code that is causing problems.
export type {myFunction} from "./myFunction.d.mts"

Where myFunction.d.mts is:

export function myFunction(a : string) : string;

And myFunction.mts is:

export function myFunction(a : string) : string {
	return `${a}`
}

Error Message

There is no error message but the output is:

declare function myFunction(a : string) : string {
	return `${a}`
}

export { myFunction };

Which obviously is wrong for a .d.mts file.

Removing the myFunction.mts file makes the plugin output the correct code:

declare function myFunction(a : string) : string;

export { myFunction };

Rollup config:

import {dts} from "rollup-plugin-dts"

export default {
	input: "./src/test.d.mts",

	output: {},

	plugins: [
		dts()
	]
}

I made a repo for easy cloning & reproduce the problem described here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions