Respect `copy from`/`copy to` extended headers
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
Under TypeScript `node16` module resolution, I often find myself needing to fix broken ESM types in packages by copying their type definition files ([example package](https://arethetypeswrong.github.io/?p=hls.js%401.5.13)).
These diffs currently show a `new file` command with the full content of the copied file, which makes them very long and hard to maintain from release to release.
```diff
diff --git a/dist/hls.js.d.ts b/dist/hls.d.mts
similarity index 100%
rename from dist/hls.js.d.ts
rename to dist/hls.d.mts
diff --git a/dist/hls.d.ts b/dist/hls.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..7ba8086b369797b5778b5295443cdd07e6beb72c
--- /dev/null
+++ b/dist/hls.d.ts
@@ -0,0 +1,3105 @@
+export declare interface AbrComponentAPI extends ComponentAPI {
+ firstAutoLevel: number;
+ forcedAutoLevel: number;
(3000+ more lines)
```
I can generate my own much smaller patch using [`git diff --find-copies-harder`](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---find-copies-harder). It's both easier to understand and easier to keep updated with the underlying package.
```diff
diff --git a/dist/hls.js.d.ts b/dist/hls.d.mts
similarity index 100%
copy from dist/hls.js.d.ts
copy to dist/hls.d.mts
diff --git a/dist/hls.js.d.ts b/dist/hls.d.ts
similarity index 100%
rename from dist/hls.js.d.ts
rename to dist/hls.d.ts
```
Unfortunately `patch-package` silently ignores these `copy from`/`copy to` headers.
When applying a patch generated by `git diff`, it would be great if this package would copy files. If that's not possible, then it should at least refuse to apply the patch.
Full list of extended header lines: https://git-scm.com/docs/diff-generate-patch#generate_patch_text_with_p
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.