core: remove typeorm decorators in bundle to reduce bundle size

This commit is contained in:
Sokna Ly 2023-12-07 12:55:00 +07:00
parent bfcc0fa511
commit 1aa466d3f2
7 changed files with 107 additions and 40 deletions

View File

@ -45,6 +45,7 @@
"sass-loader": "^12.6.0",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.1",
"typescript-remove-decorators-transformer": "^1.0.1",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^4.9.2",
@ -168,7 +169,7 @@
"lodash": "^4.17.21",
"Model": "file:../Model",
"moment-timezone": "^0.5.43",
"npm": "^10.2.2",
"npm": "^9.6.3",
"prismjs": "^1.29.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
@ -18698,6 +18699,12 @@
"node": ">=4.2.0"
}
},
"node_modules/typescript-remove-decorators-transformer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/typescript-remove-decorators-transformer/-/typescript-remove-decorators-transformer-1.0.1.tgz",
"integrity": "sha512-nNj79TVUK6SV7rAo2w6k0nrd774uLPz47TWeTH5jsEYbRcmKJKsoM1TX7gra7P/a3AoHLQt3n6fZAQtonOkYyw==",
"dev": true
},
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",

View File

@ -65,6 +65,7 @@
"sass-loader": "^12.6.0",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.1",
"typescript-remove-decorators-transformer": "^1.0.1",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^4.9.2",

View File

@ -3,6 +3,7 @@ const webpack = require("webpack");
const dotenv = require('dotenv');
const express = require('express');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const removeDecoratorsTransformer = require('typescript-remove-decorators-transformer').default;
const readEnvFile = (pathToFile) => {
@ -49,7 +50,26 @@ module.exports = {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader'
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [
removeDecoratorsTransformer([
'Entity',
'Column',
'Index',
'ManyToOne',
'JoinColumn',
'ManyToMany',
'JoinTable',
'PrimaryGeneratedColumn',
'CreateDateColumn',
'UpdateDateColumn',
'DeleteDateColumn',
'VersionColumn',
])]
}),
},
},
{
test: /\.s[ac]ss$/i,

View File

@ -40,6 +40,8 @@
"sass-loader": "^12.6.0",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.1",
"typescript": "^5.3.3",
"typescript-remove-decorators-transformer": "^1.0.1",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^4.9.2",
@ -83,16 +85,16 @@
"dependencies": {
"@clickhouse/client": "^0.2.1",
"@elastic/elasticsearch": "^8.1.0",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.0",
"@opentelemetry/sdk-node": "^0.30.0",
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/auto-instrumentations-node": "^0.40.1",
"@opentelemetry/sdk-node": "^0.45.1",
"@socket.io/redis-adapter": "^8.2.1",
"@types/ejs": "^3.1.1",
"@types/gridfs-stream": "^0.5.35",
"@types/json2csv": "^5.0.3",
"@types/markdown-it": "^12.2.3",
"@types/nodemailer": "^6.4.7",
"airtable": "^0.11.3",
"airtable": "^0.12.2",
"axios": "^1.6.2",
"bullmq": "^3.6.6",
"Common": "file:../Common",
@ -111,11 +113,11 @@
"Model": "file:../Model",
"node-device-detector": "^2.0.0",
"nodemailer": "^6.7.3",
"nodemailer-express-handlebars": "^5.0.0",
"nodemailer-express-handlebars": "^6.1.0",
"pg": "^8.7.3",
"socket.io": "^4.7.2",
"stripe": "^10.17.0",
"twilio": "^4.13.0",
"twilio": "^4.19.3",
"typeorm": "^0.3.10",
"typeorm-extension": "^2.2.13",
"vm2": "^3.9.14",
@ -142,15 +144,16 @@
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.7",
"@heroicons/react": "^2.0.13",
"@monaco-editor/react": "^4.4.6",
"@nivo/bar": "^0.79.1",
"@nivo/core": "^0.79.0",
"@nivo/bar": "^0.84.0",
"@nivo/core": "^0.84.0",
"@tippyjs/react": "^4.2.6",
"@types/prismjs": "^1.26.0",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-big-calendar": "^1.8.5",
"@types/react-color": "^3.0.6",
"@types/react-toggle": "^4.0.3",
"@uiw/react-md-editor": "^3.18.1",
@ -161,11 +164,13 @@
"i": "^0.3.7",
"lodash": "^4.17.21",
"Model": "file:../Model",
"npm": "^8.18.0",
"moment-timezone": "^0.5.43",
"npm": "^9.6.3",
"prismjs": "^1.29.0",
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
"react-big-calendar": "^1.8.5",
"react-color": "^2.19.3",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
@ -203,7 +208,7 @@
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^28.1.4",
"@types/node": "^17.0.45",
"@types/react": "^18.0.9",
"@types/react": "^18.2.38",
"@types/react-test-renderer": "^18.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^28.1.1",
@ -218,7 +223,7 @@
"license": "ISC",
"dependencies": {
"Common": "file:../Common",
"typeorm": "^0.3.7"
"typeorm": "^0.3.17"
},
"devDependencies": {
"@types/jest": "^27.4.1",
@ -17325,19 +17330,24 @@
}
},
"node_modules/typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
"node": ">=14.17"
}
},
"node_modules/typescript-remove-decorators-transformer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/typescript-remove-decorators-transformer/-/typescript-remove-decorators-transformer-1.0.1.tgz",
"integrity": "sha512-nNj79TVUK6SV7rAo2w6k0nrd774uLPz47TWeTH5jsEYbRcmKJKsoM1TX7gra7P/a3AoHLQt3n6fZAQtonOkYyw==",
"dev": true
},
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -23490,9 +23500,9 @@
"@clickhouse/client": "^0.2.1",
"@elastic/elasticsearch": "^8.1.0",
"@faker-js/faker": "^6.3.1",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.0",
"@opentelemetry/sdk-node": "^0.30.0",
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/auto-instrumentations-node": "^0.40.1",
"@opentelemetry/sdk-node": "^0.45.1",
"@socket.io/redis-adapter": "^8.2.1",
"@types/cookie-parser": "^1.4.4",
"@types/cors": "^2.8.12",
@ -23505,7 +23515,7 @@
"@types/markdown-it": "^12.2.3",
"@types/node": "^17.0.22",
"@types/nodemailer": "^6.4.7",
"airtable": "^0.11.3",
"airtable": "^0.12.2",
"axios": "^1.6.2",
"bullmq": "^3.6.6",
"Common": "file:../Common",
@ -23526,12 +23536,12 @@
"Model": "file:../Model",
"node-device-detector": "^2.0.0",
"nodemailer": "^6.7.3",
"nodemailer-express-handlebars": "^5.0.0",
"nodemailer-express-handlebars": "^6.1.0",
"pg": "^8.7.3",
"socket.io": "^4.7.2",
"stripe": "^10.17.0",
"ts-jest": "^27.1.4",
"twilio": "^4.13.0",
"twilio": "^4.19.3",
"typeorm": "^0.3.10",
"typeorm-extension": "^2.2.13",
"vm2": "^3.9.14",
@ -23545,12 +23555,12 @@
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.7",
"@heroicons/react": "^2.0.13",
"@monaco-editor/react": "^4.4.6",
"@nivo/bar": "^0.79.1",
"@nivo/core": "^0.79.0",
"@nivo/bar": "^0.84.0",
"@nivo/core": "^0.84.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/react-hooks": "^8.0.1",
@ -23559,8 +23569,9 @@
"@types/jest": "^28.1.4",
"@types/node": "^17.0.45",
"@types/prismjs": "^1.26.0",
"@types/react": "^18.0.9",
"@types/react": "^18.2.38",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-big-calendar": "^1.8.5",
"@types/react-color": "^3.0.6",
"@types/react-test-renderer": "^18.0.0",
"@types/react-toggle": "^4.0.3",
@ -23575,11 +23586,13 @@
"jest-environment-jsdom": "^28.1.3",
"lodash": "^4.17.21",
"Model": "file:../Model",
"npm": "^8.18.0",
"moment-timezone": "^0.5.43",
"npm": "^9.6.3",
"prismjs": "^1.29.0",
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
"react-big-calendar": "^1.8.5",
"react-color": "^2.19.3",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
@ -28143,7 +28156,7 @@
"Common": "file:../Common",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typeorm": "^0.3.7"
"typeorm": "^0.3.17"
}
},
"mrmime": {
@ -31637,11 +31650,16 @@
}
},
"typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"dev": true,
"peer": true
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true
},
"typescript-remove-decorators-transformer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/typescript-remove-decorators-transformer/-/typescript-remove-decorators-transformer-1.0.1.tgz",
"integrity": "sha512-nNj79TVUK6SV7rAo2w6k0nrd774uLPz47TWeTH5jsEYbRcmKJKsoM1TX7gra7P/a3AoHLQt3n6fZAQtonOkYyw==",
"dev": true
},
"unbox-primitive": {
"version": "1.0.2",

View File

@ -59,6 +59,7 @@
"sass-loader": "^12.6.0",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.1",
"typescript-remove-decorators-transformer": "^1.0.1",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^4.9.2",

View File

@ -20,7 +20,7 @@ enum PageMap {
PREVIEW_ANNOUNCEMENT_LIST = 'PREVIEW_ANNOUNCEMENT_LIST',
PREVIEW_SCHEDULED_EVENT_LIST = 'PREVIEW_SCHEDULED_EVENT_LIST',
PREVIEW_SCHEDULED_EVENT_DETAIL = 'PREVIEW_SCHEDULED_EVENT_DETAIL',
PREVIEW_RSS = 'RSS',
PREVIEW_RSS = 'PREVIEW_RSS',
PREVIEW_SUBSCRIBE_EMAIL = 'PREVIEW_SUBSCRIBE_EMAIL',
PREVIEW_SUBSCRIBE_SMS = 'PREVIEW_SUBSCRIBE_SMS',
PREVIEW_SUBSCRIBE_WEBHOOKS = 'PREVIEW_SUBSCRIBE_WEBHOOKS',

View File

@ -3,6 +3,7 @@ const webpack = require("webpack");
const dotenv = require('dotenv');
const express = require('express');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const removeDecoratorsTransformer = require('typescript-remove-decorators-transformer').default;
const readEnvFile = (pathToFile) => {
@ -48,7 +49,26 @@ module.exports = {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader'
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [
removeDecoratorsTransformer([
'Entity',
'Column',
'Index',
'ManyToOne',
'JoinColumn',
'ManyToMany',
'JoinTable',
'PrimaryGeneratedColumn',
'CreateDateColumn',
'UpdateDateColumn',
'DeleteDateColumn',
'VersionColumn',
])]
}),
},
},
{
test: /\.s[ac]ss$/i,