Skip to content

Commit 9f7ba5b

Browse files
authored
add node fiber to improve performance (#2319)
For issue [#2223](#2223), in order to solve the slow compilation time that is caused by changing from node-sass to dart-sass, one possible solution is to add a node-fibers package. Pulling from the sass official website, "to avoid this performance hit, render() can use the fibers package to call asynchronous importers from the synchronous code path". And i have validated the performance improvement: the first compilation changed to 76s from the previous 409s. However, node-fiber package has reached end of life with Node 16. If the performance issue is a problem, we can consider stay on Node 14 and use node-fiber for now, and remove fibers when migrating to Node 16 later. Issue resolved: #2223 Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
1 parent b1325ea commit 9f7ba5b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

packages/osd-optimizer/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@
2626
"dedent": "^0.7.0",
2727
"del": "^5.1.0",
2828
"execa": "^4.0.2",
29+
"fibers": "^5.0.3",
2930
"file-loader": "^4.2.0",
3031
"jest-diff": "^27.5.1",
3132
"js-yaml": "^3.14.0",
3233
"json-stable-stringify": "^1.0.1",
3334
"lmdb-store": "^1.6.11",
3435
"loader-utils": "^1.2.3",
35-
"sass": "~1.26.11",
3636
"normalize-path": "^3.0.0",
3737
"pirates": "^4.0.1",
3838
"postcss": "^8.4.5",
3939
"postcss-loader": "^4.2.0",
4040
"raw-loader": "^4.0.2",
4141
"rxjs": "^6.5.5",
42+
"sass": "~1.26.11",
4243
"sass-loader": "^10.2.0",
4344
"source-map-support": "^0.5.19",
4445
"style-loader": "^1.1.3",

packages/osd-optimizer/src/worker/webpack.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
181181
outputStyle: 'compressed',
182182
includePaths: [Path.resolve(worker.repoRoot, 'node_modules')],
183183
sourceMapRoot: `/${bundle.type}:${bundle.id}`,
184+
fiber: require('fibers'),
184185
},
185186
},
186187
},

yarn.lock

+15-3
Original file line numberDiff line numberDiff line change
@@ -7025,6 +7025,11 @@ detect-indent@^5.0.0:
70257025
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
70267026
integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50=
70277027

7028+
detect-libc@^1.0.3:
7029+
version "1.0.3"
7030+
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
7031+
integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==
7032+
70287033
detect-newline@2.X:
70297034
version "2.1.0"
70307035
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
@@ -8406,6 +8411,13 @@ fetch-mock@^7.3.9:
84068411
path-to-regexp "^2.2.1"
84078412
whatwg-url "^6.5.0"
84088413

8414+
fibers@^5.0.3:
8415+
version "5.0.3"
8416+
resolved "https://registry.yarnpkg.com/fibers/-/fibers-5.0.3.tgz#2fd03acb255db66fe693d15beafbf5ae92193fd7"
8417+
integrity sha512-/qYTSoZydQkM21qZpGLDLuCq8c+B8KhuCQ1kLPvnRNhxhVbvrpmH9l2+Lblf5neDuEsY4bfT7LeO553TXQDvJw==
8418+
dependencies:
8419+
detect-libc "^1.0.3"
8420+
84098421
figgy-pudding@^3.5.1:
84108422
version "3.5.2"
84118423
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
@@ -14306,9 +14318,9 @@ punycode@^1.2.4, punycode@^1.3.2:
1430614318
integrity sha1-wNWmOycYgArY4esPpSachN1BhF4=
1430714319

1430814320
qs@6.9.3, qs@^6.10.1, qs@^6.10.3, qs@~6.5.2:
14309-
version "6.10.3"
14310-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e"
14311-
integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==
14321+
version "6.11.0"
14322+
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
14323+
integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==
1431214324
dependencies:
1431314325
side-channel "^1.0.4"
1431414326

0 commit comments

Comments
 (0)