Minor changes with webpack optimisation (#1949)

This commit is contained in:
darth-coder00 2021-12-28 23:16:52 +05:30 committed by GitHub
parent 86fb5bbc1b
commit 5fb63c3019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 62 additions and 23313 deletions

View File

@ -60,3 +60,9 @@ build_docker_connectors:
push_docker_connectors:
@echo "Pushing Docker connectors. Make sure to run build_docker_connectors first"
python ingestion/connectors/docker-cli.py push
yarn_install_cache:
cd openmetadata-ui/src/main/resources/ui && yarn install --frozen-lockfile
yarn_start_dev_ui:
cd openmetadata-ui/src/main/resources/ui && yarn start

View File

@ -110,17 +110,17 @@
</goals>
<configuration>
<nodeVersion>v12.22.1</nodeVersion>
<yarnVersion>v1.22.10</yarnVersion>
<yarnVersion>v1.22.17</yarnVersion>
</configuration>
</execution>
<execution>
<id>yarn install --immutable</id>
<id>yarn install --frozen-lockfile</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<arguments>install --immutable</arguments>
<arguments>install --frozen-lockfile</arguments>
</configuration>
</execution>
<execution>

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
"private": true,
"engines": {
"node": ">=10.0.0",
"npm": "^6.0.0"
"yarn": "^1.22.0"
},
"repository": {
"type": "git",
@ -12,8 +12,8 @@
"directory": "openmetadata-ui/src/main/resources/ui"
},
"dependencies": {
"@deuex-solutions/redoc": "2.0.0-rc.31",
"@deuex-solutions/react-tutorial": "1.0.0",
"@deuex-solutions/redoc": "2.0.0-rc.31",
"autoprefixer": "^9.8.6",
"axios": "^0.21.1",
"babel-plugin-named-asset-import": "^0.3.6",
@ -70,8 +70,7 @@
"scripts": {
"start": "NODE_ENV=development BABEL_ENV=development webpack serve --config ./webpack.config.dev.js --env development",
"build": "NODE_ENV=production BABEL_ENV=production webpack --config ./webpack.config.prod.js --env production",
"postbuild": "rm -rf ./dist/ && mkdir -p ./dist/assets && mv build/* ./dist/assets/",
"preinstall": "cd ../../../../.. && yarn install --immutable",
"preinstall": "cd ../../../../.. && yarn install --frozen-lockfile",
"test": "jest --passWithNoTests --watch",
"test:nowatch": "jest --passWithNoTests",
"lint": "eslint \"./src/**/*.{js,jsx,ts,tsx}\"",
@ -109,6 +108,7 @@
"@types/codemirror": "^0.0.104",
"@types/jest": "^26.0.23",
"@types/lodash": "^4.14.167",
"@types/node": "^15.6.1",
"@types/react": "^17.0.8",
"@types/react-dom": "^17.0.11",
"@types/react-router-dom": "^5.1.7",
@ -116,7 +116,6 @@
"@types/react-test-renderer": "^17.0.0",
"@types/reactjs-localstorage": "^1.0.0",
"@types/testing-library__jest-dom": "^5.9.5",
"@types/node": "^15.6.1",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"babel-eslint": "^10.1.0",
@ -129,14 +128,14 @@
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "^3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jest-formatting": "^3.0.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^1.6.1",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jest-formatting": "^3.0.0",
"file-loader": "4.3.0",
"fork-ts-checker-webpack-plugin": "^6.0.8",
"html-webpack-plugin": "^4.5.1",

View File

@ -99,7 +99,7 @@ const MyData: React.FC<MyDataProps> = ({
const getLeftPanel = () => {
return (
<div className="tw-mt-5">
<div className="tw-mt-12">
<MyAssetStats
countServices={countServices}
entityCounts={entityCounts}
@ -116,7 +116,7 @@ const MyData: React.FC<MyDataProps> = ({
const getRightPanel = useCallback(() => {
return (
<div className="tw-mt-5">
<div className="tw-mt-12">
<EntityList
entityList={ownedData}
headerText={
@ -126,7 +126,7 @@ const MyData: React.FC<MyDataProps> = ({
<Link
data-testid="my-data"
to={getLinkByFilter(Ownership.OWNER)}>
<span className="link-text tw-font-light tw-text-xs">
<span className="link-text tw-font-normal tw-text-xs">
View All
</span>
</Link>
@ -146,7 +146,7 @@ const MyData: React.FC<MyDataProps> = ({
<Link
data-testid="following-data"
to={getLinkByFilter(Ownership.FOLLOWERS)}>
<span className="link-text tw-font-light tw-text-xs">
<span className="link-text tw-font-normal tw-text-xs">
View All
</span>
</Link>

View File

@ -1,35 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
const IconButton = ({ icon, onClick, title }) => {
return (
<div
className="icon-button"
data-testid="icon-button"
title={title}
onClick={onClick}>
{icon}
</div>
);
};
IconButton.propTypes = {
icon: PropTypes.node.isRequired,
onClick: PropTypes.func,
title: PropTypes.string,
};
export default IconButton;

View File

@ -1,49 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import SVGIcons, { Icons } from '../../utils/SvgUtils';
import IconButton from './IconButton';
const mockFunction = jest.fn();
const icon = <SVGIcons alt="Edit" icon={Icons.EDIT} />;
describe('Test Icon Button Component', () => {
it('Component should render', () => {
const { getByTestId } = render(
<IconButton icon={icon} title="test" onClick={mockFunction} />
);
const iconButton = getByTestId('icon-button');
expect(iconButton).toBeInTheDocument();
});
it('OnClick callback function should call', () => {
const { getByTestId } = render(
<IconButton icon={icon} title="test" onClick={mockFunction} />
);
const iconButton = getByTestId('icon-button');
fireEvent(
iconButton,
new MouseEvent('click', {
bubbles: true,
cancelable: true,
})
);
expect(mockFunction).toHaveBeenCalledTimes(1);
});
});

View File

@ -40,8 +40,8 @@ const FeedCards: FC<FeedCardsProp> = ({
return (
<div id="feedData">
{relativeDays.map((d, i) => (
<div className="tw-grid tw-grid-rows-1 tw-grid-cols-1 tw-mt-3" key={i}>
<div className="tw-relative tw-mt-3 tw-mb-3.5">
<div className="tw-grid tw-grid-rows-1 tw-grid-cols-1" key={i}>
<div className="tw-relative tw-mt-1 tw-mb-3.5">
<div className="tw-flex tw-justify-center">
<hr className="tw-absolute tw-top-3 tw-border-b-2 tw-border-main tw-w-full tw-z-0" />
<span className="tw-bg-white tw-px-4 tw-py-px tw-border tw-border-primary tw-rounded tw-z-10 tw-text-primary tw-font-medium">

View File

@ -1,55 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
import StepConnector from './StepConnector';
import StepIcon from './StepIcon';
import StepLabel from './StepLabel';
const Step = ({
activeStep,
index,
name,
totalSteps,
isVertical,
showStepNumber,
}) => {
return (
<div
className={`step-${
index < activeStep ? 'done' : activeStep === index ? 'doing' : 'pending'
} step`}
data-testid="step"
key={name}>
{index > 0 && index < totalSteps && (
<StepConnector isVertical={isVertical} />
)}
<span className="step-container">
<StepIcon stepNumber={showStepNumber ? index + 1 : null} />
<StepLabel name={name} />
</span>
</div>
);
};
Step.propTypes = {
activeStep: PropTypes.number.isRequired,
index: PropTypes.number.isRequired,
name: PropTypes.string,
totalSteps: PropTypes.number.isRequired,
isVertical: PropTypes.bool,
showStepNumber: PropTypes.bool,
};
export default Step;

View File

@ -1,33 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
const StepConnector = ({ isVertical }) => {
return (
<div className="step-connector">
<span
className={`step-connector-line line-${
isVertical ? 'vertical' : 'horizontal'
}`}
/>
</div>
);
};
StepConnector.propTypes = {
isVertical: PropTypes.bool,
};
export default StepConnector;

View File

@ -1,29 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
const StepIcon = ({ stepNumber }) => {
return (
<span className="step-icon" data-testid="step-icon">
{stepNumber}
</span>
);
};
StepIcon.propTypes = {
stepNumber: PropTypes.number,
};
export default StepIcon;

View File

@ -1,25 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
const StepLabel = ({ name }) => {
return name ? <span className="step-label">{name}</span> : null;
};
StepLabel.propTypes = {
name: PropTypes.string,
};
export default StepLabel;

View File

@ -1,55 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PropTypes from 'prop-types';
import React from 'react';
import Step from './Step';
const Stepper = ({ steps, isVertical, activeStep, showStepNumber }) => {
return (
<div
className={`stepper-list stepper-${
isVertical ? 'vertical' : 'horizontal'
}`}>
{steps.map(({ name }, index) => (
<Step
activeStep={activeStep}
index={index}
isVertical={isVertical}
key={index}
name={name}
showStepNumber={showStepNumber}
totalSteps={steps.length}
/>
))}
</div>
);
};
Stepper.defaultProps = {
activeStep: 0,
showStepNumber: true,
};
Stepper.propTypes = {
steps: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string,
})
).isRequired,
isVertical: PropTypes.bool,
activeStep: PropTypes.number,
showStepNumber: PropTypes.bool,
};
export default Stepper;

View File

@ -1,64 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { render } from '@testing-library/react';
import React from 'react';
import Stepper from '.';
describe('Test Stepper Component', () => {
it('Should render all the steps', async () => {
const { findByText, getAllByTestId } = render(
<Stepper steps={[{ name: 'step-1' }, { name: 'step-2' }]} />
);
const step1 = await findByText(/step-1/);
const step2 = await findByText(/step-2/);
const step1Icon = await findByText('1');
const step2Icon = await findByText('2');
expect(step1).toBeInTheDocument();
expect(step2).toBeInTheDocument();
expect(step1Icon).toBeInTheDocument();
expect(step2Icon).toBeInTheDocument();
const steps = getAllByTestId('step');
expect(steps[0]).toHaveClass('step-doing');
expect(steps[1]).toHaveClass('step-pending');
});
it('Should render without step numbers', () => {
const { getAllByTestId } = render(
<Stepper
showStepNumber={false}
steps={[{ name: 'step-1' }, { name: 'step-2' }]}
/>
);
const stepIcons = getAllByTestId('step-icon');
expect(stepIcons.map((icon) => icon.textContent)).toEqual(['', '']);
});
it('Should render steps with active step 1', () => {
const { getAllByTestId } = render(
<Stepper
activeStep={1}
steps={[{ name: 'step-1' }, { name: 'step-2' }]}
/>
);
const steps = getAllByTestId('step');
expect(steps[0]).toHaveClass('step-done');
expect(steps[1]).toHaveClass('step-doing');
});
});

View File

@ -43,7 +43,7 @@ module.exports = {
// .js and .jsx files to be handled by babel-loader
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
use: {
loader: 'babel-loader',
options: {
@ -58,7 +58,7 @@ module.exports = {
options: {
transpileOnly: true, // Speed up compilation in development mode
},
exclude: /node_modules/, // Just the source code
include: path.resolve(__dirname, 'src'), // Just the source code
},
// .css and .scss files to be handled by sass-loader
// include scss rule and sass-loader if injecting scss/sass file
@ -76,14 +76,21 @@ module.exports = {
},
'postcss-loader',
],
// No exclude, may need to handle files outside the source code
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/tailwindcss'),
path.resolve(__dirname, 'node_modules/react-tippy'),
path.resolve(__dirname, 'node_modules/react-draft-wysiwyg'),
path.resolve(__dirname, 'node_modules/codemirror'),
],
// May need to handle files outside the source code
// (from node_modules)
},
// .svg files to be handled by @svgr/webpack
{
test: /\.svg$/,
use: ['@svgr/webpack'],
exclude: /node_modules/, // Just the source code
include: path.resolve(__dirname, 'src'), // Just the source code
},
// different urls to be handled by url-loader
{
@ -97,21 +104,10 @@ module.exports = {
},
},
],
exclude: /node_modules/, // Just the source code
},
// different urls to be handled by url-loader in node_modules
{
test: /\.(png|jpg|jpeg|gif|svg|ico|eot|woff|woff2)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
name: `[name].[ext]`,
},
},
],
include: /node_modules\/slick-carousel/, // Just slick-carousel from node_modules
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/slick-carousel'),
], // Just the source code
},
// Font files to be handled by file-loader
{
@ -125,21 +121,10 @@ module.exports = {
},
},
],
exclude: /node_modules/, // Just the source code
},
// Font files to be handled by file-loader in node_modules
{
test: /\.ttf$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
include: /node_modules\/slick-carousel/, // Just slick-carousel from node_modules
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/slick-carousel'),
], // Just the source code
},
],
},

View File

@ -21,7 +21,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const outputPath = path.join(__dirname, 'build');
const outputPath = path.join(__dirname, 'dist/assets');
module.exports = {
// Production mode
@ -33,7 +33,7 @@ module.exports = {
// Output configuration
output: {
path: outputPath,
filename: 'openmetadata.js',
filename: 'openmetadata.bundle.js',
chunkFilename: '[name].js',
publicPath: '/', // Ensures bundle is served from absolute path as opposed to relative
},
@ -44,7 +44,7 @@ module.exports = {
// .js and .jsx files to be handled by babel-loader
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'), // Just the source code
use: {
loader: 'babel-loader',
options: {
@ -59,7 +59,7 @@ module.exports = {
options: {
transpileOnly: true, // Speed up compilation in development mode
},
exclude: /node_modules/, // Just the source code
include: path.resolve(__dirname, 'src'), // Just the source code
},
// .css and .scss files to be handled by sass-loader
// include scss rule and sass-loader if injecting scss/sass file
@ -77,14 +77,21 @@ module.exports = {
},
'postcss-loader',
],
// No exclude, may need to handle files outside the source code
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/tailwindcss'),
path.resolve(__dirname, 'node_modules/react-tippy'),
path.resolve(__dirname, 'node_modules/react-draft-wysiwyg'),
path.resolve(__dirname, 'node_modules/codemirror'),
],
// May need to handle files outside the source code
// (from node_modules)
},
// .svg files to be handled by @svgr/webpack
{
test: /\.svg$/,
use: ['@svgr/webpack'],
exclude: /node_modules/, // Just the source code
include: path.resolve(__dirname, 'src'), // Just the source code
},
// different urls to be handled by url-loader
{
@ -98,21 +105,10 @@ module.exports = {
},
},
],
exclude: /node_modules/, // Just the source code
},
// different urls to be handled by url-loader in node_modules
{
test: /\.(png|jpg|jpeg|gif|svg|ico|eot|woff|woff2)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
name: `[name].[ext]`,
},
},
],
include: /node_modules\/slick-carousel/, // Just slick-carousel from node_modules
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/slick-carousel'),
], // Just the source code
},
// Font files to be handled by file-loader
{
@ -126,21 +122,10 @@ module.exports = {
},
},
],
exclude: /node_modules/, // Just the source code
},
// Font files to be handled by file-loader in node_modules
{
test: /\.ttf$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
include: /node_modules\/slick-carousel/, // Just slick-carousel from node_modules
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/slick-carousel'),
], // Just the source code
},
],
},