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 scaffolding process #3077

Open
haoqunjiang opened this issue Dec 4, 2018 · 13 comments
Open

Speed up scaffolding process #3077

haoqunjiang opened this issue Dec 4, 2018 · 13 comments

Comments

@haoqunjiang
Copy link
Member

What problem does this feature solve?

Current installed size of default preset:

  • with yarn: 154M
  • with npm: 165M

and 20k files in node_modules.

The installation process takes at least tens of seconds to finish, let alone fresh installs without cache.

What does the proposed API look like?

There're several ways to speed up dependency installation:

PNPM Support

Blocked by #2703

Yarn Plug'n'Play Support

Tracked at #2850
Blocked by yarnpkg/yarn#6487

Reducing the number and size of indirect dependencies

Current installed size of core packages:

Could be done by bundling dependencies into the published package itself.

Possible bundling tool:

Problems encountered:

  • Too many non-statically analyzable assets, hard to fix all the caveats
@haoqunjiang
Copy link
Member Author

Current @vue/cli-service deps:
97M, 11748 files

After extracting these deps (https://github.com/sodatea/vue-cli/blob/33c7c9f212f668e389b4abf231d706e9ea00b69a/packages/%40vue/cli-service-dependencies/package.json):

    "acorn": "^6.0.4",
    "acorn-walk": "^6.1.1",
    "address": "^1.0.3",
    "cliui": "^4.1.0",
    "debug": "^4.1.0",
    "fs-extra": "^7.0.1",
    "globby": "^8.0.1",
    "hash-sum": "^1.0.2",
    "launch-editor-middleware": "^2.2.1",
    "lodash.defaultsdeep": "^4.6.0",
    "lodash.mapvalues": "^4.6.0",
    "lodash.transform": "^4.6.0",
    "minimist": "^1.2.0",
    "ora": "^3.0.0",
    "portfinder": "^1.0.19",
    "read-pkg": "^4.0.1",
    "semver": "^5.6.0",
    "ssri": "^6.0.1",
    "string.prototype.padend": "^3.0.0",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "case-sensitive-paths-webpack-plugin": "^2.1.2",
    "webpack-merge": "^4.1.4",
    "copy-webpack-plugin": "^4.6.0",
    "terser-webpack-plugin": "^1.1.0"

92 + 3M, 11076 + 1 files

Still a long way to go……

@yyx990803
Copy link
Member

majority of it is probably webpack...

@yyx990803
Copy link
Member

Actually, measuring size and file count probably isn't the most reflective of the gains - saving network requests is also important.

@haoqunjiang
Copy link
Member Author

haoqunjiang commented Dec 5, 2018

  • webpack + webpack-dev-server + html-webpack-plugin take up ~51M (these ones can't be easily bundled because many packages rely on their internal structure)
  • cssnano alone takes 15M
  • All postcss-related stuff (including cssnano) takes ~30M

I think we'll get the best ROI by tackling all the postcss stuff.

@haoqunjiang
Copy link
Member Author

As for the network request, it's 982 -> 888 after the above-mentioned commit.

As a sidenote:

  • running npm i webpack installs 389 packages;
  • running npm i webpack webpack-dev-server 567 packages;
  • running npm i webpack webpack-dev-server html-webpack-plugin installs 648 packages.

Well… at least it's worth a try to bundle webpack-dev-server & html-webpack-plugin.

@haoqunjiang
Copy link
Member Author

After extracting webpack-dev-server, it's now 829 + 1 packages, node_modules size increased to 97M

@haoqunjiang
Copy link
Member Author

Extracting webpack-bundle-analyzer reduced the package number to 776.

@Kocal
Copy link
Contributor

Kocal commented Dec 7, 2018

Nice initiative 👍

@darrenjennings
Copy link
Contributor

On a cold install of vue-cli, I get a timeout on material-design-icons, related ticket: yarnpkg/yarn#5540

vue-cli/yarn.lock

Lines 2156 to 2162 in 09be0f2

"@vue/ui@^0.5.5":
version "0.5.6"
resolved "https://registry.yarnpkg.com/@vue/ui/-/ui-0.5.6.tgz#7c39b04a3b08ae3f217d2323987ae13347a90b29"
integrity sha512-NmxJsFk8umipCbKLusz6L27DQIicpt8jLOjN1aLjyBIeX3t4H5RFshxH7IUtjDPtgOYGwwq7gy86bmFkDDBsIQ==
dependencies:
focus-visible "^4.1.4"
material-design-icons "^3.0.1"

@haoqunjiang
Copy link
Member Author

nyc uses bundledDependencies.
istanbuljs/nyc#459
https://docs.npmjs.com/files/package.json#bundleddependencies
Worth a try.

@haoqunjiang
Copy link
Member Author

As of v3.6:
✅remove material-design-icons from @vue/ui deps
✅pnpm support

@FossPrime
Copy link
Contributor

pnpm support should not be written off... there are about 5 packages that wreack havoc on glitch with vue-cli. The workaround is to disable pnpm. Glitch runs vanilla pnpm by default. Which means broken packages with undefined dependencies are not acceptable. Not to mention using shamefully-flatten destroys performance.

@haoqunjiang
Copy link
Member Author

@rayfoss feel free to submit a bug report.
As for shamefully-flatten, it is a temporary workaround. We are still trying to find out a way to remove this flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants