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

fix: Remove devDependencies from RTS build #22239

Merged
merged 4 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions app/rts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
node_modules_bkp
.env
dist
14 changes: 12 additions & 2 deletions app/rts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ set -o errexit

cd "$(dirname "$0")"
rm -rf dist/
yarn install --frozen-lockfile
# Install node modules if not already installed
# This is required for the first time build as node_modules is not present in the image
! test -d "/node_modules" && yarn install --frozen-lockfile
sharat87 marked this conversation as resolved.
Show resolved Hide resolved
npx tsc && npx tsc-alias
# Keep copy of all dependencies in node_modules_bkp
mv node_modules node_modules_bkp
# Install only production dependencies
yarn install --production --frozen-lockfile
tsc_exit_code=$?
Copy link
Member

Choose a reason for hiding this comment

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

This gets the exit code of the last command, which was tsc-alias, but the last command has changed. In fact, this is actually not needed, let's remove this line, as well as the last exit $tsc_exit_code line. Neither of them are needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


# Copying node_modules directory into dist as rts server requires node_modules to run server build properly.
# Copying node_modules directory into dist as rts server requires production dependencies to run server build properly.
# This was previously being done in dockerfile which was copying the symlinks to image rather than the whole directory of shared modules (e.g. AST)
# Also, we copy node_modules with -L flag in order to follow the symlinks for @shared folder and copy the contents instead of just the symlink
cp -RL node_modules ./dist
# Delete production dependencies
rm -rf node_modules
# Restore all dependencies
mv node_modules_bkp node_modules
exit $tsc_exit_code
12 changes: 6 additions & 6 deletions app/shared/ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
},
"dependencies": {
"@babel/runtime": "^7.21.0",
"@rollup/plugin-commonjs": "^22.0.0",
"@types/escodegen": "^0.0.7",
"@types/lodash": "^4.14.120",
"acorn": "^8.8.0",
"acorn-walk": "^8.2.0",
"astravel": "^0.6.1",
Expand All @@ -29,21 +32,18 @@
"escodegen": "^2.0.0",
"lodash": "^4.17.21",
"rollup": "^2.77.0",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.32.0",
"typescript": "4.5.5",
"unescape-js": "^1.1.4"
},
"devDependencies": {
"@babel/preset-typescript": "^7.17.12",
"@rollup/plugin-commonjs": "^22.0.0",
"@types/escodegen": "^0.0.7",
"@types/jest": "29.0.3",
"@types/lodash": "^4.14.120",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"jest": "29.0.3",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.32.0",
"ts-jest": "29.0.1"
},
"author": "",
Expand Down