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

refactor(v2): TS config update: reduce the size of npm modules #4375

Merged
merged 6 commits into from
Mar 17, 2021
Merged

refactor(v2): TS config update: reduce the size of npm modules #4375

merged 6 commits into from
Mar 17, 2021

Conversation

RDIL
Copy link
Contributor

@RDIL RDIL commented Mar 9, 2021

Signed-off-by: Reece Dunham [email protected]

Motivation

Right now, @docusaurus/core is 1.36mb, which seems a bit big for just the core files. This reduces the size of a number of the packages by doing a number of things:

  • Updates the TypeScript target to ES2019 from ES2017, since Node 12 is now the required minimum for D2. This means that some modern syntax features don't need to be polyfilled.
  • Changes the TypeScript compiler settings to avoid writing out helper functions like this just to use the spread operator:
__rest = function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function") {
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    }
    return t;
};

To instead just import it from tslib, reducing code duplication.

  • Disabling the generation of source maps from .d.ts files, which is just unneeded since the .d.ts are generated in the first place. They are essentially their own source maps.
  • Update TypeScript to v4.1.5

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Everything appears to be fine.

Related PRs

n/a

@RDIL RDIL requested review from lex111 and slorber as code owners March 9, 2021 16:20
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 9, 2021
@netlify
Copy link

netlify bot commented Mar 9, 2021

[V1] Deploy preview success

Built with commit 10502d3

https://deploy-preview-4375--docusaurus-1.netlify.app

@netlify
Copy link

netlify bot commented Mar 9, 2021

Deploy preview for docusaurus-2 ready!

Built with commit 10502d3

https://deploy-preview-4375--docusaurus-2.netlify.app

@armano2

This comment has been minimized.

@RDIL
Copy link
Contributor Author

RDIL commented Mar 10, 2021

@armano2 I actually was looking into this, but honestly I just wanted something that worked. Maybe I'll make something like babel-plugin-transform-tslib-runtime.

@github-actions
Copy link

github-actions bot commented Mar 15, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 73
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4375--docusaurus-2.netlify.app/classic/

@slorber slorber added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 17, 2021
@slorber slorber changed the title feat(v2): Reduce the size of the npm modules refactor(v2): Reduce the size of the npm modules Mar 17, 2021
@slorber slorber changed the title refactor(v2): Reduce the size of the npm modules refactor(v2): TS config update to reduce the size of the npm modules Mar 17, 2021
# Conflicts:
#	packages/docusaurus-plugin-debug/package.json
#	packages/docusaurus-theme-common/package.json
@slorber slorber changed the title refactor(v2): TS config update to reduce the size of the npm modules refactor(v2): TS config update: reduce the size of npm modules Mar 17, 2021
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

tsconfig.json Show resolved Hide resolved
@slorber slorber merged commit 76c0b11 into facebook:master Mar 17, 2021
@RDIL RDIL deleted the typescript-bundle-improvements branch March 17, 2021 15:26
@RDIL
Copy link
Contributor Author

RDIL commented Mar 17, 2021

This reduces the size of the core to 803 kilobytes, a save of 1.1 megabytes 🎉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants