-
Notifications
You must be signed in to change notification settings - Fork 58
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
Incorrect Module Configuration in package.json #53
Comments
A possible misunderstanding here. If there's interest in supporting both CommonJS and ESM (this would presumably require a build step) I'd be happy to contribute a PR with the maintainers' build tool of choice. I do understand the desire to simplify things and support only ESM, if not.
In v8.x, deck.gl had only |
Correct. I don't intend to support CommonJS in my projects anymore, so I'll close the issue. Projects that still operate in a CommonJS environment should use older |
Overview:
The @mapbox/tiny-sdf package currently has a misconfiguration in its package.json file, which is causing compatibility issues for users in environments that expect CommonJS modules (require() syntax). This issue arises due to the use of the "type": "module" field in combination with the main field set to an ESM file and not a commonJS file. This is causing confusion and errors for users who are trying to use the package in environments that rely on CommonJS modules.
Error and context:
While upgrading my stack to next.js 12.3.4, deck.gl 8.9.25 and mapbox.gl 2.15.0 I encountered the following error :
I do not know why webpack chose @deck.gl/layers/dist/es5 instead of @deck.gl/layers/dist/esm, but @deck.gl was expecting a commonJS file due to the "type: module" in @mapbox/tiny-sdf/package.json
Proposed solution:
To address this issue and enhance compatibility with a wider range of environments, I suggest the following changes to the package.json file of the @mapbox/tiny-sdf package:
Remove the "type": "module" Field: Since the index.js file is already an ESM file, specifying "type": "module" is redundant and causes compatibility issues in CommonJS environments.
Update the main and module Fields:
Duplicate index.js file to index.mjs file, then update index.js file to follow commonJS syntax.
Impact and Benefits:
By implementing this change, the @mapbox/tiny-sdf package will become more compatible with a broader range of environments. Users who rely on both CommonJS and ESM modules will be able to use the package seamlessly, without encountering module system conflicts or errors.
Steps to Reproduce:
Attempt to use the @mapbox/tiny-sdf package in a CommonJS-based environment (such as Node.js) by importing it using require().
Observe the error caused by the incompatibility between the package's "type": "module" field and the use of require().
The text was updated successfully, but these errors were encountered: