Skip to content

Commit

Permalink
feat: s2-react 移除 antd 的依赖和部分基础组件, 相关分析组件迁移到 s2-react-components 中 (#…
Browse files Browse the repository at this point in the history
…2887)

* build: esm 模块按目录打包, 使用 bundless 的方式支持 tree shaking

* build: 修复打包尺寸校验失败

* build: 自动打开分析工具

* refactor: 解决所有循环依赖问题

* build: 使用 bundless

* docs: 新增变更文档

* chore: 修复 size-limit 错误

* chore: 移除别名配置

* build: 预编译 s2-shared, 解决 bundless 的问题

* build: 修复 react-components 和 vue 打包失败

* feat: s2-react 移除 antd 的依赖, 相关分析组件迁移到 s2-react-components
中

只保留 drill-down, pagination, tooltip 三个基础能力组件

BREAKING CHANGE: 移除 header props 参数 (不再内置行列切换, 导出,
高级排序), 移除 antd ConfigProvider 包裹

* feat: 移除 header

* feat: 移除 SheetComponent 中的 Spin 组件

* feat: 移除分页组件

* docs: 更新文档

* feat: 解耦操作栏 Menu 组件

* feat: 移除编辑表的 Input 依赖

* feat: 迁移下钻组件

* docs: 更新文档

* docs: 完善分页文档

* docs: 完善导出文档

* docs: 调整目录结构

* refactor: 优化分页组件的使用方式

* docs: 完善导出和维度切换组件文档

* test: 迁移并修复 s2-react 中的分析组件单测

* test: 完善 s2-react-components 中高级排序/下钻/导出 单测

* feat: 完善 switcher 功能和单测

* feat: 统一入口文件风格

* test: 更新单测

* feat: 移除 s2-react 的 antd peerDependencies

* chore: 更新 lock

* docs: 更新文档

* docs: 完善文档和示例

* feat: 优化目录结构和文档合理性

* fix: 修复类型问题

* test: 调整单测路径

* feat: shared 包移动到 s2-core 中, 优化打包方式

* chore: 移除 s2-react-components 中的 shared 依赖

* chore: 移除 s2-vue 中的 shared 依赖

* test: 迁移 shared 单测

* docs: 完善文档

* fix: 修复布局错误

* build: 修复 umd 打包失败

* chore: 调整 size-limit

* docs: 完善文档

* build: 使用 tsc 打包

* test: 修复单测

* build: 移除 father

* build: 移除 father

* chore: 修复 ci

* test: 更新 jest 别名

* test: 修复 svg mock 不生效

* docs: 优化文档

* test: 修复单测

* test: 更新快照

* docs: 优化文档跳转效果和迁移文档

* docs: 优化 2.0-next => 2.0 迁移文档

* docs: 更新贡献指南

* chore: 移除无用开发依赖

* chore: 更新 lock

* chore(ci): 尝试解决 CI 单测进程挂起的问题

* chore(ci): 尝试解决 CI 单测进程挂起的问题

---------

Co-authored-by: Wenjun Xu <[email protected]>
Co-authored-by: 卿珂 <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 07357c1 commit 64e3882
Show file tree
Hide file tree
Showing 499 changed files with 7,161 additions and 6,146 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ module.exports = {
tabWidth: 2,
trailingComma: 'all',
printWidth: 80,
arrowParens: 'always',
proseWrap: 'never',
htmlWhitespaceSensitivity: 'css',
embeddedLanguageFormatting: 'auto',
singleAttributePerLine: false,
bracketSpacing: true,
overrides: [
{ files: '.eslintrc', options: { parser: 'json' } },
{ files: '.prettierrc', options: { parser: 'json' } },
Expand All @@ -57,7 +62,7 @@ module.exports = {
],
'import/no-duplicates': [2, { considerQueryString: true }],
'import/no-deprecated': 1,
'import/no-cycle': 1,
'import/no-cycle': 2,
'import/order': [
2,
{
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
- name: Install dependencies
run: pnpm bootstrap:ci

- name: Build doctor
run: pnpm build:doctor

- name: Build
run: pnpm build

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
- uses: preactjs/compressed-size-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
pattern: "./packages/{s2-core,s2-react,s2-vue}/dist/**/*.{js,css}"
build-script: "build:umd"
pattern: "./packages/{s2-core,s2-react,s2-react-components,s2-vue}/dist/**/*.{js,css}"
build-script: "build"
clean-script: "clean"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ packages/s2-*/dist/
packages/s2-*/temp/
packages/s2-*/coverage/
packages/s2-*/stats.html
packages/**/*.css

.swc
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

"我代码水平不行", "会不会受到鄙视?", "会不会不太好?", 放心,不存在的!

我们欢迎任何形式的贡献,不管是一个**错别字的修改**,还是**一次友好的建议**,不管是通过提交 [Issue](https://github.com/antvis/S2/issues/new/choose), 还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是一次钉钉群的讨论,参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。
我们欢迎任何形式的贡献,不管是一个**错别字的修改**,还是**一次友好的建议**,不管是通过提交 [Issue](https://github.com/antvis/S2/issues/new/choose), 还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论。

这是一个开源项目,我们也有繁忙的业务要做,是用自己的业余时间在维护,为爱发电,精力有限,所以有时候 issue 响应速度不是那么及时。

如果你遇到了问题,或者对 Issues 和 Discussions 列表的问题感兴趣,可以直接认领并尝试修复,帮助 S2 变得更好,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。

## 分支管理

Expand Down
20 changes: 11 additions & 9 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A practical visualization library for tabular analysis.

<p>
<a href="https://www.npmjs.com/package/@antv/s2" target="_blank">
<img src="https://img.badgesize.io/https:/unpkg.com/@antv/s2@next/dist/index.min.js?label=gzip%20size&compression=gzip" alt="npm bundle size" />
<img src="https://img.badgesize.io/https:/unpkg.com/@antv/s2/dist/s2.min.js?label=gzip%20size&compression=gzip" alt="npm bundle size" />
</a>
<a href="https://github.com/antvis/S2/discussions" target="_blank">
<img src="https://img.shields.io/badge/discussions-on%20github-blue" alt="GitHub discussions"/>
Expand Down Expand Up @@ -77,9 +77,9 @@ demo components and expansion capabilities, it allows developers to use it quick
## 📦 Installation

```bash
$ npm install @antv/s2@next --save
# yarn add @antv/s2@next
# pnpm add @antv/s2@next
$ npm install @antv/s2 --save
# yarn add @antv/s2
# pnpm add @antv/s2
```

## 🔨 Getting Started
Expand Down Expand Up @@ -208,11 +208,13 @@ bootstrap()

### 📦 Packages

| Package | Latest | Beta | Alpha | Next | Size | Download |
| - | - | - | - | - | - | - |
| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) |
| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |
| Package | Latest | Next | Size | Download |
| - | - | - | - | - |
| -------- | ------ | --------- | ---------- | ------ |
| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg?logo=npm) |
| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg?logo=npm) |
| [@antv/s2-react-components](https://github.com/antvis/S2/tree/next/packages/s2-react-components) | ![latest](https://img.shields.io/npm/v/@antv/s2-react-components/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react-components/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react-components@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react-components.svg?logo=npm) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg?logo=npm) |

### 🖥️ Browser Compatibility

Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<p>
<a href="https://www.npmjs.com/package/@antv/s2" target="_blank">
<img src="https://img.badgesize.io/https:/unpkg.com/@antv/s2@next/dist/index.min.js?label=gzip%20size&compression=gzip" alt="npm bundle size" />
<img src="https://img.badgesize.io/https:/unpkg.com/@antv/s2/dist/s2.min.js?label=gzip%20size&compression=gzip" alt="npm bundle size" />
</a>
<a href="https://github.com/antvis/S2/discussions" target="_blank">
<img src="https://img.shields.io/badge/discussions-on%20github-blue" alt="GitHub discussions"/>
Expand Down Expand Up @@ -73,9 +73,9 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数
## 📦 安装

```bash
$ npm install @antv/s2@next --save
# yarn add @antv/s2@next
# pnpm add @antv/s2@next
$ npm install @antv/s2 --save
# yarn add @antv/s2
# pnpm add @antv/s2
```

## 🔨 使用
Expand Down Expand Up @@ -204,11 +204,13 @@ bootstrap()

### 📦 版本

| Package | Latest | Beta | Alpha | Next | Size | Download |
| - | - | - | - | - | - | - |
| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) |
| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |
| Package | Latest | Next | Size | Download |
| - | - | - | - | - |
| -------- | ------ | --------- | ---------- | ------ |
| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg?logo=npm) |
| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg?logo=npm) |
| [@antv/s2-react-components](https://github.com/antvis/S2/tree/next/packages/s2-react-components) | ![latest](https://img.shields.io/npm/v/@antv/s2-react-components/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react-components/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react-components@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react-components.svg?logo=npm) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg?logo=npm) |

### 🖥️ 兼容环境

Expand Down
145 changes: 145 additions & 0 deletions build.config.base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/* eslint-disable max-lines-per-function */
/* eslint-disable import/order */
import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
import { toLower } from 'lodash';
import path from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import { visualizer } from 'rollup-plugin-visualizer';

export const getBaseConfig = () => {
const entry = './src/index.ts';

const OUT_DIR_NAME_MAP = {
es: 'esm',
cjs: 'lib',
umd: 'dist',
};

const format = process.env.FORMAT;
const isAnalysisMode = process.env.ANALYSIS;
const isDevMode = process.env.PLAYGROUND;
const outDir = OUT_DIR_NAME_MAP[format];
const isUMD = format === 'umd';
const isESM = format === 'es';

const define = {
'process.env.NODE_ENV': JSON.stringify(
isDevMode ? 'development' : 'production',
),
};

const resolve = {
mainFields: ['src', 'module', 'main'],
alias: [],
};

if (isDevMode) {
// 防止开发模式下直接加载 s2-core 中的主题 less
resolve.alias.push(
...[
{
find: /^(.*)\/theme\/(.*)\.less$/,
replacement: '$1/theme/$2.less?inline',
},
{
find: /^@antv\/s2$/,
replacement: path.join(__dirname, './packages/s2-core/src'),
},
],
);
}

const getViteConfig = (
{ port, name, libName, plugins } = {
port: 3001,
plugins: [],
},
) => {
const filename = isUMD ? `${toLower(name || libName)}.min` : '[name]';

return {
server: {
port,
hmr: true,
},

resolve,

define: {
'process.env.NODE_ENV': JSON.stringify(
isDevMode ? 'development' : 'production',
),
},

plugins: [
peerDepsExternal(),
!isDevMode && viteCommonjs(),
isAnalysisMode &&
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
}),
...plugins,
].filter(Boolean),

css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
modules: {
/**
* 样式小驼峰转化
* css: goods-list => tsx: goodsList
*/
localsConvention: 'camelCase',
},
},

build: {
target: 'es2015',
minify: isUMD ? 'esbuild' : false,
sourcemap: true,
lib: {
name: libName,
entry,
formats: [format],
},
outDir,
rollupOptions: {
output: {
dir: outDir,
entryFileNames: `${filename}.js`,
assetFileNames: `${filename}.[ext]`,
globals: {
vue: 'Vue',
react: 'React',
'react-dom': 'ReactDOM',
'@antv/s2': 'S2',
'@antv/s2-react': 'S2React',
lodash: '_',
antd: 'antd',
'ant-design-vue': 'antd',
},
},
},
},
};
};

return {
entry,
getViteConfig,
define,
format,
resolve,
isAnalysisMode,
outDir,
OUT_DIR_NAME_MAP,
isDevMode,
isUMD,
isESM,
};
};
4 changes: 2 additions & 2 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ module.exports = {
'\\.svg$': 'jest-raw-loader',
},
moduleNameMapper: {
'\\.svg$': '<rootDir>/__tests__/__mocks__/svg.ts',
'^@/(.*)': '<rootDir>/src/$1',
'^tests/(.*)': '<rootDir>/__tests__/$1',
'^@antv/s2$': path.join(__dirname, 'packages/s2-core/src'),
'^@antv/s2-shared$': path.join(__dirname, 'packages/s2-shared/src'),
'^@antv/s2/esm/(.*)$': path.join(__dirname, 'packages/s2-core/src/$1'),
'^@antv/s2-react$': path.join(__dirname, 'packages/s2-react/src'),
'^@antv/s2-react-components$': path.join(
__dirname,
'packages/s2-react-components/src',
),
'\\.svg$': '<rootDir>/__tests__/__mocks__/svg.ts',
/* ignore module query: foo.less?a=1 -> foo.less */
'(.+)\\.(.+)\\?(.*)$': '$1.$2',
},
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"url": "https://github.com/antvis/S2.git"
},
"license": "MIT",
"files": [],
"scripts": {
"preinstall": "npx only-allow pnpm",
"bootstrap": "pnpm install",
Expand All @@ -32,6 +33,7 @@
"core:start": "pnpm --filter @antv/s2 start",
"core:watch": " pnpm --filter @antv/s2 watch",
"core:build": "pnpm --filter @antv/s2 build",
"core:build-esm": "pnpm --filter @antv/s2 build:esm",
"core:test": "pnpm --filter @antv/s2 test",
"core:test-coverage": "pnpm --filter @antv/s2 test:coverage",
"core:sync-event": "pnpm --filter @antv/s2 sync-event",
Expand All @@ -55,7 +57,7 @@
"build:umd": "pnpm -r --filter './packages/*' --stream build:umd",
"build:size-limit": "pnpm -r --filter './packages/*' --stream build:size-limit",
"build:size-limit-json": "pnpm -r --filter './packages/*' --stream build:size-limit-json",
"release": "pnpm -r --filter !@antv/s2-shared --filter !@antv/s2-site --workspace-concurrency=1 exec npx --no-install semantic-release",
"release": "pnpm -r --filter !@antv/s2-site --workspace-concurrency=1 exec npx --no-install semantic-release",
"release:preview": "pnpm release --dry-run --no-ci",
"release:bump-version": "node ./scripts/bump-version.js",
"test": "pnpm -r --filter './packages/*' --stream test",
Expand All @@ -77,7 +79,6 @@
"site:build": "NODE_OPTIONS='--max-old-space-size=4096' pnpm --filter @antv/s2-site build",
"site:preview": "pnpm --filter @antv/s2-site preview",
"site:deploy": "pnpm --filter @antv/s2-site deploy",
"share:test": "pnpm --filter @antv/s2-shared test",
"format": "prettier . --write"
},
"commitlint": {
Expand Down Expand Up @@ -162,7 +163,7 @@
"jest-url-loader": "^0.1.0",
"less": "^4.2.0",
"lint-staged": "^15.2.5",
"lodash-es": "^4.17.21",
"lodash": "^4.17.21",
"markdownlint-cli": "^0.41.0",
"npm-run-all": "^4.1.5",
"ora": "^8.0.1",
Expand Down
Loading

0 comments on commit 64e3882

Please sign in to comment.