AElfProject / aelf-web3.js

aelf JavaScript SDK
MIT License
16 stars 24 forks source link

aelf-web3.js - building dist export error #177

Closed AbigailDeng closed 3 months ago

AbigailDeng commented 3 months ago

Description

aelf-web3.js recently underwent a dependency upgrade, which included upgrading from Webpack 4 to Webpack 5. This upgrade has introduced some issues due to Webpack's removal of built-in polyfills, requiring users to manually include necessary packages. As a result, the bundled output frequently throws errors related to missing process or similar variables. Additionally, there's a problem with the bundled output for Node.js environments using CommonJS: the external import statement const { AElf } = require('aelf-sdk') is generated, while the desired import is const AElf = require('aelf-sdk').

Steps To Reproduce

The Current Behavior

The bundled output throws errors indicating that process or other built-in Node.js modules are missing. The CommonJS module export in the bundled file results in the import statement const { AElf } = require('aelf-sdk'), which is not the intended usage.

The Expected Behavior

The bundled output should include necessary polyfills or configuration to avoid errors related to missing process or other built-in Node.js modules. The CommonJS module export should result in the import statement const AElf = require('aelf-web3.js') to ensure correct usage in a Node.js environment.

Environment

Package: aelf-web3.js Node.js Version: v20.8.1