mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
refactor: keep index.js as entry (#3397)
This commit is contained in:
@@ -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
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');
|
||||
|
||||
@@ -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
vendored
6
typings/custom-typings.d.ts
vendored
@@ -75,3 +75,9 @@ declare module 'rc-upload';
|
||||
declare module 'rc-collapse';
|
||||
|
||||
declare module 'rc-form*';
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
NODE_ENV: string
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user