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(notification-center,node,shared): update the axios to latest version #3861

Merged
merged 1 commit into from
Jul 27, 2023
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
2 changes: 1 addition & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dist/"
],
"dependencies": {
"axios": "1.2.0",
"axios": "^1.4.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the Axios version 1.2.0 was buggy, updating it to the latest helped solve the original issue, but...

"class-transformer": "0.5.1",
"class-validator": "0.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/lodash.get": "^4.4.6",
"@types/lodash.merge": "^4.6.6",
"@types/node": "^14.6.0",
"axios": "^1.3.3",
"axios": "^1.4.0",
"codecov": "^3.5.0",
"cz-conventional-changelog": "^3.3.0",
"jest": "^27.0.6",
Expand Down
32 changes: 15 additions & 17 deletions packages/notification-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
"start": "npm run build:watch",
"prebuild": "rimraf dist",
"lint": "eslint --ext .ts,.tsx src",
"build": "rollup -c && npm run build:types",
"build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types",
"build:cjs": "cross-env node_modules/.bin/tsc -p tsconfig.json",
"build:esm": "cross-env node_modules/.bin/tsc -p tsconfig.esm.json",
"build:esm:watch": "cross-env node_modules/.bin/tsc -p tsconfig.esm.json -w --preserveWatchOutput",
"build:umd": "webpack --config webpack.config.js",
"build:types": "tsc --declaration --emitDeclarationOnly --declarationMap --declarationDir dist/types -p tsconfig.json",
"build:watch": "rollup -c -w",
"build:watch": "npm run build:esm:watch",
Comment on lines +10 to +16
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That latest Axios version broke the UMD build of the notification-center package.
First of all, Rollup was bundling the Axios for node env, which required to polyfill NodeJS native modules like http, utils, ... etc.
The second thing was that the Rollup NodeJS polyfills do not support everything that Axios is using right now in Axios for node.
I wasn't able to figure out why it was trying to bundle the Axios for node, but I was sure that it was the issue between rollup plugins.

After a long fight, I decided to give it a try to Webpack, and in a few minutes, I had it working like a charm.
Then CJS and ESM modules needed to be built with TSC, but we were importing some images in the components, so I had to fix them too, like to make them React SVG components.

"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"test": "jest"
Expand All @@ -26,11 +30,6 @@
"sideEffects": false,
"types": "dist/types/index.d.ts",
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-image": "^3.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^10.0.1",
"@storybook/addon-actions": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-interactions": "^6.4.19",
Expand All @@ -49,22 +48,22 @@
"@types/react-dom": "^17.0.0",
"acorn": "^8.7.1",
"babel-loader": "^8.2.4",
"compression-webpack-plugin": "^10.0.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-transform-stub": "^2.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"rimraf": "^3.0.2",
"rollup": "^3.7.3",
"rollup-plugin-bundle-analyzer": "^1.6.6",
"rollup-plugin-gzip": "^3.1.0",
"rollup-plugin-node-externals": "^5.0.2",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup-plugin-terser": "^7.0.2",
"terser-webpack-plugin": "^5.3.9",
"ts-jest": "^29.0.3",
"ts-loader": "~9.4.0",
"tslib": "^2.3.1",
"typescript": "4.9.5"
"typescript": "4.9.5",
"url-loader": "^4.1.1",
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.9.0",
"webpack-cli": "^5.1.4"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand All @@ -78,10 +77,9 @@
"@mantine/hooks": "^5.7.1",
"@novu/client": "^0.17.1",
"@novu/shared": "^0.17.1",
"@rollup/plugin-babel": "^6.0.3",
"@tanstack/react-query": "^4.20.4",
"acorn-jsx": "^5.3.2",
"axios": "^1.3.3",
"axios": "^1.4.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"lodash.merge": "^4.6.2",
Expand Down
86 changes: 0 additions & 86 deletions packages/notification-center/rollup.config.mjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { IMessage, ChannelCTATypeEnum } from '@novu/shared';

import { useNotifications, useNotificationCenter, useNovuContext, useTranslations } from '../../../hooks';
import image from '../../../images/no-new-notifications.svg';
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've transformed svg and webp images to React SVG components

import { NotificationsList } from './NotificationsList';
import { Loader } from './Loader';
import { colors } from '../../../shared/config/colors';
import { NoNewNotifications } from '../../../images/NoNewNotifications';

export function NotificationsListTab() {
const { apiService } = useNovuContext();
Expand Down Expand Up @@ -54,7 +54,7 @@ export function NotificationsListTab() {
justifyContent: 'center',
}}
>
<img src={image as any} alt="logo" style={{ maxWidth: 200, marginBottom: 15 }} />
<NoNewNotifications style={{ maxWidth: 200, marginBottom: 15 }} />
<span style={{ color: colors.B70, fontSize: 15 }}>{t('noNewNotification')}</span>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { css, cx } from '@emotion/css';

import { useNovuTheme, useFetchUserPreferences, useNovuContext } from '../../../../hooks';
import { accordionStyles } from './styles';
import image from '../../../../images/no-settings.webp';
import { useStyles } from '../../../../store/styles';
import { UserPreferenceItem } from './UserPreferenceItem';
import { Loader } from '../Loader';
import { NoSettings } from '../../../../images/NoSettings';

const rootClassName = css`
padding: 15px;
Expand Down Expand Up @@ -51,7 +51,7 @@ export function SubscriberPreference() {
justifyContent: 'center',
}}
>
<img src={image as any} alt="logo" style={{ maxWidth: 300 }} />
<NoSettings style={{ maxWidth: 300 }} />
</div>
) : (
<ScrollArea style={{ height: 400 }}>
Expand Down
15 changes: 0 additions & 15 deletions packages/notification-center/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
declare module '*.png' {
const value: any;
export = value;
}

declare module '*.webp' {
const value: any;
export = value;
}

declare module '*.svg' {
const value: any;
export = value;
}

interface IMessagePayload {
type: string;
[key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
Expand Down
82 changes: 82 additions & 0 deletions packages/notification-center/src/images/NoNewNotifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable */
import React from 'react';

export const NoNewNotifications = (props: React.ComponentPropsWithoutRef<'svg'>) => {
return (
<svg width="120" height="108" viewBox="0 0 120 108" fill="none" {...props}>
<circle
cx="11.3191"
cy="30.7872"
r="6.31915"
stroke="#3D3D4D"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<ellipse
cx="60.117"
cy="27.9787"
rx="5.96809"
ry="5.61702"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M79.5424 49.4934C79.5424 44.1598 77.6437 39.0446 74.2641 35.2732C70.8844 31.5017 66.3006 29.3829 61.5211 29.3829C56.7415 29.3829 52.1578 31.5017 48.7781 35.2732C45.3985 39.0446 43.4998 44.1598 43.4998 49.4934C43.4998 72.9557 34.4892 79.6592 34.4892 79.6592H88.553C88.553 79.6592 79.5424 72.9557 79.5424 49.4934Z"
fill="#292933"
/>
<path
d="M68.8995 81.7552C68.1496 83.551 67.0731 85.0417 65.778 86.0779C64.4828 87.1141 63.0144 87.6595 61.5198 87.6595C60.0252 87.6595 58.5568 87.1141 57.2617 86.0779C55.9665 85.0417 54.8901 83.551 54.1401 81.7552"
fill="#292933"
/>
<path
d="M81.2976 50.2203C81.2976 68.2545 87.2222 76.7327 90.2814 79.9083C90.7671 80.4126 90.3802 81.4764 89.68 81.4764C88.0927 81.4764 86.5488 81.4764 85.0422 81.4764M68.5814 82.946C67.6854 84.8068 66.3993 86.3513 64.8518 87.425C63.3044 88.4987 61.5499 89.0638 59.7641 89.0638C57.9783 89.0638 56.2239 88.4987 54.6765 87.425C53.129 86.3513 51.8429 84.8068 50.9468 82.946M79.712 42.3723C78.6394 39.8192 77.0439 37.4727 74.991 35.4861C70.953 31.5783 65.4763 29.3829 59.7656 29.3829C54.055 29.3829 48.5783 31.5783 44.5403 35.4861C43.3681 36.6205 42.345 37.8722 41.4832 39.2127C40.4958 40.7487 39.7202 42.4013 39.1747 44.1276C38.5563 46.0847 38.2337 48.1364 38.2337 50.2203C38.2337 53.2503 38.0665 56.0106 37.7737 58.5212M34.8401 70.7608C32.9874 75.4551 30.7688 78.331 29.2526 79.9055C28.767 80.4099 29.155 81.4764 29.8551 81.4764C47.1962 81.4764 59.3571 81.4764 74.1593 81.4764"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M55.6345 59.0737C55.1665 59.7144 54.4949 60.2462 53.6868 60.6159C52.8787 60.9855 51.9625 61.1801 51.0299 61.1801C50.0973 61.1801 49.1811 60.9855 48.373 60.6159C47.5649 60.2462 46.8933 59.7144 46.4254 59.0737"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M73.1877 59.0737C72.7197 59.7144 72.0481 60.2462 71.24 60.6159C70.4319 60.9855 69.5157 61.1801 68.5831 61.1801C67.6506 61.1801 66.7344 60.9855 65.9263 60.6159C65.1182 60.2462 64.4465 59.7144 63.9786 59.0737"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle
cx="107.511"
cy="56.0638"
r="7.02128"
stroke="#3D3D4D"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx="16.4252" cy="58.1703" r="4.21277" fill="#3D3D4D" />
<ellipse cx="59.9573" cy="104.511" rx="25.2766" ry="2.80851" fill="#3D3D4D" />
<path
d="M81.5317 18.1489H88.553L81.5317 25.1702H88.553"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M96.6807 2H106.51L96.6807 11.8298H106.51"
stroke="#828299"
strokeWidth="3.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
};
45 changes: 45 additions & 0 deletions packages/notification-center/src/images/NoSettings.tsx

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions packages/notification-center/src/images/no-new-notifications.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/notification-center/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "./dist/esm"
}
}
Comment on lines +1 to +7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

separate TS config for the ESM module

4 changes: 3 additions & 1 deletion packages/notification-center/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"include": ["src"],
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"forceConsistentCasingInFileNames": true,
"target": "es6",
"strict": true,
"typeRoots": ["./node_modules/@types"],
"jsx": "react",
"module": "ESNext",
"module": "commonjs",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TS config for CJS

"lib": ["ESNext", "dom"],
"skipLibCheck": true,
"declaration": false,
"declarationMap": false,
"sourceMap": true,
"removeComments": false,
"allowSyntheticDefaultImports": true,
"baseUrl": "."
},
"exclude": ["src/**/*.test.*", "src/*.test.*", "node_modules", "**/node_modules/*"]
Expand Down
Loading
Loading