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

Use package.exports for better compatibility #110

Merged

Conversation

dmitri-gb
Copy link
Contributor

@dmitri-gb dmitri-gb commented Apr 18, 2024

Hey!

I'd like to suggest this change in package.json which should make the package more interoperable.

The exports field is the standard way to specify the "main" module and is universally supported by most runtimes and bundlers. The currently used module field does not work in Node.js and even a simple import {} from 'docx-preview' will fail.

I also removed "type": "module", as it is not correct. The property is meant to specify whether .js files in the package are to be interpreted as ES modules or CommonJS. And right now dist/*.js are all CommonJS modules. If you wanted to keep "type": "module", you'd need to rename those files to .cjs.

Finally, I also added moduleResolution to tsconfig.json so that the jszip import would resolve properly.

With these changes, it will be possible to load docx-preview from both ES and CommonJS modules.

@VolodymyrBaydalka VolodymyrBaydalka merged commit 589b3cf into VolodymyrBaydalka:master May 1, 2024
1 check passed
@dmitri-gb dmitri-gb deleted the package-exports branch May 2, 2024 13:32
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