Skip to content

Commit e58af92

Browse files
authored
adds src as a module directory and makes it work with rollup (Shopify#2380)
* adds src as a module directory and makes it work with the rollup * fixes types imports * restricts imports to node_modules and /src * fixes ts lint * fixes config and types import
1 parent fada616 commit e58af92

File tree

62 files changed

+76
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+76
-78
lines changed

config/jest/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"\\.svg$": "<rootDir>/config/jest/transformers/svg.js",
1010
"\\.tsx?$": "<rootDir>/config/jest/transformers/typescript.js"
1111
},
12-
"modulePaths": ["<rootDir>"],
12+
"modulePaths": ["<rootDir>/src"],
1313
"moduleNameMapper": {
1414
"\\.(s?css)$": "identity-obj-proxy"
1515
},

config/rollup/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export default function createRollupConfig({
5858
module: true,
5959
jsnext: true,
6060
main: true,
61+
customResolveOptions: {
62+
moduleDirectory: ['./', 'node_modules'],
63+
},
6164
}),
6265
babel({
6366
include: '**/*.js',

playground/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
},
2929
resolve: {
3030
extensions: ['.ts', '.tsx', '.js', '.json'],
31-
modules: ['node_modules', path.resolve(__dirname, '..')],
31+
modules: ['node_modules', path.resolve(__dirname, '..', 'src')],
3232
alias: {
3333
'@shopify/polaris': path.resolve(__dirname, '..', 'src'),
3434
},

shrink-ray-build/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
},
2424
resolve: {
2525
extensions: ['.ts', '.tsx', '.js', '.json'],
26-
modules: ['node_modules', path.resolve(__dirname, '..')],
26+
modules: ['node_modules', path.resolve(__dirname, '..', 'src')],
2727
alias: {
2828
'@shopify/polaris': path.resolve(__dirname, '..', 'src'),
2929
},

src/components/AccountConnection/AccountConnection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
2-
import {Action} from 'src/types';
3-
import {Avatar, buttonFrom, Card, Stack, TextStyle} from 'src/components';
2+
import {Action} from 'types';
3+
import {Avatar, buttonFrom, Card, Stack, TextStyle} from 'components';
44
// eslint-disable-next-line shopify/strict-component-boundaries
5-
import SettingAction from 'src/components/SettingAction';
5+
import SettingAction from 'components/SettingAction';
66
import * as styles from './AccountConnection.scss';
77

88
export interface Props {

src/components/AccountConnection/tests/AccountConnection.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import {noop} from '@shopify/javascript-utilities/other';
33
import {mountWithAppProvider} from 'tests/utilities';
4-
import {Avatar, buttonFrom} from 'src/components';
4+
import {Avatar, buttonFrom} from 'components';
55
import AccountConnection from '../AccountConnection';
66

77
describe('<AccountConnection />', () => {

src/components/ActionList/components/Item/tests/Item.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import {mountWithAppProvider} from 'tests/utilities';
3-
import {UnstyledLink} from 'src/components';
3+
import {UnstyledLink} from 'components';
44
import Item from '../Item';
55

66
describe('<Item />', () => {

src/components/Badge/tests/Badge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import {mountWithAppProvider} from 'tests/utilities';
3-
import {VisuallyHidden} from 'src/components';
3+
import {VisuallyHidden} from 'components';
44
import Badge, {Status, Progress, PROGRESS_LABELS, STATUS_LABELS} from '..';
55

66
describe('<Badge />', () => {

src/components/Banner/tests/Banner.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import {mountWithAppProvider} from 'tests/utilities';
3-
import {Button, Icon, UnstyledLink, Heading} from 'src/components';
3+
import {Button, Icon, UnstyledLink, Heading} from 'components';
44
import Banner from '..';
55

66
import successIcon from '../icons/circle-check-mark.svg';

src/components/Breadcrumbs/tests/Breadcrumbs.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import {noop} from '@shopify/javascript-utilities/other';
33
import {mountWithAppProvider} from 'tests/utilities';
4-
import {CallbackAction, LinkAction} from 'src/types';
4+
import {CallbackAction, LinkAction} from 'types';
55
import Breadcrumbs from '../Breadcrumbs';
66

77
describe('<Breadcrumbs />', () => {

0 commit comments

Comments
 (0)