Skip to content

Commit

Permalink
fix(components): Import Ant components by their fully qualified name
Browse files Browse the repository at this point in the history
babel-plugin-import doesn't work for dependencies that reside inside vendors bundle, so they need to
be explicitly imported by their fully qualified name. This sucks, so we at least need an tslint rule
in the future.
  • Loading branch information
wms committed Sep 14, 2017
1 parent ab8d660 commit dc0c5ec
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"!**/*.d.ts"
],
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
"moduleNameMapper": {
"\\.less": "<rootDir>/../tools/styleMock.js"
},
"moduleFileExtensions": [
"ts",
"tsx",
Expand Down
8 changes: 7 additions & 1 deletion src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Resource, Form as HALForm } from '@optics/hal-client';
import { Data, Schema } from '@optics/hal-client/dist/Form';
import { Form as AntForm, Button } from 'antd';

import AntForm from 'antd/lib/form';
import 'antd/lib/form/style';

import Button from 'antd/lib/button';
import 'antd/lib/button/style';

import { FormProps as AntFormProps, WrappedFormUtils } from 'antd/lib/form/Form';
import { FormItemProps as AntFormItemProps } from 'antd/lib/form/FormItem';

Expand Down
7 changes: 5 additions & 2 deletions src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Resource, Form as HALForm } from '@optics/hal-client';
import { Alert, Button } from 'antd';
import { AlertProps } from 'antd/lib/alert';

import Alert, { AlertProps } from 'antd/lib/alert';
import 'antd/lib/button/style';
import Button from 'antd/lib/button';
import { ButtonProps } from 'antd/lib/button/button';
import 'antd/lib/button/style';

import { Form as FormComponent } from './Form';
import { SchemaFields } from './SchemaFields';
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import { Row } from 'antd';
import { Resource } from '@optics/hal-client';
import { Transition, TargetState } from '@uirouter/react';

import Row from 'antd/lib/row';
import 'antd/lib/row/style';

import { CredentialStore } from '../CredentialStore';
import { LoginForm } from '../components/LoginForm';

Expand Down
3 changes: 2 additions & 1 deletion src/ui-router.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { UIRouterReact, servicesPlugin, pushStateLocationPlugin } from '@uirouter/react';
import { UIRouterRx } from '@uirouter/rx';
import notification from 'antd/lib/notification';
import * as paramTypes from './ui-router/paramTypes';

import notification from 'antd/lib/notification';
import 'antd/lib/notification/style';

export const buildRouter = (): UIRouterReact => {
Expand Down
3 changes: 3 additions & 0 deletions tools/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Allows jest to handle *.scss imports by returning an empty module

module.exports = {};
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"exclude": [
"**/*.spec.ts",
"**/*.spec.tsx"
"**/*.spec.tsx",
"**/__mocks__/*"
]
}

0 comments on commit dc0c5ec

Please sign in to comment.