@visulima/packem 1.8.2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## @visulima/packem [1.9.0](https://github.com/visulima/packem/compare/@visulima/packem@1.8.2...@visulima/packem@1.9.0) (2024-11-23)
2
+
3
+ ### Features
4
+
5
+ * added a files shim types file, fixed log for externals ([3a93717](https://github.com/visulima/packem/commit/3a9371773367c9f99ad4c8ee00ad5d00cb1ec761))
6
+
1
7
  ## @visulima/packem [1.8.2](https://github.com/visulima/packem/compare/@visulima/packem@1.8.1...@visulima/packem@1.8.2) (2024-11-22)
2
8
 
3
9
  ### Bug Fixes
package/README.md CHANGED
@@ -881,6 +881,49 @@ You choose which one of the three supported transformer to use.
881
881
  - [@swc/core](https://github.com/swc-project/swc)
882
882
  - [sucrase](https://github.com/alangpierce/sucrase)
883
883
 
884
+ ### File types
885
+
886
+ Packem exports a `files.d.ts` file that contains all supported the types.
887
+
888
+ To shim the types, you can use the following:
889
+
890
+ ```ts
891
+ /// <reference types="@visulima/packem/files" />
892
+ ```
893
+
894
+ Alternatively, you can add `@visulima/packem/files` to `compilerOptions.types` inside `tsconfig.json`:
895
+
896
+ ```json
897
+ {
898
+ "compilerOptions": {
899
+ "types": ["@visulima/packem/files"]
900
+ }
901
+ }
902
+ ```
903
+
904
+ This will provide the following type shims:
905
+
906
+ - Asset imports (e.g importing an `.svg`, `.module.css` file)
907
+
908
+ > Tip:
909
+ >
910
+ > To override the default typing, add a type definition file that contains your typings. Then, add the type reference before `@visulima/packem/files`.
911
+ >
912
+ > packem-env-override.d.ts (the file that contains your typings):
913
+ > ```ts
914
+ > declare module '*.svg' {
915
+ > const content: React.FC<React.SVGProps<SVGElement>>
916
+ > export default content
917
+ > }
918
+ > ```
919
+ >
920
+ > The file containing the reference to `@visulima/packem/files`:
921
+ >
922
+ > ```ts
923
+ > /// <reference types="./packem-env-override.d.ts" />
924
+ > /// <reference types="@visulima/packem/files" />
925
+ > ```
926
+
884
927
  ## Related
885
928
 
886
929
  - [bunchee](https://github.com/huozhi/bunchee) - Zero config bundler for ECMAScript and TypeScript packages