Skip to content

Commit b544b78

Browse files
committed
feat(livechat): Drop stale polyfills
1 parent 01c8ff5 commit b544b78

File tree

5 files changed

+11
-70
lines changed

5 files changed

+11
-70
lines changed

packages/livechat/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@rocket.chat/ui-kit": "workspace:~",
3636
"ajv": "^8.17.1",
3737
"ajv-formats": "^3.0.1",
38-
"css-vars-ponyfill": "^2.4.9",
3938
"date-fns": "~4.1.0",
4039
"dompurify": "~3.2.7",
4140
"emoji-mart": "^3.0.1",
@@ -48,8 +47,7 @@
4847
"query-string": "^7.1.3",
4948
"react-hook-form": "~7.45.4",
5049
"react-i18next": "~13.2.2",
51-
"storybook-dark-mode": "^4.0.2",
52-
"whatwg-fetch": "^3.6.20"
50+
"storybook-dark-mode": "^4.0.2"
5351
},
5452
"devDependencies": {
5553
"@babel/core": "~7.28.5",
@@ -74,7 +72,6 @@
7472
"@types/mini-css-extract-plugin": "~2.5.1",
7573
"@types/react": "~18.3.26",
7674
"@types/webpack-env": "~1.18.8",
77-
"@types/whatwg-fetch": "~0.0.33",
7875
"@typescript-eslint/eslint-plugin": "~5.60.1",
7976
"@typescript-eslint/parser": "~5.60.1",
8077
"autoprefixer": "^9.8.8",

packages/livechat/src/components/Screen/index.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext, useEffect } from 'preact/hooks';
1+
import { useContext } from 'preact/hooks';
22

33
import { createClassName } from '../../helpers/createClassName';
44
import CloseIcon from '../../icons/close.svg';
@@ -31,29 +31,6 @@ export const ScreenFooter = ({ children, options, limit }) => {
3131
};
3232

3333
const CssVar = ({ theme }) => {
34-
useEffect(() => {
35-
if (window.CSS && CSS.supports('color', 'var(--color)')) {
36-
return;
37-
}
38-
let mounted = true;
39-
(async () => {
40-
const { default: cssVars } = await import('css-vars-ponyfill');
41-
if (!mounted) {
42-
return;
43-
}
44-
cssVars({
45-
variables: {
46-
'--color': theme.color,
47-
'--font-color': theme.fontColor,
48-
'--icon-color': theme.iconColor,
49-
},
50-
});
51-
})();
52-
return () => {
53-
mounted = false;
54-
};
55-
}, [theme]);
56-
5734
return (
5835
<style>{`
5936
.${styles.screen} {

packages/livechat/src/polyfills.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/livechat/webpack.config.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { resolve, dirname } from 'node:path';
22

33
import HtmlWebpackPlugin from 'html-webpack-plugin';
44
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
5-
import webpack from 'webpack';
5+
import { ContextReplacementPlugin, DefinePlugin, type Configuration, type WebpackOptionsNormalized } from 'webpack';
66

77
import { supportedLocales } from './src/supportedLocales';
88

@@ -11,13 +11,12 @@ import 'webpack-dev-server';
1111
// Helper to use absolute paths in the webpack config
1212
const _ = (p: string) => resolve(__dirname, p);
1313

14-
const config = (_env: any, { mode = 'production' }: webpack.WebpackOptionsNormalized): webpack.Configuration[] => [
14+
const config = (_env: any, { mode = 'production' }: WebpackOptionsNormalized): Configuration[] => [
1515
{
1616
mode,
1717
entry: {
1818
bundle: ['core-js', 'regenerator-runtime/runtime', _('./src/entry')],
19-
polyfills: _('./src/polyfills'),
20-
} as webpack.Entry,
19+
},
2120
output: {
2221
path: _('./dist'),
2322
publicPath: mode === 'production' ? 'livechat/' : '/',
@@ -27,7 +26,7 @@ const config = (_env: any, { mode = 'production' }: webpack.WebpackOptionsNormal
2726
stats: 'errors-warnings',
2827
devtool: mode === 'production' ? 'source-map' : 'eval',
2928
resolve: {
30-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
29+
extensions: ['.js', '.ts', '.tsx'],
3130
symlinks: false,
3231
alias: {
3332
'react': 'preact/compat',
@@ -126,16 +125,16 @@ const config = (_env: any, { mode = 'production' }: webpack.WebpackOptionsNormal
126125
new MiniCssExtractPlugin({
127126
filename: mode === 'production' ? '[name].[contenthash:5].css' : '[name].css',
128127
chunkFilename: mode === 'production' ? '[name].chunk.[contenthash:5].css' : '[name].chunk.css',
129-
}) as unknown as webpack.WebpackPluginInstance,
130-
new webpack.DefinePlugin({
128+
}),
129+
new DefinePlugin({
131130
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),
132131
}),
133132
new HtmlWebpackPlugin({
134133
title: 'Livechat - Rocket.Chat',
135-
chunks: ['polyfills', 'vendor', 'bundle'],
134+
chunks: ['vendor', 'bundle'],
136135
chunksSortMode: 'manual',
137136
}),
138-
new webpack.ContextReplacementPlugin(/date-fns[/\\]locale/, new RegExp(`(${supportedLocales.join('|')})\\.js$`)),
137+
new ContextReplacementPlugin(/date-fns[/\\]locale/, new RegExp(`(${supportedLocales.join('|')})\\.js$`)),
139138
],
140139
devServer: {
141140
hot: true,
@@ -163,7 +162,7 @@ const config = (_env: any, { mode = 'production' }: webpack.WebpackOptionsNormal
163162
mode,
164163
entry: {
165164
'rocketchat-livechat.min': _('./src/embeddable-script.ts'),
166-
} as webpack.Entry,
165+
},
167166
output: {
168167
path: _('./dist'),
169168
publicPath: mode === 'production' ? 'livechat/' : '/',

yarn.lock

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8905,7 +8905,6 @@ __metadata:
89058905
"@types/mini-css-extract-plugin": "npm:~2.5.1"
89068906
"@types/react": "npm:~18.3.26"
89078907
"@types/webpack-env": "npm:~1.18.8"
8908-
"@types/whatwg-fetch": "npm:~0.0.33"
89098908
"@typescript-eslint/eslint-plugin": "npm:~5.60.1"
89108909
"@typescript-eslint/parser": "npm:~5.60.1"
89118910
ajv: "npm:^8.17.1"
@@ -8914,7 +8913,6 @@ __metadata:
89148913
babel-loader: "npm:~10.0.0"
89158914
cross-env: "npm:^7.0.3"
89168915
css-loader: "npm:^4.3.0"
8917-
css-vars-ponyfill: "npm:^2.4.9"
89188916
cssnano: "npm:^7.0.7"
89198917
date-fns: "npm:~4.1.0"
89208918
desvg-loader: "npm:^0.1.0"
@@ -8967,7 +8965,6 @@ __metadata:
89678965
webpack: "npm:~5.99.9"
89688966
webpack-cli: "npm:~5.1.4"
89698967
webpack-dev-server: "npm:~5.2.2"
8970-
whatwg-fetch: "npm:^3.6.20"
89718968
peerDependencies:
89728969
"@rocket.chat/fuselage-tokens": "*"
89738970
"@rocket.chat/logo": "*"
@@ -14341,22 +14338,6 @@ __metadata:
1434114338
languageName: node
1434214339
linkType: hard
1434314340

14344-
"@types/whatwg-fetch@npm:~0.0.33":
14345-
version: 0.0.33
14346-
resolution: "@types/whatwg-fetch@npm:0.0.33"
14347-
dependencies:
14348-
"@types/whatwg-streams": "npm:*"
14349-
checksum: 10/431c407a72f5d5098e55361f159027137239df495c930d3f35f231d7375d34423d015d0cc1e391bf73af4dafb757e80a8ff33951972325e402dbea3b4934f6a0
14350-
languageName: node
14351-
linkType: hard
14352-
14353-
"@types/whatwg-streams@npm:*":
14354-
version: 0.0.7
14355-
resolution: "@types/whatwg-streams@npm:0.0.7"
14356-
checksum: 10/63ffdd1493cfcaf6f5ce99f865d9a7b921335c046ef8b8f0e37aacfa17672174606321da0f8d9ab9e4bfa26bd90c80529463f3651f1b202028debabdadf13fe8
14357-
languageName: node
14358-
linkType: hard
14359-
1436014341
"@types/whatwg-url@npm:^11.0.2":
1436114342
version: 11.0.5
1436214343
resolution: "@types/whatwg-url@npm:11.0.5"
@@ -37161,13 +37142,6 @@ __metadata:
3716137142
languageName: node
3716237143
linkType: hard
3716337144

37164-
"whatwg-fetch@npm:^3.6.20":
37165-
version: 3.6.20
37166-
resolution: "whatwg-fetch@npm:3.6.20"
37167-
checksum: 10/2b4ed92acd6a7ad4f626a6cb18b14ec982bbcaf1093e6fe903b131a9c6decd14d7f9c9ca3532663c2759d1bdf01d004c77a0adfb2716a5105465c20755a8c57c
37168-
languageName: node
37169-
linkType: hard
37170-
3717137145
"whatwg-mimetype@npm:^4.0.0":
3717237146
version: 4.0.0
3717337147
resolution: "whatwg-mimetype@npm:4.0.0"

0 commit comments

Comments
 (0)