Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tsc): exclude test/stories/mock files only from build #451

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/plugins/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
},
"scripts": {
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc --module esnext --outDir lib/esm",
"build:cjs": "tsc",
"build:esm": "tsc --module esnext --outDir lib/esm --project ./tsconfig.build.json",
"build:cjs": "tsc --project ./tsconfig.build.json",
"test": "NODE_ENV=test jest"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/components/src/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DefaultNavBarContent } from './defaultContent';

export const navBarContentId = 'nav-bar-content';

interface NavBarProps {
export interface NavBarProps {
useCustomContent?: boolean; // rename to show that it is a backNavigation
className?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/components/src/NavBar/navbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
component: NavBar,
} as ComponentMeta<typeof NavBar>;

const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles((_theme: Theme) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

just wonder what is the difference? I saw in the code sometimes we use theme and sometimes use _theme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'_' prefix let compiler now that even though this parameter is not in use at tis point, we want to keep it named in code. Otherwise eslint will complain about unused parameter.

None of used variables should have _ prefix. If variable is not used we can either delete it or add _ prefix.
I decided to add prefix here, as I know that I will use it in my next PR :)

updatedOne: {
backgroundColor: 'lightblue',
color: 'black',
Expand Down
15 changes: 15 additions & 0 deletions packages/plugins/components/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"exclude": [
// files excluded from the build, we can not put it inro default tsconfig
// as it will screw VSCode IntelliSence
"**/test",
"**/mocks",
"**/__mocks__",
"**/__stories__",
"src/**/*.spec.*",
"src/**/*.test.*",
"src/**/*.mock.*",
"src/**/*.stories.*"
]
}
15 changes: 15 additions & 0 deletions packages/zapp/console/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"exclude": [
// files excluded from the build, we can not put it inro default tsconfig
// as it will screw VSCode IntelliSence
"**/test",
"**/mocks",
"**/__mocks__",
"**/__stories__",
"src/**/*.spec.*",
"src/**/*.test.*",
"src/**/*.mock.*",
"src/**/*.stories.*"
]
}
6 changes: 5 additions & 1 deletion packages/zapp/console/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"noImplicitOverride": false
},
"references": [{ "path": "../../plugins/components" }],
"include": ["src/**/*"]
"include": [
"src/**/*",
// TODO: *.json could be removed when tsconfig.build.json would be properly consumed by webpack
"src/**/*.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

just wonder isn't
"src/**/* include "src/**/*.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙃 I know it's sound funky, but no **/* doesn't include *.json files (and some other file types too). It was specifically done by TS - to avoid accidental addition of big files, which are rarely should be part of the project.
As webpack will currently include test/spec/ mock files, we would need to build in few jsons that our tests are relied upon. (for now)

]
}
13 changes: 1 addition & 12 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,5 @@
"@flyteconsole/*": ["./packages/plugins/*/src", "./packages/zapp/*/src"]
}
},
"exclude": [
"**/node_modules",
"**/dist",
"**/lib",
"**/src/**/*.spec.*",
"**/src/**/*.test.*",
"**/src/**/*.stories.*",
// old code patterns
"**/__mocks__",
"**/test",
"**/mocks"
]
"exclude": ["**/node_modules", "**/dist", "**/lib"]
}