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

TGUI: Replaces babel & terser #6196

Merged
merged 1 commit into from
May 1, 2024
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
15 changes: 15 additions & 0 deletions tgui/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"loose": true,
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic"
}
}
}
}
52 changes: 0 additions & 52 deletions tgui/babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion tgui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
testEnvironment: 'jsdom',
testRunner: require.resolve('jest-circus/runner'),
transform: {
'^.+\\.(js|cjs|ts|tsx)$': require.resolve('babel-jest'),
'^.+\\.(js|cjs|ts|tsx)$': require.resolve('@swc/jest'),
},
moduleFileExtensions: ['js', 'cjs', 'ts', 'tsx', 'json'],
resetMocks: true,
Expand Down
16 changes: 4 additions & 12 deletions tgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,16 @@
"tgui:tsc": "tsc"
},
"dependencies": {
"@babel/core": "^7.15.0",
"@babel/eslint-parser": "^7.15.0",
"@babel/plugin-transform-class-properties": "^7.23.3",
"@babel/plugin-transform-jscript": "^7.14.5",
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.15.0",
"@swc/core": "^1.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Of note, this seems to work here in this PR, but I get no candidates found for this version in the branch I'm testing.
image

Copy link
Contributor Author

@jlsnow301 jlsnow301 Apr 27, 2024

Choose a reason for hiding this comment

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

Might be a yarn/swc issue,
swc-project/swc#8898

"@swc/jest": "^0.2.36",
"@types/jest": "^27.0.1",
"@types/jsdom": "^16.2.13",
"@types/node": "^14.17.9",
"@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.16.2",
"@typescript-eslint/parser": "^4.29.1",
"babel-jest": "^27.0.6",
"babel-loader": "^8.2.2",
"babel-plugin-transform-remove-console": "^6.9.4",
"common": "workspace:*",
"css-loader": "^5.2.7",
"esbuild-loader": "^4.1.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-radar": "^0.2.1",
Expand All @@ -52,7 +44,7 @@
"sass": "^1.37.5",
"sass-loader": "^11.1.1",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.4",
"swc-loader": "^0.2.6",
"typescript": "^4.9.4",
"url-loader": "^4.1.1",
"webpack": "^5.75.0",
Expand Down
4 changes: 1 addition & 3 deletions tgui/packages/tgui/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { KEY_ENTER, KEY_ESCAPE, KEY_SPACE } from 'common/keycodes';
import { classes, pureComponentHooks } from 'common/react';
import { classes } from 'common/react';
import { Component, createRef } from 'react';
import { createLogger } from '../logging';
import { Box, computeBoxClassName, computeBoxProps } from './Box';
Expand Down Expand Up @@ -134,8 +134,6 @@ export const Button = (props) => {
return buttonContent;
};

Button.defaultHooks = pureComponentHooks;

export const ButtonCheckbox = (props) => {
const { checked, ...rest } = props;
return (
Expand Down
3 changes: 0 additions & 3 deletions tgui/packages/tgui/components/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { map, zipWith } from 'common/collections';
import { pureComponentHooks } from 'common/react';
import { Component, createRef } from 'react';
import { Box } from './Box';

Expand Down Expand Up @@ -117,8 +116,6 @@ class LineChart extends Component {
}
}

LineChart.defaultHooks = pureComponentHooks;

const Stub = (props) => null;

// IE8: No inline svg support
Expand Down
4 changes: 1 addition & 3 deletions tgui/packages/tgui/components/ColorBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license MIT
*/

import { classes, pureComponentHooks } from 'common/react';
import { classes } from 'common/react';
import { computeBoxClassName, computeBoxProps } from './Box';

export const ColorBox = (props) => {
Expand All @@ -27,5 +27,3 @@ export const ColorBox = (props) => {
</div>
);
};

ColorBox.defaultHooks = pureComponentHooks;
2 changes: 0 additions & 2 deletions tgui/packages/tgui/components/DraggableControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { clamp } from 'common/math';
import { pureComponentHooks } from 'common/react';
import { Component, createRef } from 'react';
import { AnimatedNumber } from './AnimatedNumber';

Expand Down Expand Up @@ -276,7 +275,6 @@ export class DraggableControl extends Component {
}
}

DraggableControl.defaultHooks = pureComponentHooks;
DraggableControl.defaultProps = {
minValue: -Infinity,
maxValue: +Infinity,
Expand Down
5 changes: 0 additions & 5 deletions tgui/packages/tgui/components/Grid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { Table } from './Table';
import { pureComponentHooks } from 'common/react';

/** @deprecated */
export const Grid = (props) => {
Expand All @@ -17,8 +16,6 @@ export const Grid = (props) => {
);
};

Grid.defaultHooks = pureComponentHooks;

/** @deprecated */
export const GridColumn = (props) => {
const { size = 1, style, ...rest } = props;
Expand All @@ -33,6 +30,4 @@ export const GridColumn = (props) => {
);
};

Grid.defaultHooks = pureComponentHooks;

Grid.Column = GridColumn;
4 changes: 1 addition & 3 deletions tgui/packages/tgui/components/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license MIT
*/

import { classes, pureComponentHooks } from 'common/react';
import { classes } from 'common/react';
import { computeBoxClassName, computeBoxProps } from './Box';

const FA_OUTLINE_REGEX = /-o$/;
Expand Down Expand Up @@ -55,8 +55,6 @@ export const Icon = (props) => {
);
};

Icon.defaultHooks = pureComponentHooks;

export const IconStack = (props) => {
const { className, children, ...rest } = props;
return (
Expand Down
4 changes: 1 addition & 3 deletions tgui/packages/tgui/components/NoticeBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license MIT
*/

import { classes, pureComponentHooks } from 'common/react';
import { classes } from 'common/react';
import { Box } from './Box';

export const NoticeBox = (props) => {
Expand All @@ -23,5 +23,3 @@ export const NoticeBox = (props) => {
/>
);
};

NoticeBox.defaultHooks = pureComponentHooks;
8 changes: 1 addition & 7 deletions tgui/packages/tgui/components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license MIT
*/

import { classes, pureComponentHooks } from 'common/react';
import { classes } from 'common/react';
import { computeBoxClassName, computeBoxProps } from './Box';

export const Table = (props) => {
Expand All @@ -23,8 +23,6 @@ export const Table = (props) => {
);
};

Table.defaultHooks = pureComponentHooks;

export const TableRow = (props) => {
const { className, header, ...rest } = props;
return (
Expand All @@ -40,8 +38,6 @@ export const TableRow = (props) => {
);
};

TableRow.defaultHooks = pureComponentHooks;

export const TableCell = (props) => {
const { className, collapsing, header, ...rest } = props;
return (
Expand All @@ -58,7 +54,5 @@ export const TableCell = (props) => {
);
};

TableCell.defaultHooks = pureComponentHooks;

Table.Row = TableRow;
Table.Cell = TableCell;
3 changes: 1 addition & 2 deletions tgui/public/tgui-panel.bundle.css

Large diffs are not rendered by default.

37 changes: 9 additions & 28 deletions tgui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const webpack = require('webpack');
const path = require('path');
const ExtractCssPlugin = require('mini-css-extract-plugin');
const { createBabelConfig } = require('./babel.config.js');

const createStats = (verbose) => ({
assets: verbose,
Expand All @@ -33,18 +32,9 @@ module.exports = (env = {}, argv) => {
context: path.resolve(__dirname),
target: ['web', 'es3', 'browserslist:ie 8'],
entry: {
'tgui': [
'./packages/tgui-polyfill',
'./packages/tgui',
],
'tgui-panel': [
'./packages/tgui-polyfill',
'./packages/tgui-panel',
],
'tgui-say': [
'./packages/tgui-polyfill',
'./packages/tgui-say',
],
'tgui': ['./packages/tgui-polyfill', './packages/tgui'],
'tgui-panel': ['./packages/tgui-polyfill', './packages/tgui-panel'],
'tgui-say': ['./packages/tgui-polyfill', './packages/tgui-say'],
},
output: {
path: argv.useTmpFolder
Expand All @@ -61,13 +51,10 @@ module.exports = (env = {}, argv) => {
module: {
rules: [
{
test: /\.(js|jsx|cjs|ts|tsx)$/,
test: /\.([tj]s(x)?|cjs)$/,
use: [
{
loader: require.resolve('babel-loader'),
options: createBabelConfig({
removeConsole: !bench,
}),
loader: require.resolve('swc-loader'),
},
],
},
Expand Down Expand Up @@ -143,17 +130,11 @@ module.exports = (env = {}, argv) => {

// Production build specific options
if (mode === 'production') {
const TerserPlugin = require('terser-webpack-plugin');
const { EsbuildPlugin } = require('esbuild-loader');
config.optimization.minimizer = [
new TerserPlugin({
extractComments: false,
terserOptions: {
ie8: true,
output: {
ascii_only: true,
comments: false,
},
},
new EsbuildPlugin({
target: 'ie8',
css: true,
}),
];
}
Expand Down
Loading
Loading