From b770cbb175dd6047d9b7066cd4fed27184d7821a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 14 Oct 2022 15:43:32 -0500 Subject: [PATCH] Webpack: convert rules to TypeScript --- webpack/rules/{assets.js => assets.ts} | Bin 2077 -> 2152 bytes ...-build-config.js => babel-build-config.ts} | Bin 521 -> 587 bytes webpack/rules/{babel-git.js => babel-git.ts} | Bin 517 -> 582 bytes webpack/rules/{babel.js => babel.ts} | Bin 694 -> 759 bytes webpack/rules/{css.js => css.ts} | Bin 504 -> 574 bytes webpack/rules/git-refresh.js | Bin 239 -> 0 bytes webpack/rules/git-refresh.ts | 13 ++++++++++ webpack/rules/index.js | Bin 494 -> 0 bytes webpack/rules/index.ts | 23 ++++++++++++++++++ webpack/rules/mark.js | Bin 151 -> 0 bytes webpack/rules/mark.ts | 14 +++++++++++ .../{node_modules.js => node_modules.ts} | Bin 635 -> 700 bytes 12 files changed, 50 insertions(+) rename webpack/rules/{assets.js => assets.ts} (93%) rename webpack/rules/{babel-build-config.js => babel-build-config.ts} (71%) rename webpack/rules/{babel-git.js => babel-git.ts} (71%) rename webpack/rules/{babel.js => babel.ts} (76%) rename webpack/rules/{css.js => css.ts} (73%) delete mode 100644 webpack/rules/git-refresh.js create mode 100644 webpack/rules/git-refresh.ts delete mode 100644 webpack/rules/index.js create mode 100644 webpack/rules/index.ts delete mode 100644 webpack/rules/mark.js create mode 100644 webpack/rules/mark.ts rename webpack/rules/{node_modules.js => node_modules.ts} (75%) diff --git a/webpack/rules/assets.js b/webpack/rules/assets.ts similarity index 93% rename from webpack/rules/assets.js rename to webpack/rules/assets.ts index e0a14c250075f09472581871973a7510ae4c1c83..d8c8e3e18b8e41f17d491bb09ac0daeda6269019 100644 GIT binary patch delta 140 zcmbO$@IqjMlXqrrL4Hw*LbXCsYH@x}S*k*B1=zZj)U?FX J9H>HTE&%^wGR^=1 delta 65 zcmaDMFjruLlX7x?UU7*+wL(#9aehu&szR-TEs$MUnpu>ppEB^1y_)oR|c2V)6-AR z&r8cpFD*(e$;{6~Qdm-1kP0*|s5B=vIJE>s!F83VCKV(mXM+^$>nnt0WELw-jHwm} jnp9k(Py|$Ig{*DkQx!%ruG9*!`%+TV5=(O+s;s#HkS;)l delta 109 zcmX@j(#aB-oS#=*qEM|+lvEB^1y_)oR|c2V)6-AR z&r8cpFD*(e$;{6~Qdm-1kP0*|s5B=vIJE>s!F83VCKV(mXM+^$>nnt0WELw-jHwg{ inp9k(Py|$Ig{*DkVR6uJ0 delta 109 zcmX@c(#jH;oS#=*qEM|+lv`Tu^CFYH(@^h=Lndo|;sUn4Aq#4Afm* fqEG~swL(_9vB-rRiReF7RW9v%`8gQP%lU<$xzp{=Hh~> zP0cIQQ7BF=Dap)BFGf|Xr>758m6n-aT9jClnV$#Nmz$qbnv<%RT2YW+R8kByx|&Nt Pp(M4q#7be~YI7z4vpg?vQ{Ji24g(9G=6+$Uf aPU^;h6^x=>sTE*%q@<=LmgYc|Spxv$4mxQ7 delta 68 zcmdnT@`G75IX|zsM8P*RFVnfW*tMdhC^5MtAg44vGf%-*p(wSmG_xpGW1^y@kft>k XS8jevX-=wMYDGbQQAzQ}#ubbJTud0n diff --git a/webpack/rules/git-refresh.js b/webpack/rules/git-refresh.js deleted file mode 100644 index 0b708b74627b9de5725bdc7970e754c7fdbd858f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmZ{eK?;K~6h!wq#otB2CVQoq=mjK=A5Dq*X@0bVc=v|dE(^0580O7b3Y=kwgiL-# zIN)0Rb8!hP8BLyK-3g&J+|be-oky@Vpn5R8CJeY@g3)ELlL;fTm}yu%D%>Ka%mua! zfQ+2m-$d2-gG<58*nm_@7nv9}lZkiQ^pc%t{oRmtQ|b$2`{4k1G6SZ+tTSd^9$ijf Lj-HUC5l1K9@}f@1 diff --git a/webpack/rules/git-refresh.ts b/webpack/rules/git-refresh.ts new file mode 100644 index 0000000000..aa16c5bcbd --- /dev/null +++ b/webpack/rules/git-refresh.ts @@ -0,0 +1,13 @@ +import { resolve } from 'path'; + +import type { RuleSetRule } from 'webpack'; + +/** Recompile code.js whenever git changes. */ +const rule: RuleSetRule = { + test: resolve(__dirname, '../../app/soapbox/utils/code.js'), + use: { + loader: resolve(__dirname, '../loaders/git-loader.js'), + }, +}; + +export default rule; \ No newline at end of file diff --git a/webpack/rules/index.js b/webpack/rules/index.js deleted file mode 100644 index bdf850c6d13c030a1d1faf5bfbc78683e0746b8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 494 zcmZvZu};J=42JhSg(Zdq>6+}En3!2u7!X2f;`R!q33duRK2B08cc+`;{QqYswp~~_ zfn~qL0F)23>>yMuCt>1~hmIZ~t(Vx4CH7?xoguW((T?M{k`-;%~DU4un# zjN^;HiO^g@pK&1M<9Q*`JE}&5m*DX!_;tpMlG%9ws!qn0G4O(YwC)q;U_BCpC4@-9 zp^VGJw8*%AL`MiDe$F_i6#3qm-}ZHd`fgQ-f|mn^yU{sxNE&i-F1} kUKN1Wx^7`F7wI`4Ck^ClSwRk@+wItfQQWqXy?Q&Se|$itJ^%m! diff --git a/webpack/rules/index.ts b/webpack/rules/index.ts new file mode 100644 index 0000000000..dac8763ca6 --- /dev/null +++ b/webpack/rules/index.ts @@ -0,0 +1,23 @@ +import assets from './assets'; +import babel from './babel'; +import buildConfig from './babel-build-config'; +import git from './babel-git'; +import css from './css'; +import gitRefresh from './git-refresh'; +import nodeModules from './node_modules'; + +import type { RuleSetRule } from 'webpack'; + +// Webpack loaders are processed in reverse order +// https://webpack.js.org/concepts/loaders/#loader-features +const rules: RuleSetRule[] = [ + ...assets, + css, + nodeModules, + babel, + git, + gitRefresh, + buildConfig, +]; + +export default rules; diff --git a/webpack/rules/mark.js b/webpack/rules/mark.js deleted file mode 100644 index e62a526b02a4a90beab27e517b7774dea72235ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmc~yQ_v_V%1=%$F4jxUE7SAycX5q(^$Sz5wY61H2g;@#i=;tftnN)N>YnUtQ7QP^sbZ$U*}4#(I!Fp+AQu2@pDv>S diff --git a/webpack/rules/mark.ts b/webpack/rules/mark.ts new file mode 100644 index 0000000000..322dabc1b7 --- /dev/null +++ b/webpack/rules/mark.ts @@ -0,0 +1,14 @@ +import { env } from 'process'; + +import type { RuleSetRule } from 'webpack'; + +let rule: RuleSetRule = {}; + +if (env.NODE_ENV !== 'production') { + rule = { + test: /\.js$/, + loader: 'mark-loader', + }; +} + +export default rule; \ No newline at end of file diff --git a/webpack/rules/node_modules.js b/webpack/rules/node_modules.ts similarity index 75% rename from webpack/rules/node_modules.js rename to webpack/rules/node_modules.ts index aa46fe59668cc69e48d36cafea65271be1fe0dce..f6f11b041da257bb79b87c264a6191b91f60430b 100644 GIT binary patch delta 181 zcmey(vWK-kGq)hWs6?S!AuB&KPoY*JttdZNLA@ZcBtzYriwiEBnpdWyP@Gy)l9`uY z3|FS7r=OgkmzJ4cT9jClnV*NGrKGYT6=-TuX-;ZzY6*yf>ncx8Do9Mu1}RP!%g-w= fQ78gRTOq66m?^|0%9UCHc3VnnT4HGqM3prFlR!To delta 136 zcmdnP`kSRbIX|zsM4?(CD?c+&p;p0Gp(wSmG_xpGL%kreBtu=(nu`mjq&T&tBr`9) zSVti>uMAbKo}NBXRa$0xX;ETHW_})6Uv7R%X-=wMYDGbQQAsh-=xQzng_6|b5-SD$ R7(I=w;+ov7jjR7K0sxgaF9QGo