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
ES module is the modern standard for JavaScript module system. It is supported by all major browsers and Node.js. It is also the default module system for TypeScript. However, Lumos currently only supports CommonJS module system. Supporting ES module will bring the following benefits:
native support for ES module to use the 1k+ very common modules without transpilation in Lumos
work well with code splitting and tree shaking
import only the required code
improve the cold start time
avoid users using non-exported APIs
the exports field in package.json to specify the entry point of the package
How to
To keep the backward compatibility, we will keep the CommonJS module system as the default, thanks to the conditional exports feature in Node.js, we'll use the exports field in package.json to specify the entry point of the package.
ES Module Support for Lumos
Motivation
ES module is the modern standard for JavaScript module system. It is supported by all major browsers and Node.js. It is also the default module system for TypeScript. However, Lumos currently only supports CommonJS module system. Supporting ES module will bring the following benefits:
exports
field inpackage.json
to specify the entry point of the packageHow to
To keep the backward compatibility, we will keep the CommonJS module system as the default, thanks to the conditional exports feature in Node.js, we'll use the
exports
field inpackage.json
to specify the entry point of the package.@ckb-lumos/bi
@ckb-lumos/codec
@ckb-lumos/toolkit
@ckb-lumos/base
@ckb-lumos/rpc
@ckb-lumos/crypto
@ckb-lumos/config-manager
@ckb-lumos/helpers
@ckb-lumos/hd
@ckb-lumos/ckb-indexer
@ckb-lumos/light-client
@ckb-lumos/transaction-manager
@ckb-lumos/common-scripts
@ckb-lumos/lumos
packageBreaking
import {} from '@ckb-lumos/base/lib/...'
will be brokenNotes for Contributors
/*#__PURE__*/
annotation for tree shakinghow to
lumos-build --esm --cjs --types
@ckb-lumos/[moduleName]/lib/[subModule]
with@ckb-lumos/[moduleName]/[subModule]
exports
andmodule
field to relatedpackage.json
playground/module.test.mjs
The text was updated successfully, but these errors were encountered: