1.0.21 • Published 2 years ago

@dodoex-io/core v1.0.21

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

使用

  1. 考虑到很多核心方法写在 core 项目,当方法报错时需要告知给用户报错内容。以便让用户知道错误,以及联系客服时能提供相应信息。所以将 toast 方法通过初次调用赋值的方式,传入 core 项目
initCore({
  projectToastFailed: toastFailed,
  projectToastSuccess: toastSuccess,
});
  1. 其他按需使用即可

常用方法

错误捕获

监听到错误,需要上报到 sentry ,并提供有用的信息,方便修复。并根据实际情况看是否需要提示给用户

captureException(api, error, params)

问题

  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.

1.0.21

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.20-0

2 years ago

1.0.16

2 years ago

1.0.17-5

2 years ago

1.0.17-4

2 years ago

1.0.17-3

2 years ago

1.0.17-2

2 years ago

1.0.20

2 years ago

1.0.17-1

2 years ago

1.0.17-0

2 years ago

1.0.15-0

2 years ago

1.0.15

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6-0

2 years ago

1.0.6

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.14-beta.1

2 years ago

1.0.12

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago