Skip to content

rustdoc: use webpack to bundle code #51735

Closed
@ishitatsuyuki

Description

@ishitatsuyuki

webpack is the most popular script bundler for JavaScript and other assets.

With webpack, we can benefit from:

  • Transpilation of ES6 or TypeScript
  • Code splitting/dynamic imports
  • Effortless code minification
  • Eliminating the need of resource-suffix with chunk hash

However, this adds the requirement of Node.js + NPM to the build dependencies. We need to care about:

  • How to execute webpack
  • How to bundle (vendor) node_modules

Below are some implementation notes:

  • In rustdoc's build scripts we run webpack and then generate the code for including into the binary. Example:
resources.insert("bundle.ef0d81c.js", include_bytes!(concat!(env!("OUT_DIR"), "bundle.ef0d81c.js")));

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.T-releaseRelevant to the release subteam, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions