Browse Source

Remove babel-plugin-add-module-exports (#8888)

pull/8958/head
Wei Zhu 7 years ago
committed by GitHub
parent
commit
46b45acb12
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      components/calendar/index.tsx
  2. 4
      components/date-picker/__tests__/MonthPicker.test.js
  3. 4
      components/date-picker/__tests__/RangePicker.test.js
  4. 4
      components/date-picker/__tests__/WeekPicker.test.js
  5. 4
      components/date-picker/__tests__/other.test.js
  6. 4
      components/date-picker/__tests__/showTime.test.js
  7. 7
      components/date-picker/wrapPicker.tsx
  8. 2
      index-with-locales.js
  9. 2
      package.json
  10. 7
      site/bisheng.config.js
  11. 2
      tests/shared/demoTest.js

10
components/calendar/index.tsx

@ -6,8 +6,7 @@ import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { PREFIX_CLS } from './Constants';
import Header from './Header';
import callMoment from '../_util/callMoment';
declare const require: Function;
import enUS from './locale/en_US';
export { HeaderProps } from './Header';
@ -122,11 +121,6 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
);
}
getDefaultLocale() {
const locale = require('./locale/en_US');
return locale.default || locale;
}
setValue = (value: moment.Moment, way: 'select' | 'changePanel') => {
if (!('value' in this.props)) {
this.setState({ value });
@ -215,7 +209,7 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
return (
<LocaleReceiver
componentName="Calendar"
defaultLocale={this.getDefaultLocale}
defaultLocale={enUS}
>
{this.renderCalendar}
</LocaleReceiver>

4
components/date-picker/__tests__/MonthPicker.test.js

@ -1,6 +1,8 @@
import { MonthPicker } from '..';
import DatePicker from '..';
import focusTest from '../../../tests/shared/focusTest';
const { MonthPicker } = DatePicker;
describe('MonthPicker', () => {
focusTest(MonthPicker);
});

4
components/date-picker/__tests__/RangePicker.test.js

@ -1,9 +1,11 @@
import React from 'react';
import { mount, render } from 'enzyme';
import moment from 'moment';
import { RangePicker } from '../';
import DatePicker from '../';
import focusTest from '../../../tests/shared/focusTest';
const { RangePicker } = DatePicker;
describe('RangePicker', () => {
focusTest(RangePicker);

4
components/date-picker/__tests__/WeekPicker.test.js

@ -1,6 +1,8 @@
import { WeekPicker } from '..';
import DatePicker from '..';
import focusTest from '../../../tests/shared/focusTest';
const { WeekPicker } = DatePicker;
describe('WeekPicker', () => {
focusTest(WeekPicker);
});

4
components/date-picker/__tests__/other.test.js

@ -1,7 +1,9 @@
import React from 'react';
import { mount, render } from 'enzyme';
import moment from 'moment';
import { MonthPicker, WeekPicker } from '../';
import DatePicker from '../';
const { MonthPicker, WeekPicker } = DatePicker;
describe('MonthPicker and WeekPicker', () => {
it('render MonthPicker', () => {

4
components/date-picker/__tests__/showTime.test.js

@ -1,6 +1,8 @@
import React from 'react';
import { mount } from 'enzyme';
import DatePicker, { RangePicker } from '../';
import DatePicker from '../';
const { RangePicker } = DatePicker;
describe('DatePicker with showTime', () => {
it('should trigger onChange when select value', () => {

7
components/date-picker/wrapPicker.tsx

@ -3,8 +3,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel';
import classNames from 'classnames';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { generateShowHourMinuteSecond } from '../time-picker';
declare const require: Function;
import enUS from './locale/en_US';
function getColumns({ showHour, showMinute, showSecond, use12Hours }: any) {
let column = 0;
@ -81,10 +80,8 @@ export default function wrapPicker(Picker: React.ComponentClass<any>, defaultFor
}
getDefaultLocale = () => {
const locale = require('./locale/en_US');
const defaultlocale = (locale.default || locale);
const result = {
...defaultlocale,
...enUS,
...this.props.locale,
};
result.lang = {

2
index-with-locales.js

@ -5,7 +5,7 @@ antd.locales = {};
req.keys().forEach((mod) => {
const match = mod.match(/\/([^/]+).tsx$/);
antd.locales[match[1]] = req(mod);
antd.locales[match[1]] = req(mod).default;
});
module.exports = antd;

2
package.json

@ -87,7 +87,7 @@
"@types/react": "^16.0.0",
"@types/react-dom": "^16.0.0",
"ansi-styles": "^3.2.0",
"antd-tools": "^4.0.6",
"antd-tools": "^5.0.0",
"babel-cli": "^6.18.0",
"babel-eslint": "^8.1.1",
"babel-plugin-import": "^1.0.0",

7
site/bisheng.config.js

@ -8,7 +8,12 @@ const usePreact = process.env.REACT_ENV === 'preact';
function alertBabelConfig(rules) {
rules.forEach((rule) => {
if (rule.loader && rule.loader === 'babel-loader') {
rule.options.plugins.push(replaceLib);
if (rule.options.plugins.indexOf(replaceLib) === -1) {
rule.options.plugins.push(replaceLib);
}
rule.options.plugins = rule.options.plugins.filter(plugin =>
!plugin.indexOf || plugin.indexOf('babel-plugin-add-module-exports') === -1
);
} else if (rule.use) {
alertBabelConfig(rule.use);
}

2
tests/shared/demoTest.js

@ -12,7 +12,7 @@ export default function demoTest(component, options = {}) {
}
testMethod(`renders ${file} correctly`, () => {
MockDate.set(new Date('2016-11-22').getTime() + (new Date().getTimezoneOffset() * 60 * 1000));
const demo = require(`../.${file}`); // eslint-disable-line global-require, import/no-dynamic-require
const demo = require(`../.${file}`).default; // eslint-disable-line global-require, import/no-dynamic-require
const wrapper = render(demo);
expect(wrapper).toMatchSnapshot();
MockDate.reset();

Loading…
Cancel
Save