1.0.25 • Published 12 months ago

@dodoex/core v1.0.25

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

问题

  1. get config rollup 不支持动态参数的 dynamic import, 见 https://github.com/rollup/rollup/issues/2463,所以 packages\dodoex-io-core\src\setting\getConfig\index.ts 文件中
    let { default: data } = await import(
      `./configs/${chain.localConfigPath}.json`
    );

的导入在 dodo-web 项目中使用时会报错,

./node_modules/@dodoex-io/core/dist/esm/index.js
Module not found: Can't resolve './configs' in 'C:\code\work\dodo-web\node_modules\@dodoex-io\core\dist\esm'
Compiling...
Failed to compile.

./node_modules/@dodoex-io/core/dist/esm/index.js
Module not found: Can't resolve './configs' in 'C:\code\work\dodo-web\node_modules\@dodoex-io\core\dist\esm'

这里不再使用动态参数,如果请求报错,则使用默认的空配置文件即可

  1. @ethersproject/bignumber 该库在编译之后,dist/esm/index.js 中 import 的代码为
import require$$2$6, { parseFixed, _base36To16, _base16To36, BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
import { Route as Route$1 } from '@owen05/dodo-sdk-v2';

而这种默认导出在 webpack 中是无法使用的,因为 @ethersproject/bignumber 这个包实际上没有默认导出的 require$$2$6,在主站引用这个包的时候会报错:

./node_modules/@dodoex-io/core/dist/esm/index.js
Attempted import error: '@ethersproject/bignumber' does not contain a default export (imported as 'require$$2$6').

所以在 rollup.config.js 增加以下配置

nodeResolve({
  // https://github.com/rollup/plugins/tree/master/packages/node-resolve#modulesonly 添加这一行后 @ether
  modulesOnly: true,
}),

导出的包的格式变为

import { parseFixed } from '@ethersproject/bignumber';
import { Route } from '@owen05/dodo-sdk-v2';

这样在 webpack 使用的时候就不会报错和警告。同事 dist/esm/index.js 的体积也由 1.88MB 减小到 348KB.