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

speed up the installation of dependencies #1030

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

DudaGod
Copy link
Member

@DudaGod DudaGod commented Nov 15, 2024

What is done:

  • reinstall webdriverio, @wdio/utils and devtools in order to update locate-app instade package-lock, which was weight ~30mb. Now it weights 1.7 mb
  • start to bundle glob-extra and @wdio/utils-cjs in order to reduce weight of packages and do not install them from npm
  • remove @wdio/globals which not used anymore
  • move @types packages from deps to dev deps

As a result:

  • production node_modules weights on 31% less (217mb vs 314 mb)
  • production deps installed on 16% faster (18.6 sec vs 22.32 sec). Check on 5 runs on master and current branch, use command - time npm i --production and rm -rf node_modules && npm cache clean -f before each install

@DudaGod DudaGod force-pushed the TESTPLANE-328.speed_up_install branch 6 times, most recently from 3aa57fa to 8c8a112 Compare November 20, 2024 11:57
Comment on lines +1 to +2
/* eslint-disable @typescript-eslint/no-var-requires */
const bundle = require("./cjs");
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use require here?
If import does not work here, i think const bundle = import("./cjs") would.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can use import, but then typescript build this file and store it inside build folder. And it's not a big problem, but it will not be used in production code. In production code only final bundle file is used. So because of this, I use require here.

Copy link
Member

Choose a reason for hiding this comment

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

And now typescript wouldn't build this file?

src/test-reader/sets-builder/index.ts Show resolved Hide resolved
"@vitest/spy": "2.1.4",
"@wdio/globals": "8.39.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Do not used anymore, so I remove it

"@wdio/utils": "8.39.0",
"@wdio/utils-cjs": "npm:@wdio/[email protected]",
Copy link
Member Author

Choose a reason for hiding this comment

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

Move to dev deps, because now I bundle this package using esbuild

@@ -73,10 +68,8 @@
"fs-extra": "5.0.0",
"gemini-configparser": "1.4.1",
"get-port": "5.1.1",
"glob-extra": "5.0.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

Move to dev deps. This package now also bundled

@@ -54,14 +54,9 @@
"@babel/code-frame": "7.24.2",
"@gemini-testing/commander": "2.15.4",
"@jspm/core": "2.0.1",
"@types/debug": "4.1.12",
"@types/yallist": "4.0.4",
Copy link
Member Author

Choose a reason for hiding this comment

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

All these types packages should be declared in dev deps

@@ -1,7 +1,5 @@
import crypto from "crypto";
import { RequestOptions } from "https";

import { RemoteCapability } from "@wdio/types/build/Capabilities";
Copy link
Member Author

Choose a reason for hiding this comment

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

Found solution how to remove this hack

);
}
export const setupTransformHook: (opts?: { removeNonJsImports?: boolean }) => VoidFunction = bundle.setupTransformHook;
export const TRANSFORM_EXTENSIONS: string[] = bundle.TRANSFORM_EXTENSIONS;
Copy link
Member Author

Choose a reason for hiding this comment

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

Now here I just reexport necessary methods

src/base-testplane.ts Outdated Show resolved Hide resolved
@@ -110,14 +104,15 @@
"@commitlint/config-conventional": "^19.0.3",
"@cspotcode/source-map-support": "0.8.0",
"@sinonjs/fake-timers": "10.3.0",
"@swc/core": "1.3.40",
"@swc/core": "1.9.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

Install fresh version of swc/core. Because with old version I got errors in CI builds.

Comment on lines +1 to +2
/* eslint-disable @typescript-eslint/no-var-requires */
const bundle = require("./cjs");
Copy link
Member Author

Choose a reason for hiding this comment

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

I can use import, but then typescript build this file and store it inside build folder. And it's not a big problem, but it will not be used in production code. In production code only final bundle file is used. So because of this, I use require here.

src/test-reader/sets-builder/index.ts Show resolved Hide resolved
@DudaGod
Copy link
Member Author

DudaGod commented Nov 27, 2024

Oh, I forgot to send comments, which I wrote when publish this PR =(

@DudaGod DudaGod force-pushed the TESTPLANE-328.speed_up_install branch from 8c8a112 to 3e7dc91 Compare November 27, 2024 11:22
@DudaGod DudaGod merged commit c3a362a into master Nov 27, 2024
2 checks passed
@DudaGod DudaGod deleted the TESTPLANE-328.speed_up_install branch November 27, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants