pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
742 stars 302 forks source link

Why use the .js extension in imports? #3028

Closed Jonathan-Baldwin closed 2 months ago

Jonathan-Baldwin commented 2 months ago

What version of PnPjs library you are using

4.x

Minor Version Number

4.0.0

Target environment

All

Additional environment details

Just reading the code base in GitHub 🧑‍💻

Question/Request

I have a general question about the codebase.

I notice that there are references to .js files in the import statements across many of the files in the sp package. i am curious why the .js extension is needed here as this appears to be a TypeScript project. For example https://github.com/pnp/pnpjs/blob/a111ec8f95bc5b3bea08e6df1043d80f3b35ac59/packages/sp/lists/types.ts#L16

Is there a reason that the extension cannot be omitted within the import statements in this project?

patrick-rodgers commented 2 months ago

This is done to help with the node module resolution rules between esm and commonjs.

patrick-rodgers commented 2 months ago

Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!

github-actions[bot] commented 1 month ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.