-
Notifications
You must be signed in to change notification settings - Fork 76
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
As a Builder, I want package tree-shaking, so I can minimize my build size, compile time, test time, and page load time. #1148
Comments
@skiv71 discovered that when we configure |
We've discussed this task a lot this past week, despite it not being part of the sprint. I've decided to move it into this sprint so that we can implement it and move on. |
While working on this, I disabled Webpack. I think that we'll remove Webpack as part of this task so I've added #1203 as a subtask in the description. |
The effort required to fix this is larger than anticipated and upon closer inspection, we realize that tree-shaking will still be blocked by #1202 even after switching to ES Modules. Thus, we still want to do this task, but I'm reducing the priority to Medium. |
Problem
tsconfig.json
specifies"module": "commonjs"
. This prevents tree-shaking, or the elimination of dead code.According to the webpack docs:
Solution
Set
"module": "node16"
and"moduleResolution": "node16"
in thetsconfig.json
For compatibility with Node.js so users who require
CommonJS
can get it, but consumers of our bundled packages will get ES2020 and can do tree-shaking."module": "node16"
"moduleResolution": "node16"
Append
.js
to all relative imports filenamesSet
"type": "module"
in allpackage.json
filesDefiniton of Done
Non Issues
Currently, the Request Network packages take advantage of the monorepo to directly import source files instead of respecting the package separation. This means that build tools and bundlers cannot perform "tree-shaking" which removes unnecessary dependencies from the final distribution.This is not true. See Eliminate relative imports between packages and enforce monorepo/no-relative-import eslint rule #1194Migrated from Asana: https://app.asana.com/0/1203912381456855/1205320821557402
The text was updated successfully, but these errors were encountered: