mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
chore: simplify import expression from package.json (#48602)
This commit is contained in:
parent
8812b14e9d
commit
b9d90f8299
@ -7,14 +7,16 @@ import type { IApi, IRoute } from 'dumi';
|
|||||||
import ReactTechStack from 'dumi/dist/techStacks/react';
|
import ReactTechStack from 'dumi/dist/techStacks/react';
|
||||||
import sylvanas from 'sylvanas';
|
import sylvanas from 'sylvanas';
|
||||||
|
|
||||||
import localPackage from '../../package.json';
|
import { dependencies, devDependencies } from '../../package.json';
|
||||||
|
|
||||||
function extractEmotionStyle(html: string) {
|
function extractEmotionStyle(html: string) {
|
||||||
// copy from emotion ssr
|
// copy from emotion ssr
|
||||||
// https://github.com/vercel/next.js/blob/deprecated-main/examples/with-emotion-vanilla/pages/_document.js
|
// https://github.com/vercel/next.js/blob/deprecated-main/examples/with-emotion-vanilla/pages/_document.js
|
||||||
const styles = global.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__.getCacheList().map((cache) => {
|
const styles = global.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__.getCacheList().map((cache) => {
|
||||||
const result = createEmotionServer(cache).extractCritical(html);
|
const result = createEmotionServer(cache).extractCritical(html);
|
||||||
if (!result.css) return null;
|
if (!result.css) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const { css, ids } = result;
|
const { css, ids } = result;
|
||||||
|
|
||||||
@ -46,10 +48,7 @@ class AntdReactTechStack extends ReactTechStack {
|
|||||||
const codePath = opts.fileAbsPath!.replace(/\.\w+$/, '.tsx');
|
const codePath = opts.fileAbsPath!.replace(/\.\w+$/, '.tsx');
|
||||||
const code = fs.existsSync(codePath) ? fs.readFileSync(codePath, 'utf-8') : '';
|
const code = fs.existsSync(codePath) ? fs.readFileSync(codePath, 'utf-8') : '';
|
||||||
|
|
||||||
props.pkgDependencyList = {
|
props.pkgDependencyList = { ...devDependencies, ...dependencies };
|
||||||
...localPackage.devDependencies,
|
|
||||||
...localPackage.dependencies,
|
|
||||||
};
|
|
||||||
props.jsx = sylvanas.parseText(code);
|
props.jsx = sylvanas.parseText(code);
|
||||||
|
|
||||||
if (md) {
|
if (md) {
|
||||||
|
@ -5,9 +5,7 @@ import ora from 'ora';
|
|||||||
import simpleGit from 'simple-git';
|
import simpleGit from 'simple-git';
|
||||||
import type { StatusResult } from 'simple-git';
|
import type { StatusResult } from 'simple-git';
|
||||||
|
|
||||||
import localPackage from '../package.json';
|
import { version } from '../package.json';
|
||||||
|
|
||||||
const { version } = localPackage;
|
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
const git = simpleGit(cwd);
|
const git = simpleGit(cwd);
|
||||||
|
@ -5,9 +5,7 @@ import chalk from 'chalk';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
|
|
||||||
import localPackage from '../package.json';
|
import { version } from '../package.json';
|
||||||
|
|
||||||
const { version } = localPackage;
|
|
||||||
|
|
||||||
dayjs.extend(isBetween);
|
dayjs.extend(isBetween);
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import localPackage from '../package.json';
|
import { version } from '../package.json';
|
||||||
|
|
||||||
const { version } = localPackage;
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(__dirname, '..', 'components', 'version', 'version.ts'),
|
path.join(__dirname, '..', 'components', 'version', 'version.ts'),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable global-require */
|
/* eslint-disable global-require */
|
||||||
import pkg from '../package.json';
|
import { version as packageVersion } from '../package.json';
|
||||||
|
|
||||||
const testDist = process.env.LIB_DIR === 'dist';
|
const testDist = process.env.LIB_DIR === 'dist';
|
||||||
const testDistMin = process.env.LIB_DIR === 'dist-min';
|
const testDistMin = process.env.LIB_DIR === 'dist-min';
|
||||||
@ -28,14 +28,14 @@ describe('antd dist files', () => {
|
|||||||
// eslint-disable-next-line global-require,import/no-unresolved
|
// eslint-disable-next-line global-require,import/no-unresolved
|
||||||
const antd = require('../dist/antd');
|
const antd = require('../dist/antd');
|
||||||
expect(antd).toBeTruthy();
|
expect(antd).toBeTruthy();
|
||||||
expect(antd.version).toBe(pkg.version);
|
expect(antd.version).toBe(packageVersion);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('antd.min.js should export version', () => {
|
it('antd.min.js should export version', () => {
|
||||||
// eslint-disable-next-line global-require,import/no-unresolved
|
// eslint-disable-next-line global-require,import/no-unresolved
|
||||||
const antd = require('../dist/antd.min');
|
const antd = require('../dist/antd.min');
|
||||||
expect(antd).toBeTruthy();
|
expect(antd).toBeTruthy();
|
||||||
expect(antd.version).toBe(pkg.version);
|
expect(antd.version).toBe(packageVersion);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user