Skip to content

Commit f1af632

Browse files
committed
docs: 更新 FAQ 文档, 增加打包工具报错的解答
1 parent dc0c756 commit f1af632

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

s2-site/docs/manual/faq.zh.md

+56
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,59 @@ class CustomColCell extends ColCell {
483483
推荐使用 `codesandbox`, 我们提供了各种版本的模板,方便你反馈问题。[查看所有模板](https://www.yuque.com/antv/vo4vyz/bam4vz)
484484

485485
## 2. 错误和警告
486+
487+
### `@antv/s2/extends` 找不到,报 `This Dependency was not found` 错误
488+
489+
```json
490+
// package.json
491+
{
492+
"exports": {
493+
".": {
494+
"import": "./esm/index.js",
495+
"require": "./lib/index.js"
496+
},
497+
"./extends": {
498+
"import": "./esm/extends/index.js",
499+
"require": "./lib/extends/index.js"
500+
},
501+
"./*": "./*"
502+
},
503+
"main": "lib/index.js",
504+
"module": "esm/index.js",
505+
}
506+
```
507+
508+
通常来说,是你的使用的包管理器或者打包工具,不支持 `exports` 字段,识别不了 `@antv/s2/extends` 这个子模块,请参考 [#3008](https://github.com/antvis/S2/issues/3008#issuecomment-2533524990)
509+
510+
### `Can't resolve './@antv/s2/esm/styles/variables.less'`
511+
512+
低版本的打包工具如果不写 "~", 即: `@import '~@antv/s2/esm/styles/variables.less'` 的话,会识别成本地模块,自动转成相对路径,而不是从 node_modules 去找,导致源码被编译成如下,导致文件找不到。
513+
514+
```diff
515+
- @import '@antv/s2/esm/styles/variables.less';
516+
+ @import './@antv/s2/esm/styles/variables.less';
517+
```
518+
519+
解决方案:
520+
521+
1. 升级下打包工具。
522+
2. 可以参考 https://github.com/webpack-contrib/less-loader#imports 的解决方案。
523+
3. less-loader 开启 javascriptEnabled, 配置别名,让 `@antv/s2` 转成 `node_modules/@antv/s2`
524+
525+
```ts
526+
{
527+
loader: 'less-loader',
528+
options: {
529+
lessOptions: {
530+
paths: [path.resolve(__dirname, 'node_modules')],
531+
javascriptEnabled: true,
532+
},
533+
},
534+
}
535+
536+
alias: {
537+
'@antv/s2': path.resolve(__dirname, 'node_modules/@antv/s2')
538+
}
539+
```
540+
541+
请参考 [3008#issuecomment-2537747353](https://github.com/antvis/S2/issues/3008#issuecomment-2537747353)[3008#issuecomment-2586200238](https://github.com/antvis/S2/issues/3008#issuecomment-2586200238) 的解决方案。

0 commit comments

Comments
 (0)