Skip to content

Commit 07acadd

Browse files
committed
fix(enhanced-img): ensure ambient modules use ambient imports
Top-level imports and exports automatically upgrade a TypeScript file to the module context. This is not desired in because we want to keep this module ambient in order for the to apply globally across all imports of . By importing the type inside the ambient module context, we preserve the ambient-ness of the file. https://www.typescriptlang.org/docs/handbook/modules/reference.html#ambient-modules fix
1 parent ee81f76 commit 07acadd

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

.changeset/afraid-llamas-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sveltejs/enhanced-img": patch
3+
---
4+
5+
fix: make `*?enhanced` imports available in the ambient context

packages/enhanced-img/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,21 @@
3737
"types": "types/index.d.ts",
3838
"dependencies": {
3939
"magic-string": "^0.30.5",
40-
"svelte": "^4.2.10",
4140
"svelte-parse-markup": "^0.1.2",
42-
"vite": "^5.2.8",
4341
"vite-imagetools": "^7.0.1"
4442
},
4543
"devDependencies": {
4644
"@types/estree": "^1.0.5",
4745
"@types/node": "^18.19.3",
4846
"estree-walker": "^3.0.3",
4947
"rollup": "^4.14.2",
48+
"svelte": "^4.2.10",
5049
"typescript": "^5.3.3",
50+
"vite": "^5.2.8",
5151
"vitest": "^1.6.0"
52+
},
53+
"peerDependencies": {
54+
"svelte": "^4.0.0 || ^5.0.0-next.0",
55+
"vite": "^5.0.0"
5256
}
5357
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Picture } from 'vite-imagetools';
2-
31
declare module '*?enhanced' {
2+
import type { Picture } from 'vite-imagetools';
3+
44
const value: Picture;
55
export default value;
66
}

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)