mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-23 18:50:06 +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 sylvanas from 'sylvanas';
|
||||
|
||||
import localPackage from '../../package.json';
|
||||
import { dependencies, devDependencies } from '../../package.json';
|
||||
|
||||
function extractEmotionStyle(html: string) {
|
||||
// copy from emotion ssr
|
||||
// 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 result = createEmotionServer(cache).extractCritical(html);
|
||||
if (!result.css) return null;
|
||||
if (!result.css) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { css, ids } = result;
|
||||
|
||||
@ -46,10 +48,7 @@ class AntdReactTechStack extends ReactTechStack {
|
||||
const codePath = opts.fileAbsPath!.replace(/\.\w+$/, '.tsx');
|
||||
const code = fs.existsSync(codePath) ? fs.readFileSync(codePath, 'utf-8') : '';
|
||||
|
||||
props.pkgDependencyList = {
|
||||
...localPackage.devDependencies,
|
||||
...localPackage.dependencies,
|
||||
};
|
||||
props.pkgDependencyList = { ...devDependencies, ...dependencies };
|
||||
props.jsx = sylvanas.parseText(code);
|
||||
|
||||
if (md) {
|
||||
|
@ -5,9 +5,7 @@ import ora from 'ora';
|
||||
import simpleGit from 'simple-git';
|
||||
import type { StatusResult } from 'simple-git';
|
||||
|
||||
import localPackage from '../package.json';
|
||||
|
||||
const { version } = localPackage;
|
||||
import { version } from '../package.json';
|
||||
|
||||
const cwd = process.cwd();
|
||||
const git = simpleGit(cwd);
|
||||
|
@ -5,9 +5,7 @@ import chalk from 'chalk';
|
||||
import dayjs from 'dayjs';
|
||||
import isBetween from 'dayjs/plugin/isBetween';
|
||||
|
||||
import localPackage from '../package.json';
|
||||
|
||||
const { version } = localPackage;
|
||||
import { version } from '../package.json';
|
||||
|
||||
dayjs.extend(isBetween);
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import localPackage from '../package.json';
|
||||
|
||||
const { version } = localPackage;
|
||||
import { version } from '../package.json';
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '..', 'components', 'version', 'version.ts'),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable global-require */
|
||||
import pkg from '../package.json';
|
||||
import { version as packageVersion } from '../package.json';
|
||||
|
||||
const testDist = process.env.LIB_DIR === 'dist';
|
||||
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
|
||||
const antd = require('../dist/antd');
|
||||
expect(antd).toBeTruthy();
|
||||
expect(antd.version).toBe(pkg.version);
|
||||
expect(antd.version).toBe(packageVersion);
|
||||
});
|
||||
|
||||
it('antd.min.js should export version', () => {
|
||||
// eslint-disable-next-line global-require,import/no-unresolved
|
||||
const antd = require('../dist/antd.min');
|
||||
expect(antd).toBeTruthy();
|
||||
expect(antd.version).toBe(pkg.version);
|
||||
expect(antd.version).toBe(packageVersion);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user