mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-29 18:50:00 +08:00
feat: insert use client
automatically at compilations instead of hardcode (#44608)
* feat: remove the hardcode of `use client` * chore: update `@ant-design/tools` * test: update * fix: incorrect dictionary * chore: update dep * ci: check use client * chore: update ci * fix: should be LIB_DIR * ci: should only run in dist * chore: update check tsx files
This commit is contained in:
parent
54316f719c
commit
f0c105d262
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@ -188,6 +188,12 @@ jobs:
|
||||
if: ${{ matrix.module == 'dist' }}
|
||||
run: node ./tests/dekko/dist.test.js
|
||||
|
||||
- name: check use client
|
||||
if: ${{ matrix.module == 'dist' }}
|
||||
run: node ./tests/dekko/use-client.test.js
|
||||
env:
|
||||
LIB_DIR: dist
|
||||
|
||||
# dom test
|
||||
- name: dom test
|
||||
if: ${{ matrix.module == 'dom' }}
|
||||
@ -286,6 +292,10 @@ jobs:
|
||||
|
||||
- name: check
|
||||
run: node ./tests/dekko/lib.test.js
|
||||
|
||||
- name: check use client
|
||||
run: node ./tests/dekko/use-client.test.js
|
||||
|
||||
needs: setup
|
||||
|
||||
compiled-module-test:
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import React, { createRef, forwardRef, useContext } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { AlertProps } from './Alert';
|
||||
import InternalAlert from './Alert';
|
||||
import ErrorBoundary from './ErrorBoundary';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import InternalAnchor from './Anchor';
|
||||
import AnchorLink from './AnchorLink';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { ReactNode } from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { BaseSelectRef } from 'rc-select';
|
||||
import toArray from 'rc-util/lib/Children/toArray';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
|
||||
import type { AvatarProps } from './avatar';
|
||||
import InternalAvatar from './avatar';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import VerticalAlignTopOutlined from '@ant-design/icons/VerticalAlignTopOutlined';
|
||||
import classNames from 'classnames';
|
||||
import CSSMotion from 'rc-motion';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classnames from 'classnames';
|
||||
import CSSMotion from 'rc-motion';
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Breadcrumb from './Breadcrumb';
|
||||
|
||||
export type { BreadcrumbProps } from './Breadcrumb';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Button from './button';
|
||||
|
||||
export type { SizeType as ButtonSize } from '../config-provider/SizeContext';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
|
||||
import type { CalendarProps } from './generateCalendar';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import InternalCard from './Card';
|
||||
import Grid from './Grid';
|
||||
import Meta from './Meta';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import type { Settings } from '@ant-design/react-slick';
|
||||
import SlickCarousel from '@ant-design/react-slick';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import LeftOutlined from '@ant-design/icons/LeftOutlined';
|
||||
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type * as React from 'react';
|
||||
import type { CheckboxProps } from './Checkbox';
|
||||
import InternalCheckbox from './Checkbox';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import { Col, type ColProps, type ColSize } from '../grid';
|
||||
|
||||
export type { ColProps, ColSize };
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Collapse from './Collapse';
|
||||
|
||||
export type { CollapseProps } from './Collapse';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import ColorPicker from './ColorPicker';
|
||||
|
||||
export type { ColorPickerProps } from './ColorPicker';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import { createTheme } from '@ant-design/cssinjs';
|
||||
import IconContext from '@ant-design/icons/lib/components/Context';
|
||||
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
|
||||
import genPurePanel from '../_util/PurePanel';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
/* eslint-disable react/no-array-index-key */
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import warning from '../_util/warning';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { DrawerProps as RcDrawerProps } from 'rc-drawer';
|
||||
import RcDrawer from 'rc-drawer';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import InternalDropdown from './dropdown';
|
||||
import DropdownButton from './dropdown-button';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import { ConfigContext } from '../config-provider';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import BackTop from './BackTop';
|
||||
import FloatButton from './FloatButton';
|
||||
import FloatButtonGroup from './FloatButtonGroup';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { Rule, RuleObject, RuleRender } from 'rc-field-form/lib/interface';
|
||||
import warning from '../_util/warning';
|
||||
import ErrorList, { type ErrorListProps } from './ErrorList';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Col from './col';
|
||||
import useInternalBreakpoint from './hooks/useBreakpoint';
|
||||
import Row from './row';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import EyeOutlined from '@ant-design/icons/EyeOutlined';
|
||||
import classNames from 'classnames';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
export type { Breakpoint } from './_util/responsiveObserver';
|
||||
export { default as Affix } from './affix';
|
||||
export type { AffixProps } from './affix';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import DownOutlined from '@ant-design/icons/DownOutlined';
|
||||
import UpOutlined from '@ant-design/icons/UpOutlined';
|
||||
import classNames from 'classnames';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type * as React from 'react';
|
||||
import Group from './Group';
|
||||
import type { InputProps, InputRef } from './Input';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import InternalLayout, { Content, Footer, Header } from './layout';
|
||||
import Sider from './Sider';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
||||
import * as React from 'react';
|
||||
import warning from '../_util/warning';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import RcMentions from 'rc-mentions';
|
||||
import type {
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { MenuRef as RcMenuRef } from 'rc-menu';
|
||||
import { ItemGroup } from 'rc-menu';
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { render } from 'rc-util/lib/React/render';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { ModalStaticFunctions } from './confirm';
|
||||
import confirm, {
|
||||
modalGlobalConfig,
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { render } from 'rc-util/lib/React/render';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Pagination from './Pagination';
|
||||
|
||||
export type { PaginationConfig, PaginationProps } from './Pagination';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';
|
||||
import classNames from 'classnames';
|
||||
import KeyCode from 'rc-util/lib/KeyCode';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import type { RenderFunction } from '../_util/getRenderPropValue';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Progress from './progress';
|
||||
|
||||
export type { ProgressAriaProps, ProgressProps } from './progress';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import ReloadOutlined from '@ant-design/icons/ReloadOutlined';
|
||||
import classNames from 'classnames';
|
||||
import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type * as React from 'react';
|
||||
import Group from './group';
|
||||
import type { RadioProps } from './interface';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import StarFilled from '@ant-design/icons/StarFilled';
|
||||
import classNames from 'classnames';
|
||||
import RcRate from 'rc-rate';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';
|
||||
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
|
||||
import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import { Row, type RowProps } from '../grid';
|
||||
|
||||
export type { RowProps };
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type {
|
||||
SegmentedLabeledOption as RcSegmentedLabeledOption,
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
// TODO: 4.0 - codemod should help to change `filterOption` to support node props.
|
||||
import classNames from 'classnames';
|
||||
import type { BaseSelectRef, SelectProps as RcSelectProps } from 'rc-select';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Skeleton from './Skeleton';
|
||||
|
||||
export type { SkeletonProps } from './Skeleton';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { SliderProps as RcSliderProps } from 'rc-slider';
|
||||
import RcSlider from 'rc-slider';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import toArray from 'rc-util/lib/Children/toArray';
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import omit from 'rc-util/lib/omit';
|
||||
import * as React from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { CountdownProps } from './Countdown';
|
||||
import Countdown from './Countdown';
|
||||
import type { StatisticProps } from './Statistic';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import CheckOutlined from '@ant-design/icons/CheckOutlined';
|
||||
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
||||
import classNames from 'classnames';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import type { CSSObject } from '@ant-design/cssinjs';
|
||||
import type { AliasToken, DerivativeToken } from '../theme/internal';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
||||
import classNames from 'classnames';
|
||||
import RcSwitch from 'rc-switch';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import { type TablePaginationConfig, type TableProps } from './InternalTable';
|
||||
import Table from './Table';
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
||||
import EllipsisOutlined from '@ant-design/icons/EllipsisOutlined';
|
||||
import PlusOutlined from '@ant-design/icons/PlusOutlined';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
||||
import classNames from 'classnames';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import getDesignToken from './getDesignToken';
|
||||
import type { GlobalToken, MappingAlgorithm } from './interface';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import * as React from 'react';
|
||||
import genPurePanel from '../_util/PurePanel';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Timeline from './Timeline';
|
||||
|
||||
export type { TimelineProps } from './Timeline';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type { BuildInPlacements } from '@rc-component/trigger';
|
||||
import classNames from 'classnames';
|
||||
import RcTooltip from 'rc-tooltip';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import RCTour from '@rc-component/tour';
|
||||
import classNames from 'classnames';
|
||||
import React, { useContext } from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { ChangeEvent, CSSProperties } from 'react';
|
||||
import React, { useCallback, useContext } from 'react';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import type { BaseSelectRef } from 'rc-select';
|
||||
import type { Placement } from 'rc-select/lib/BaseSelect';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import type RcTree from 'rc-tree';
|
||||
import type { BasicDataNode } from 'rc-tree';
|
||||
import { TreeNode } from 'rc-tree';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Link from './Link';
|
||||
import Paragraph from './Paragraph';
|
||||
import Text from './Text';
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use client';
|
||||
|
||||
import Dragger from './Dragger';
|
||||
import type { UploadProps } from './Upload';
|
||||
import InternalUpload, { LIST_IGNORE } from './Upload';
|
||||
|
@ -161,7 +161,7 @@
|
||||
"devDependencies": {
|
||||
"@ant-design/compatible": "^5.1.2",
|
||||
"@ant-design/happy-work-theme": "^1.0.0",
|
||||
"@ant-design/tools": "^17.0.0",
|
||||
"@ant-design/tools": "^17.3.1",
|
||||
"@antv/g6": "^4.8.13",
|
||||
"@argos-ci/core": "^0.9.0",
|
||||
"@babel/eslint-plugin": "^7.19.1",
|
||||
|
32
tests/dekko/use-client.test.js
Normal file
32
tests/dekko/use-client.test.js
Normal file
@ -0,0 +1,32 @@
|
||||
const $ = require('dekko');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
|
||||
const includeUseClient = (filename) =>
|
||||
fs.readFileSync(filename).toString().includes('"use client"');
|
||||
|
||||
if (process.env.LIB_DIR === 'dist') {
|
||||
$('dist/*')
|
||||
.isFile()
|
||||
.assert("doesn't contain use client", (filename) => !includeUseClient(filename));
|
||||
} else {
|
||||
$('{es,lib}/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
$('{es,lib}/*/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
// check tsx files
|
||||
$('{es,lib}/typography/*.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
$('{es,lib}/typography/Base/*.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.green('✨ use client passed!'));
|
Loading…
Reference in New Issue
Block a user