You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an issue with the package when trying to import it in a Node.js environment that strictly requires file extensions in ES Module imports. The package is specified as an ES module ("type": "module" in package.json), but the exported files in the distribution do not include the .js file extensions. This results in import failures when the package is used in environments that adhere to the Node.js module resolution algorithm for ES Modules.
Details
Node.js, from version 12 onwards, enforces the inclusion of file extensions for ES Modules. However, the current exports in @ston-fi/sdk are missing these required .js extensions, which leads to errors such as:
error TS2305: Module '"@ston-fi/sdk"' has no exported member 'DEX'.
error TS2305: Module '"@ston-fi/sdk"' has no exported member 'pTON'.
Given the use of vite.js for your development and potential deployment setups, a switch to tsup for library packaging might resolve this issue, as it supports better configuration options for both ESM and CommonJS formats.
Suggested Fix
I recommend updating the package build process to include .js file extensions in the module export paths. Here is a suggested tsup.config.ts configuration that ensures proper file extensions:
import{defineConfig}from'tsup';exportdefaultdefineConfig(options=>{return{entryPoints: ['src/'],outDir: 'dist',dts: true,sourcemap: !options.watch,clean: true,splitting: true,format: ['esm','cjs'],// This ensures both formats are built with appropriate file extensions};});
This configuration specifies multiple formats (ESM and CJS) and includes explicit settings to ensure file extensions are correct, thus making your SDK compatible with standard Node.js module resolution rules and preventing import errors for users in strict ES Module environments.
The text was updated successfully, but these errors were encountered:
I am experiencing an issue with the package when trying to import it in a Node.js environment that strictly requires file extensions in ES Module imports. The package is specified as an ES module (
"type": "module"
inpackage.json
), but the exported files in the distribution do not include the.js
file extensions. This results in import failures when the package is used in environments that adhere to the Node.js module resolution algorithm for ES Modules.Details
Node.js, from version 12 onwards, enforces the inclusion of file extensions for ES Modules. However, the current exports in
@ston-fi/sdk
are missing these required.js
extensions, which leads to errors such as:Given the use of vite.js for your development and potential deployment setups, a switch to tsup for library packaging might resolve this issue, as it supports better configuration options for both ESM and CommonJS formats.
Suggested Fix
I recommend updating the package build process to include .js file extensions in the module export paths. Here is a suggested tsup.config.ts configuration that ensures proper file extensions:
and
package.json
:This configuration specifies multiple formats (ESM and CJS) and includes explicit settings to ensure file extensions are correct, thus making your SDK compatible with standard Node.js module resolution rules and preventing import errors for users in strict ES Module environments.
The text was updated successfully, but these errors were encountered: