Repository navigation
IP pool utilization - #2078
IP pool utilization#2078
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| [23094304823948203952304920342n, '23.1E27'], | ||
| ])('displayBigNum %d -> %s', (input, output) => { | ||
| expect(displayBigNum(input)).toEqual(output) | ||
| }) |
There was a problem hiding this comment.
these bigint literals are the reason for the target: es2020 bump in the tsconfig
| "sourceMap": true, | ||
| "strict": true, | ||
| "target": "es2015", | ||
| "target": "es2020", |
There was a problem hiding this comment.
This is so we can use bigint literals, e.g., 1123901234n. target seems primarily relevant in that it determines lib if you're not also setting lib (we are not). There is no change in our bundle size from this, which is weird. Will add more detail to this comment later.
https://www.typescriptlang.org/tsconfig#target
https://www.typescriptlang.org/tsconfig#lib
There was a problem hiding this comment.
According to the compat table (ironically, works poorly in FF but well in Chrome), these are the features for each version:
These are the ones for es2020 specifically, and they all have been supported since 2019 or early 2020.
- https://caniuse.com/mdn-javascript_builtins_string_matchall
- https://caniuse.com/bigint
- https://caniuse.com/mdn-javascript_builtins_promise_allsettled
- https://caniuse.com/mdn-javascript_builtins_globalthis
- https://caniuse.com/mdn-javascript_operators_optional_chaining
- https://caniuse.com/mdn-javascript_operators_nullish_coalescing
I looked through most of the other features and I think we could go as high as es2022, but I don't think there's much advantage to doing that.
There was a problem hiding this comment.
Ah. Of course. This explains why it had no effect on bundle size.
We should also note that TypeScript's target only impacts your runtime code if you're using TypeScript to transpile your source files to JavaScript. If you're using another tool to transpile, such as Babel, ESBuild, or SWC, then that tool's settings will be what determines the syntax used in your output JavaScript code.
I'm embarrassed not to have known this, but here's how Vite handles it.
build.target
Browser compatibility target for the final bundle. The default value is a Vite special value, 'modules', which targets browsers with native ES Modules, native ESM dynamic import, and import.meta support. Vite will replace 'modules' to ['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14']
Note the build will fail if the code contains features that cannot be safely transpiled by esbuild. See esbuild docs for more details.
Note that by default, Vite only handles syntax transforms and does not cover polyfills.
The linked page from the esbuild docs about what features are in what version is better than anything I found yesterday while researching this stuff.
It also gave me a good example of too-new syntax to test it with:
x Build failed in 7.97s
error during build:
Error: [vite:esbuild-transpile] Transform failed with 1 error:
assets/app-!~{001}~.js:62912:0: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
62910| };
62911| const colHelper = createColumnHelper();
62912| await new Promise((res) => res(1));
| ^
62913| function SiloAccessPage() {
62914| const [addModalOpen, setAddModalOpen] = reactExports.useState(false);
Conclusion
So in theory, Vite has us covered for making sure we are okay on syntax, and TS target should prevent us from using new built-in things we can't use. That said, I couldn't find a good example of something like that being rejected by TS.
a1cba60 to
001662c
Compare
8c864ec to
9f64b6d
Compare
| {allocated.toLocaleString()} | ||
| <div className="text-quaternary">{capacityLabel}</div> | ||
| <div className="!normal-case text-secondary"> | ||
| {displayBigNum(capacity)} |
There was a problem hiding this comment.
This component is getting out of hand. I will make an issue about breaking it up into composable components.
d781818 to
f83e616
Compare
f83e616 to
541be68
Compare
| const percentage = | ||
| typeof provisioned === 'bigint' | ||
| ? (provisioned * 100n) / (capacity as bigint) // TS is being a jerk | ||
| : (provisioned * 100) / capacity |
There was a problem hiding this comment.
I’m going to pull this logic out into a function so I can unit test the hell out of it.
0bfba53 to
87417eb
Compare
| import { percentage, splitDecimal } from '~/util/math' | ||
|
|
||
| export const CapacityBar = ({ | ||
| export const CapacityBar = <T extends number | bigint>({ |
There was a problem hiding this comment.
generic is so we can let provisioned and allocated be number | bigint while enforcing that they are the same type
| <IpUtilFrac {...ipv4} /> | ||
| </div> | ||
| ) | ||
| } |
There was a problem hiding this comment.
This should be what users see because they almost certainly have no IPv6 ranges.
| </div> | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
took a slightly different approach here than the possibly too clever "if there is IPv6, show both, otherwise just show IPv4 with no v4 label" in the table cell. Here we just show whichever ones are present, including possibly both or none.
| // the point of these tests is to make sure the toLowerCase shenanigan in | ||
| // toEngNotation doesn't go horribly wrong due some obscure locale's concept of | ||
| // engineering notation |
There was a problem hiding this comment.
Love that you included these
oxidecomputer/console@784e8aa...7c96844 * [7c968443](oxidecomputer/console@7c968443) oxidecomputer/console#2083 * [b844a42c](oxidecomputer/console@b844a42c) oxidecomputer/console#2078 * [47835ee3](oxidecomputer/console@47835ee3) oxidecomputer/console#2086 * [c4ddebc2](oxidecomputer/console@c4ddebc2) oxidecomputer/console#2082 * [530a0997](oxidecomputer/console@530a0997) upload-artifact@v4 requires unique filenames for each run in matrix * [b996c34c](oxidecomputer/console@b996c34c) bump actions/upload-artifact to v4 * [bc51f530](oxidecomputer/console@bc51f530) bump API to latest main * [743da3b0](oxidecomputer/console@743da3b0) oxidecomputer/console#2080 * [7596d633](oxidecomputer/console@7596d633) oxidecomputer/console#2073 * [65531bff](oxidecomputer/console@65531bff) oxidecomputer/console#2074 * [4d226cd3](oxidecomputer/console@4d226cd3) oxidecomputer/console#1891 * [7490104a](oxidecomputer/console@7490104a) update readme with cool new preview URL * [a2218994](oxidecomputer/console@a2218994) oxidecomputer/console#2066 * [641ebe85](oxidecomputer/console@641ebe85) oxidecomputer/console#2061 * [1bb8dd3a](oxidecomputer/console@1bb8dd3a) oxidecomputer/console#2055 * [41dd9f06](oxidecomputer/console@41dd9f06) oxidecomputer/console#2059 * [04692802](oxidecomputer/console@04692802) oxidecomputer/console#2048 * [8c30305e](oxidecomputer/console@8c30305e) oxidecomputer/console#2050 * [53709d2a](oxidecomputer/console@53709d2a) oxidecomputer/console#2046 * [84caede7](oxidecomputer/console@84caede7) oxidecomputer/console#2026 * [bca9f42a](oxidecomputer/console@bca9f42a) oxidecomputer/console#2045 * [09e5f713](oxidecomputer/console@09e5f713) oxidecomputer/console#2043 * [d780e5d8](oxidecomputer/console@d780e5d8) fix casing on floating IP attach/detach toasts
oxidecomputer/console@784e8aa...7c96844 * [7c968443](oxidecomputer/console@7c968443) oxidecomputer/console#2083 * [b844a42c](oxidecomputer/console@b844a42c) oxidecomputer/console#2078 * [47835ee3](oxidecomputer/console@47835ee3) oxidecomputer/console#2086 * [c4ddebc2](oxidecomputer/console@c4ddebc2) oxidecomputer/console#2082 * [530a0997](oxidecomputer/console@530a0997) upload-artifact@v4 requires unique filenames for each run in matrix * [b996c34c](oxidecomputer/console@b996c34c) bump actions/upload-artifact to v4 * [bc51f530](oxidecomputer/console@bc51f530) bump API to latest main * [743da3b0](oxidecomputer/console@743da3b0) oxidecomputer/console#2080 * [7596d633](oxidecomputer/console@7596d633) oxidecomputer/console#2073 * [65531bff](oxidecomputer/console@65531bff) oxidecomputer/console#2074 * [4d226cd3](oxidecomputer/console@4d226cd3) oxidecomputer/console#1891 * [7490104a](oxidecomputer/console@7490104a) update readme with cool new preview URL * [a2218994](oxidecomputer/console@a2218994) oxidecomputer/console#2066 * [641ebe85](oxidecomputer/console@641ebe85) oxidecomputer/console#2061 * [1bb8dd3a](oxidecomputer/console@1bb8dd3a) oxidecomputer/console#2055 * [41dd9f06](oxidecomputer/console@41dd9f06) oxidecomputer/console#2059 * [04692802](oxidecomputer/console@04692802) oxidecomputer/console#2048 * [8c30305e](oxidecomputer/console@8c30305e) oxidecomputer/console#2050 * [53709d2a](oxidecomputer/console@53709d2a) oxidecomputer/console#2046 * [84caede7](oxidecomputer/console@84caede7) oxidecomputer/console#2026 * [bca9f42a](oxidecomputer/console@bca9f42a) oxidecomputer/console#2045 * [09e5f713](oxidecomputer/console@09e5f713) oxidecomputer/console#2043 * [d780e5d8](oxidecomputer/console@d780e5d8) fix casing on floating IP attach/detach toasts
Nothing in the repo references these packages any more. The lockfile goes from 709 to 704 entries. `tslib` and `@react-router/node` stay installed as dependencies of other packages, so for those two this only tidies `package.json`. Lint, tsc, build, and the vitest suite pass. I did not run e2e locally. - `tslib` came from the Nx generator that created the repo ([source](https://github.com/nrwl/nx/blob/313552b/packages/react/src/schematics/init/init.ts#L55-L61)), along with `importHelpers: true` in tsconfig, which tells tsc to import helpers like `__awaiter` from tslib instead of inlining them. tsc never emitted our build (that was Babel, then Vite), but with `importHelpers` on, typechecking fails with TS2354 if tslib can't be resolved and the target needs a helper, as ours did while it was es2015. #2078 raised the target to es2020 and #3075 removed `importHelpers`. It is still installed through `@peculiar/x509` and others. - `@tailwindcss/container-queries` was added in #2654 for the `@container` and `@[48rem]:` variants on the instance metrics tabs, loaded as a plugin in `tailwind.config.ts`. Tailwind 4 [has container queries built in](https://github.com/tailwindlabs/tailwindcss-container-queries/blob/7a968b3/README.md?plain=1#L1-L2), and #2910 deleted the config file that loaded the plugin but left the package. - `@tanstack/react-query-devtools` was added in #1238 to show the React Query devtools panel in dev. It was commented out in cc67cff to keep it out of screenshots, and #3400 deleted the commented-out lines. - `react-is` and `@types/react-is` also came from the Nx generator, which adds them alongside styled-components ([source](https://github.com/nrwl/nx/blob/313552b/packages/react/src/utils/styled.ts#L18-L28)) because styled-components 5 has react-is as a peer dependency. We replaced styled-components with emotion in 451bef6. `@reach/menu-button` 0.16 also had react-is as a peer dependency until #1395 replaced it with Radix, and no package in the lockfile has had one since. Nothing in the repo has ever imported react-is, so the types were never used. - `@react-router/node` was added in #3400, following the [React Router SPA guide](https://github.com/remix-run/react-router/blob/f482813/docs/how-to/spa.md#L38), which says a project needs it for the build-time render of `index.html`. Our `entry.server.tsx` uses web streams and doesn't import it, and `@react-router/dev` already depends on the exact same version, so it stays installed.
Closes #2070
and v6counts in properties table on IP pool detail2024-03-20-ip-pool-utilization.mp4