Skip to content

Commit

Permalink
[tsconfig] Remove base url from tsconfig + src -> shared (#23505)
Browse files Browse the repository at this point in the history
I added `baseUrl` to make `src/...` imports work in OSS, instead of
using baseUrl lets use paths with a regex.

This makes it so that we stop automatically recommending imports that
start with "src/..."

#### Test Plan
yarn ts
  • Loading branch information
salazarm authored Aug 8, 2024
1 parent e799f5a commit 7bbbc31
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion js_modules/dagster-ui/packages/app-oss/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"paths": {
"@dagster-io/ui-core/*": ["../ui-core/src/*"],
"@dagster-io/ui-components": ["../ui-components/src"],
"src/*": ["../ui-core/src/*"]
"shared/*": ["../ui-core/src/*"]
},
"module": "esnext",
"target": "es2022",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ module.exports = {
node,
message: 'Relative importing files that end with ".oss" is not allowed.',
fix: (fixer) => {
const absolutePath = path.relative(
context.getCwd(),
path.resolve(path.dirname(context.getFilename()), node.source.value),
);
const absolutePath = path
.relative(
context.getCwd(),
path.resolve(path.dirname(context.getFilename()), node.source.value),
)
.replace(/^src/, 'shared');
return fixer.replaceText(node.source, `'${absolutePath}'`);
},
});
Expand All @@ -37,10 +39,12 @@ module.exports = {
node,
message: 'Relative dynamic importing files that end with ".oss.tsx" is not allowed.',
fix: (fixer) => {
const absolutePath = path.relative(
context.getCwd(),
path.resolve(path.dirname(context.getFilename()), node.source.value),
);
const absolutePath = path
.relative(
context.getCwd(),
path.resolve(path.dirname(context.getFilename()), node.source.value),
)
.replace(/^src/, 'shared');
return fixer.replaceText(node.source, `'${absolutePath}'`);
},
});
Expand Down
2 changes: 1 addition & 1 deletion js_modules/dagster-ui/packages/ui-core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = {
'\\.(css|less)$': 'identity-obj-proxy',
'^worker-loader(.*)/workers/(.*)$': '<rootDir>/jest/mocks/$2',
'^@dagster-io/ui-components$': '<rootDir>/../ui-components/src/index',
'^src/(.*)$': '<rootDir>/src/$1',
'^shared/(.*)$': '<rootDir>/src/$1',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Box, Colors, Icon, IconWrapper, Tooltip} from '@dagster-io/ui-components';
import * as React from 'react';
import {Link, NavLink} from 'react-router-dom';
import {AppTopNavRightOfLogo} from 'src/app/AppTopNav/AppTopNavRightOfLogo.oss';
import {AppTopNavRightOfLogo} from 'shared/app/AppTopNav/AppTopNavRightOfLogo.oss';
import styled from 'styled-components';

import {VersionNumber} from '../../nav/VersionNumber';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ErrorBoundary, MainContent} from '@dagster-io/ui-components';
import {memo, useEffect, useRef} from 'react';
import {Switch, useLocation} from 'react-router-dom';
import {AssetsOverviewRoot} from 'src/assets/AssetsOverviewRoot.oss';
import {AssetsOverviewRoot} from 'shared/assets/AssetsOverviewRoot.oss';

import {Route} from './Route';
import {AssetFeatureProvider} from '../assets/AssetFeatureContext';
Expand All @@ -11,7 +11,7 @@ const WorkspaceRoot = lazy(() => import('../workspace/WorkspaceRoot'));
const OverviewRoot = lazy(() => import('../overview/OverviewRoot'));
const AutomationRoot = lazy(() => import('../automation/AutomationRoot'));
const FallthroughRoot = lazy(() =>
import('src/app/FallthroughRoot.oss').then((mod) => ({default: mod.FallthroughRoot})),
import('shared/app/FallthroughRoot.oss').then((mod) => ({default: mod.FallthroughRoot})),
);
const AssetsGroupsGlobalGraphRoot = lazy(() => import('../assets/AssetsGroupsGlobalGraphRoot'));
const CodeLocationsPage = lazy(() => import('../instance/CodeLocationsPage'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Tooltip,
} from '@dagster-io/ui-components';
import * as React from 'react';
import {UserPreferences} from 'src/app/UserSettingsDialog/UserPreferences.oss';
import {UserPreferences} from 'shared/app/UserSettingsDialog/UserPreferences.oss';

import {CodeLinkProtocolSelect} from '../../code-links/CodeLinkProtocol';
import {FeatureFlagType, getFeatureFlags, setFeatureFlags} from '../Flags';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import uniq from 'lodash/uniq';
import without from 'lodash/without';
import * as React from 'react';
import {useMemo} from 'react';
import {useAssetGraphExplorerFilters} from 'src/asset-graph/useAssetGraphExplorerFilters.oss';
import {AssetFilterState} from 'src/assets/useAssetDefinitionFilterState.oss';
import {useAssetGraphExplorerFilters} from 'shared/asset-graph/useAssetGraphExplorerFilters.oss';
import {AssetFilterState} from 'shared/assets/useAssetDefinitionFilterState.oss';
import styled from 'styled-components';

import {AssetEdges} from './AssetEdges';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useContext, useEffect, useState} from 'react';
import {AssetFilterState} from 'src/assets/useAssetDefinitionFilterState.oss';
import {AssetFilterState} from 'shared/assets/useAssetDefinitionFilterState.oss';

import {AssetGraphFilterBar} from './AssetGraphFilterBar';
import {GraphNode} from './Utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {gql, useQuery} from '@apollo/client';
import {Box, Heading, Page, PageHeader, Tabs, Tag} from '@dagster-io/ui-components';
import React, {useCallback, useMemo} from 'react';
import {useHistory, useParams} from 'react-router-dom';
import {AssetGlobalLineageLink} from 'src/assets/AssetPageHeader.oss';
import {useAssetDefinitionFilterState} from 'src/assets/useAssetDefinitionFilterState.oss';
import {AssetGlobalLineageLink} from 'shared/assets/AssetPageHeader.oss';
import {useAssetDefinitionFilterState} from 'shared/assets/useAssetDefinitionFilterState.oss';

import {AssetsCatalogTable} from './AssetsCatalogTable';
import {useAutoMaterializeSensorFlag} from './AutoMaterializeSensorFlag';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import groupBy from 'lodash/groupBy';
import * as React from 'react';
import {useContext, useMemo} from 'react';
import {AssetWipeDialog} from 'src/assets/AssetWipeDialog.oss';
import {AssetWipeDialog} from 'shared/assets/AssetWipeDialog.oss';

import {LaunchAssetExecutionButton} from './LaunchAssetExecutionButton';
import {AssetTableFragment} from './types/AssetTableFragment.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Alert, Box, ErrorBoundary, NonIdealState, Spinner, Tag} from '@dagster-i
import {useContext, useEffect, useMemo} from 'react';
import {Link, Redirect, useLocation, useRouteMatch} from 'react-router-dom';
import {useSetRecoilState} from 'recoil';
import {AssetPageHeader} from 'src/assets/AssetPageHeader.oss';
import {AssetPageHeader} from 'shared/assets/AssetPageHeader.oss';

import {AssetEvents} from './AssetEvents';
import {AssetFeatureContext} from './AssetFeatureContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as React from 'react';
import {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useState} from 'react';
import {useRouteMatch} from 'react-router-dom';
import {useSetRecoilState} from 'recoil';
import {AssetCatalogTableBottomActionBar} from 'src/assets/AssetCatalogTableBottomActionBar.oss';
import {useAssetCatalogFiltering} from 'src/assets/useAssetCatalogFiltering.oss';
import {AssetCatalogTableBottomActionBar} from 'shared/assets/AssetCatalogTableBottomActionBar.oss';
import {useAssetCatalogFiltering} from 'shared/assets/useAssetCatalogFiltering.oss';

import {AssetTable} from './AssetTable';
import {ASSET_TABLE_DEFINITION_FRAGMENT, ASSET_TABLE_FRAGMENT} from './AssetTableFragment';
Expand Down Expand Up @@ -222,8 +222,6 @@ export const AssetsCatalogTable = ({
leading: true,
});

const loaded = !!assets;

React.useEffect(() => {
if (view !== 'directory' && prefixPath.length) {
setView('directory');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Page} from '@dagster-io/ui-components';
import {useCallback, useMemo} from 'react';
import {useHistory, useParams} from 'react-router-dom';
import {AssetsGraphHeader} from 'src/assets/AssetsGraphHeader.oss';
import {useAssetDefinitionFilterState} from 'src/assets/useAssetDefinitionFilterState.oss';
import {AssetsGraphHeader} from 'shared/assets/AssetsGraphHeader.oss';
import {useAssetDefinitionFilterState} from 'shared/assets/useAssetDefinitionFilterState.oss';

import {assetDetailsPathForKey} from './assetDetailsPathForKey';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {BreadcrumbProps} from '@blueprintjs/core';
import {Box} from '@dagster-io/ui-components';
import React, {useMemo} from 'react';
import {useHistory, useParams} from 'react-router-dom';
import {AssetGlobalLineageLink, AssetPageHeader} from 'src/assets/AssetPageHeader.oss';
import {AssetGlobalLineageLink, AssetPageHeader} from 'shared/assets/AssetPageHeader.oss';

import {AssetView} from './AssetView';
import {AssetsCatalogTable} from './AssetsCatalogTable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AssetFilterBaseType,
AssetFilterType,
filterAssetDefinition,
} from 'src/assets/useAssetDefinitionFilterState.oss';
} from 'shared/assets/useAssetDefinitionFilterState.oss';

import {
ChangeReason,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {TextInput} from '@dagster-io/ui-components';
import * as React from 'react';
import {useMemo} from 'react';
import {useAssetDefinitionFilterState} from 'src/assets/useAssetDefinitionFilterState.oss';
import {useAssetDefinitionFilterState} from 'shared/assets/useAssetDefinitionFilterState.oss';

import {useAssetGroupSelectorsForAssets} from './AssetGroupSuggest';
import {AssetTableFragment} from './types/AssetTableFragment.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Colors, Icon, MenuDivider, MenuItem} from '@dagster-io/ui-components';
import {useContext, useState} from 'react';
import {AssetWipeDialog} from 'src/assets/AssetWipeDialog.oss';
import {AssetWipeDialog} from 'shared/assets/AssetWipeDialog.oss';

import {CloudOSSContext} from '../app/CloudOSSContext';
import {usePermissionsForLocation} from '../app/Permissions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const OverviewAssetsRoot = ({Header, TabButton}: Props) => {
() => groupedAssets.flatMap((group) => group.assets.map((asset) => asset.key)) ?? [],
[groupedAssets],
);
const {liveDataByNode} = useAssetsBaseData(orderedAssets, 'OverviewAssetsRoot');
useAssetsBaseData(orderedAssets, 'OverviewAssetsRoot');

const parentRef = React.useRef<HTMLDivElement | null>(null);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Box, Heading, PageHeader} from '@dagster-io/ui-components';
import React from 'react';
import {OverviewPageAlerts} from 'src/overview/OverviewPageAlerts.oss';
import {OverviewPageAlerts} from 'shared/overview/OverviewPageAlerts.oss';

import {OverviewTabs} from './OverviewTabs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@dagster-io/ui-components';
import * as React from 'react';
import {Link} from 'react-router-dom';
import {RunMetricsDialog} from 'src/runs/RunMetricsDialog.oss';
import {RunMetricsDialog} from 'shared/runs/RunMetricsDialog.oss';
import styled from 'styled-components';

import {DeletionDialog} from './DeletionDialog';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useMutation} from '@apollo/client';
import {Button, Group, Icon, Menu, MenuItem, Popover, Tooltip} from '@dagster-io/ui-components';
import {useContext, useState} from 'react';
import {useHistory} from 'react-router-dom';
import {RunMetricsDialog} from 'src/runs/RunMetricsDialog.oss';
import {RunMetricsDialog} from 'shared/runs/RunMetricsDialog.oss';

import {DeletionDialog} from './DeletionDialog';
import {QueuedRunCriteriaDialog} from './QueuedRunCriteriaDialog';
Expand Down
4 changes: 2 additions & 2 deletions js_modules/dagster-ui/packages/ui-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@dagster-io/ui-components": ["../ui-components/src"]
"@dagster-io/ui-components": ["../ui-components/src"],
"shared/*": ["./src/*"]
},
"module": "es2022",
"target": "es2022",
Expand Down

1 comment on commit 7bbbc31

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-53i2ks6gs-elementl.vercel.app

Built with commit 7bbbc31.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.