Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add "exports" to package.json #455

Merged
merged 1 commit into from
Jan 8, 2023
Merged

chore: Add "exports" to package.json #455

merged 1 commit into from
Jan 8, 2023

Conversation

SerG-Y
Copy link
Contributor

@SerG-Y SerG-Y commented Aug 31, 2022

Fixes for #451

The motivation of this change [copied from corresponding pixi.js PR]:
This CR adjusts the package.json to make PIXI easier to use in an ESM environment with TypeScript.

TypeScript 4.7 introduces official (albeit beta) support for ESM in TypeScript. In connection with modern bundling tools such as Vite, it presents an exciting opportunity for front-end development. Unfortunately, the current version of PIXI packages do not behave properly in an ESM environment due to adjustments in how TypeScript resolves packages and types.

To be more specific, when running TS in ESM mode against the current version of PIXI, it resolves the code to the CJS bundle and the types to a non-existent index file in the CJS directory. To get it to correctly resolve both the types and the entrypoint, the package.json needs to include an "exports" key that specifies both types and entrypoint for ESM and CJS.

For more details on this feature, see they TypeScript 4.7 release notes or the node.js documentation. Additionally, for fallback reasons, it's recommend to explicitly include the "types" field which specifies exactly where the types are located in the package.

@ivanpopelyshev ivanpopelyshev merged commit 0d586d5 into pixijs-userland:master Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants