RodrigoTomeES / astro-rename

Astro-Rename is an Astro integration that brings postcss-rename functionality to your Astro project without the need for configuration.
https://www.npmjs.com/package/astro-rename
GNU General Public License v3.0
15 stars 4 forks source link

fix: update package.json to make types work #15

Closed florian-lefebvre closed 3 months ago

RodrigoTomeES commented 3 months ago

@florian-lefebvre hi, thanks so much for the PR!!!

But I tested it and it doesn't work, but I found the problem. The route of the types was wrong 🤦🏼‍♂️, it is "types": "./dist/src/index.d.ts",. But what is the difference between declare the main and the types and your declaration form?

florian-lefebvre commented 3 months ago

I'm not sure tbh! @Fryuni do you know the difference?

Fryuni commented 3 months ago

From the docs:

The "main" field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package.

The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, and preventing any other entry points besides those defined in "exports". This encapsulation allows module authors to clearly define the public interface for their package.

They work mostly the same, but "exports" is more flexible and when present prevents importing anything that is not declared.

I don't know what was the original problem this PR was trying to solve, but this change should not affect anything importing the library root (import ... from 'astro-rename';)

florian-lefebvre commented 3 months ago

Gotcha thank you! Yeah this PR does not fix the initial problem (but @RodrigoTomeES figured it out) but I believe it doesn't hurt looking at your explanation. Up to you @RodrigoTomeES!

RodrigoTomeES commented 3 months ago

@Fryuni thanks for the explanation very interesting!!. @florian-lefebvre I will use your approach, it appear to be a more modern way to do it and better because it only import exactly what I export explicitly