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

Openshift-SDK and PF dependency version upgrade #1525

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions analyzeTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from 'fs';
import { parseChunked } from '@discoveryjs/json-ext';

const pluginName = process.env.PLUGIN;
const MAX_ASSET_SIZE = 17; //17 MiB
Expand All @@ -12,17 +13,17 @@ const stringifyMiB = (value: ReturnType<typeof toMiB>): string =>

const getParsedStatFile = () => {
const filePath = getStatsFilePath();
const statsFile = fs.readFileSync(filePath, 'utf-8');
return JSON.parse(statsFile);

return parseChunked(fs.createReadStream(filePath, { encoding: 'utf8' }));
};

type BundleDataMap = Record<string, number>;

// [Valid Bundles, Violating Bunldes]
type GetBundleInformation = () => [BundleDataMap, BundleDataMap];
type GetBundleInformation = () => Promise<[BundleDataMap, BundleDataMap]>;

const getBundleInformation: GetBundleInformation = () => {
const statsData = getParsedStatFile();
const getBundleInformation: GetBundleInformation = async () => {
const statsData = await getParsedStatFile();
const validAssets = {};
const violatingAssets = {};

Expand All @@ -39,8 +40,8 @@ const getBundleInformation: GetBundleInformation = () => {
return [validAssets, violatingAssets];
};

const validateBuild = () => {
const [validAssets, violatingAssets] = getBundleInformation();
const validateBuild = async () => {
const [validAssets, violatingAssets] = await getBundleInformation();
if (Object.keys(violatingAssets).length > 0) {
// eslint-disable-next-line no-console
console.error('Assets are larger than expected', violatingAssets);
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@
"dev:c": "yarn ocp-console & PLUGIN=${PLUGIN} I8N_NS=${I8N_NS} yarn server:plugin & wait"
},
"dependencies": {
"@openshift-console/dynamic-plugin-sdk": "1.3.0",
"@openshift-console/dynamic-plugin-sdk": "1.5.0",
"@openshift-console/dynamic-plugin-sdk-internal": "1.0.0",
"@openshift-console/dynamic-plugin-sdk-webpack": "1.1.0",
"@openshift-console/dynamic-plugin-sdk-webpack": "1.2.0",
"@openshift-console/plugin-shared": "^0.0.1",
"@patternfly/patternfly": "5.0.2",
"@patternfly/react-charts": "7.1.0",
"@patternfly/react-core": "5.1.0",
"@patternfly/react-icons": "5.0.1",
"@patternfly/react-table": "5.1.0",
"@patternfly/react-tokens": "5.1.0",
"@patternfly/react-topology": "5.0.0",
"@patternfly/patternfly": "5.0.4",
"@patternfly/react-charts": "7.1.1",
"@patternfly/react-core": "5.1.1",
"@patternfly/react-icons": "5.1.1",
"@patternfly/react-table": "5.1.1",
"@patternfly/react-tokens": "5.1.1",
"@patternfly/react-topology": "5.1.0",
Comment on lines +65 to +71
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have package.json under shared as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, will update both

"@types/lodash-es": "^4.17.4",
"@types/react-dnd-html5-backend": "^3.0.2",
"buffer": "^6.0.3",
Expand Down Expand Up @@ -120,7 +120,8 @@
"webpack": "5.75.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "4.5.x",
"yup": "^0.32.11"
"yup": "^0.32.11",
"@discoveryjs/json-ext": "0.6.1"
},
"devDependencies": {
"@cypress/webpack-preprocessor": "^5.9.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/odf/hooks/useSafeK8sGet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useK8sGet } from '@odf/shared';
import { useK8sGet } from '@odf/shared/hooks';
import { getValidK8sOptions } from '@odf/shared/utils';
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
import { K8sKind } from '@openshift-console/dynamic-plugin-sdk/lib/api/common-types';
Expand Down
2 changes: 1 addition & 1 deletion packages/odf/hooks/useSafeK8sList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useK8sList } from '@odf/shared';
import { useK8sList } from '@odf/shared/hooks';
import { getValidK8sOptions } from '@odf/shared/utils';
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
import { K8sKind } from '@openshift-console/dynamic-plugin-sdk/lib/api/common-types';
Expand Down
16 changes: 8 additions & 8 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"publish-new": "scripts/publish-new.sh"
},
"dependencies": {
"@patternfly/patternfly": "5.0.2",
"@patternfly/react-charts": "7.1.0",
"@patternfly/react-core": "5.1.0",
"@patternfly/react-icons": "5.0.1",
"@patternfly/react-table": "5.1.0",
"@patternfly/react-tokens": "5.1.0",
"@patternfly/react-topology": "5.0.0",
"@patternfly/patternfly": "5.0.4",
"@patternfly/react-charts": "7.1.1",
"@patternfly/react-core": "5.1.1",
"@patternfly/react-icons": "5.1.1",
"@patternfly/react-table": "5.1.1",
"@patternfly/react-tokens": "5.1.1",
"@patternfly/react-topology": "5.1.0",
"@types/lodash-es": "^4.17.4",
"@types/node": "^14.14.34",
"@types/react": "16.8.13",
Expand Down Expand Up @@ -55,7 +55,7 @@
"yup": "^0.32.11"
},
"peerDependencies": {
"@openshift-console/dynamic-plugin-sdk": "1.3.0",
"@openshift-console/dynamic-plugin-sdk": "1.5.0",
"@openshift-console/dynamic-plugin-sdk-internal": "1.0.0",
"i18next": "^20.2.1",
"react": "^17.0.1",
Expand Down
74 changes: 44 additions & 30 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,42 @@ import * as webpack from 'webpack';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';

// supported PLUGINS: odf/mco/client
const PLUGIN = process.env.PLUGIN;
if (PLUGIN === undefined) {
process.exit(1);
}
// switch current working directory based on the plugins
const processPath = path.resolve(__dirname, `plugins/${PLUGIN}`);
process.chdir(processPath);

// supported languages
const LANGUAGES = ['en', 'ja', 'ko', 'zh', 'es', 'fr'];
const resolveLocale = (dirName: string, ns: string) =>
LANGUAGES.map((lang) => ({
from: path.resolve(dirName, `locales/${lang}/plugin__*.json`),
to: `locales/${lang}/${ns}.[ext]`,
}));

// supported NODE_ENV: production/development
const NODE_ENV = (process.env.NODE_ENV ||
'development') as webpack.Configuration['mode'];
const PLUGIN = process.env.PLUGIN;
const isProduction = NODE_ENV === 'production';
const OPENSHIFT_CI = process.env.OPENSHIFT_CI;

if (PLUGIN === undefined) {
process.exit(1);
}
const processPath = path.resolve(__dirname, `plugins/${PLUGIN}`);
process.chdir(processPath);

const config: webpack.Configuration & DevServerConfiguration = {
context: __dirname,
mode: NODE_ENV,
entry: {},
output: {
path: path.resolve('./dist'),
filename: '[name]-bundle.js',
chunkFilename: '[name]-chunk.js',
filename: '[name].bundle.[contenthash:8].js',
chunkFilename: '[name].[contenthash:8].js',
},
ignoreWarnings: [(warning) => !!warning?.file?.includes('shared module')],
watchOptions: {
ignored: ['node_modules', 'dist'],
},
devServer: {
port: 9001,
devMiddleware: {
writeToDisk: true,
},
headers: {
'Cache-Control': 'no-store',
},
static: ['dist'],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'@odf/shared': path.resolve(__dirname, './packages/shared/src/'),
},
},
module: {
rules: [
{
Expand Down Expand Up @@ -86,7 +75,7 @@ const config: webpack.Configuration & DevServerConfiguration = {
{
loader: 'thread-loader',
options: {
...(NODE_ENV === 'development'
...(!isProduction
? { poolTimeout: Infinity, poolRespawn: false }
: OPENSHIFT_CI
? {
Expand Down Expand Up @@ -135,7 +124,11 @@ const config: webpack.Configuration & DevServerConfiguration = {
],
},
plugins: [
new ConsoleRemotePlugin(),
new ConsoleRemotePlugin({
sharedDynamicModuleSettings: {
modulePaths: [path.resolve(__dirname, 'node_modules')],
},
}),
new CopyWebpackPlugin({
patterns: [...resolveLocale(__dirname, process.env.I8N_NS || '')],
}),
Expand All @@ -153,13 +146,34 @@ const config: webpack.Configuration & DevServerConfiguration = {
cwd: process.cwd(),
}),
],
devtool: 'eval-cheap-module-source-map',
// 'source-map' is recommended choice for production builds, A full SourceMap is emitted as a separate file.
// 'eval-source-map' is recommended for development but 'eval-cheap-module-source-map' is faster and gives better result.
devtool: isProduction ? 'source-map' : 'eval-cheap-module-source-map',
optimization: {
chunkIds: 'named',
// 'deterministic' Good for long term caching.
// 'named' Readable ids for better debugging.
chunkIds: isProduction ? 'deterministic' : 'named',
},
devServer: {
port: 9001,
// Allow bridge running in a container to connect to the plugin dev server.
allowedHosts: 'all',
devMiddleware: {
writeToDisk: true,
},
static: ['dist'],
// Enable gzip compression for dev server
compress: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'@odf/shared': path.resolve(__dirname, './packages/shared/src/'),
},
},
};

if (NODE_ENV === 'production' || process.env.DEV_NO_TYPE_CHECK !== 'true') {
if (isProduction || process.env.DEV_NO_TYPE_CHECK !== 'true') {
config.plugins?.push(
new ForkTsCheckerWebpackPlugin({
issue: {
Expand Down
Loading
Loading