Skip to content
New issue

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

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

Open
3 tasks done
eXory2024 opened this issue Oct 13, 2024 · 2 comments
Open
3 tasks done

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

eXory2024 opened this issue Oct 13, 2024 · 2 comments

Comments

@eXory2024
Copy link

eXory2024 commented Oct 13, 2024

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.

@eXory2024
Copy link
Author

File extension doesn't matter, if you change .d.mts to .d.ts and .mts to .ts the behaviour is the same.

@eXory2024
Copy link
Author

It looks like the plugin does to the correct thing when the entry point is renamed from .d.mts to simply .mts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant