Skip to content

Commit

Permalink
perf: reduce bundle size (#4315)
Browse files Browse the repository at this point in the history
Co-authored-by: Maël Nison <[email protected]>
(cherry picked from commit a50d10c)
  • Loading branch information
merceyz committed Oct 22, 2023
1 parent cbf3ff3 commit 5b238a8
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 17 deletions.
30 changes: 15 additions & 15 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added .yarn/cache/ink-patch-a1ac5ddcf7-2c6d54e455.zip
Binary file not shown.
31 changes: 31 additions & 0 deletions .yarn/patches/ink-npm-3.0.8-3a8005f59f.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/build/ink.js b/build/ink.js
index f292bccdd049835ded848da83a6daac1e4f70416..54c4ebf36dc0c8f7f2580a5e69869848c83dc46f 100644
--- a/build/ink.js
+++ b/build/ink.js
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
-const lodash_1 = require("lodash");
+const lodash_1_throttle = require("lodash/throttle");
const log_update_1 = __importDefault(require("./log-update"));
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
const is_ci_1 = __importDefault(require("is-ci"));
@@ -90,7 +90,7 @@ class Ink {
this.rootNode = dom.createNode('ink-root');
this.rootNode.onRender = options.debug
? this.onRender
- : lodash_1.throttle(this.onRender, 32, {
+ : lodash_1_throttle(this.onRender, 32, {
leading: true,
trailing: true
});
@@ -98,7 +98,7 @@ class Ink {
this.log = log_update_1.default.create(options.stdout);
this.throttledLog = options.debug
? this.log
- : lodash_1.throttle(this.log, undefined, {
+ : lodash_1_throttle(this.log, undefined, {
leading: true,
trailing: true
});
24 changes: 24 additions & 0 deletions .yarn/versions/4bdc9471.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
releases:
"@yarnpkg/builder": patch
"@yarnpkg/cli": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"typescript": "5.2.0-beta"
},
"resolutions": {
"ink": "patch:ink@npm%3A3.0.8#./.yarn/patches/ink-npm-3.0.8-3a8005f59f.patch",
"yoga-layout-prebuilt": "patch:[email protected]#./.yarn/patches/yoga-layout-prebuilt.patch"
},
"dependenciesMeta": {
Expand Down
16 changes: 15 additions & 1 deletion packages/yarnpkg-builder/sources/commands/build/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,21 @@ export default class BuildBundleCommand extends Command {
},
entryPoints: [path.join(basedir, `sources/cli.ts`)],
bundle: true,
define: {YARN_VERSION: JSON.stringify(version)},
define: {
YARN_VERSION: JSON.stringify(version),
...(this.noMinify ? {} : {
// For React
'process.env.NODE_ENV': JSON.stringify(`production`),
// For ink
'process.env.DEV': JSON.stringify(`false`),
// For ourselves
'process.env.TEST_ENV': `false`,
// mkdirp
'process.env.__TESTING_MKDIRP_PLATFORM__': `false`,
'process.env.__TESTING_MKDIRP_NODE_VERSION__': `false`,
'process.env.__FAKE_PLATFORM__': `false`,
}),
},
outfile: output,
// Default extensions + .mjs
resolveExtensions: [`.tsx`, `.ts`, `.jsx`, `.mjs`, `.js`, `.css`, `.json`],
Expand Down
39 changes: 38 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15130,7 +15130,7 @@ __metadata:
languageName: node
linkType: hard

"ink@npm:^3.0.8":
"ink@npm:3.0.8":
version: 3.0.8
resolution: "ink@npm:3.0.8"
dependencies:
Expand Down Expand Up @@ -15167,6 +15167,43 @@ __metadata:
languageName: node
linkType: hard

"ink@patch:ink@npm%3A3.0.8#./.yarn/patches/ink-npm-3.0.8-3a8005f59f.patch::locator=%40yarnpkg%2Fmonorepo%40workspace%3A.":
version: 3.0.8
resolution: "ink@patch:ink@npm%3A3.0.8#./.yarn/patches/ink-npm-3.0.8-3a8005f59f.patch::version=3.0.8&hash=2bdc6c&locator=%40yarnpkg%2Fmonorepo%40workspace%3A."
dependencies:
ansi-escapes: ^4.2.1
auto-bind: 4.0.0
chalk: ^4.1.0
cli-boxes: ^2.2.0
cli-cursor: ^3.1.0
cli-truncate: ^2.1.0
code-excerpt: ^3.0.0
indent-string: ^4.0.0
is-ci: ^2.0.0
lodash: ^4.17.20
patch-console: ^1.0.0
react-devtools-core: ^4.6.0
react-reconciler: ^0.24.0
scheduler: ^0.18.0
signal-exit: ^3.0.2
slice-ansi: ^3.0.0
stack-utils: ^2.0.2
string-length: ^3.1.0
type-fest: ^0.12.0
widest-line: ^3.1.0
wrap-ansi: ^6.2.0
ws: ^7.2.5
yoga-layout-prebuilt: ^1.9.6
peerDependencies:
"@types/react": ">=16.8.0"
react: ">=16.8.0"
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 2c6d54e455d2305fa060811ec38a1312adcf58aa81cb4c16e7fbd78cfd9bd2754ac22db94491baa04485e8d97fca352fb6231d39a975559a932d489b2029dbe4
languageName: node
linkType: hard

"inline-style-parser@npm:0.1.1":
version: 0.1.1
resolution: "inline-style-parser@npm:0.1.1"
Expand Down

0 comments on commit 5b238a8

Please sign in to comment.