Browse Source

refactor: keep index.js as entry (#3397)

pull/3658/head
偏右 8 years ago
committed by Benjy Cui
parent
commit
1deea83a05
  1. 9
      components/index.tsx
  2. 35
      index.js
  3. 2
      package.json
  4. 6
      typings/custom-typings.d.ts

9
components/index.tsx

@ -1,3 +1,12 @@
/* eslint no-console:0 */
// this file is not used if use https://github.com/ant-design/babel-plugin-import
if (process.env.NODE_ENV !== 'production') {
if (typeof console !== 'undefined' && console.warn) {
console.warn(`You are using prebuilt antd,
please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.`);
}
}
export { default as Affix } from './affix';
export { default as AutoComplete } from './auto-complete';

35
index.js

@ -1,34 +1 @@
/* eslint no-console:0 */
// this file is not used if use https://github.com/ant-design/babel-plugin-import
function camelCase(name) {
return name.charAt(0).toUpperCase() +
name.slice(1).replace(/-(\w)/g, (m, n) => {
return n.toUpperCase();
});
}
const req = require.context('./components', true, /^\.\/[^_][\w-]+\/(style\/)?index\.tsx?$/);
req.keys().forEach((mod) => {
let v = req(mod);
if (v && v.default) {
v = v.default;
}
const match = mod.match(/^\.\/([^_][\w-]+)\/index\.tsx?$/);
if (match && match[1]) {
if (match[1] === 'message' || match[1] === 'notification') {
// message & notification should not be capitalized
exports[match[1]] = v;
} else {
exports[camelCase(match[1])] = v;
}
}
});
if (process.env.NODE_ENV !== 'production') {
if (typeof console !== 'undefined' && console.warn) {
console.warn(`You are using prebuilt antd,
please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.`);
}
}
module.exports = require('./components');

2
package.json

@ -25,7 +25,7 @@
"bugs": {
"url": "https://github.com/ant-design/ant-design/issues"
},
"main": "dist/antd",
"main": "lib/index.js",
"files": [
"dist",
"lib"

6
typings/custom-typings.d.ts

@ -75,3 +75,9 @@ declare module 'rc-upload';
declare module 'rc-collapse';
declare module 'rc-form*';
declare var process: {
env: {
NODE_ENV: string
}
};

Loading…
Cancel
Save