CAFECA-IO / TideBit-DeFi

TideBit Decentralize Finance Version
https://tidebit-defi.vercel.app
GNU General Public License v3.0
1 stars 0 forks source link

[refactor] Edge runtime for Node.js API #1410

Closed arealclimber closed 12 months ago

arealclimber commented 1 year ago

edge runtime 警告訊息,image response import common.ts 的特定 function時,當 common.ts其他 function存在不被 edge runtime 支持的 API,則會出現以下訊息。

% npm run build

> src@0.8.0+66.1 build
> next build

info  - Loaded env from /Users/shirley/programming/cafeca/tidebit-defi-dev/.env
info  - Linting and checking validity of types  
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
info  - Creating an optimized production build .<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (659kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
warn  - Compiled with warnings

./node_modules/@cafeca/keccak/dist/index.js
A Node.js API is used (Buffer at line: 76) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/@cafeca/keccak/dist/index.js
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./node_modules/@cafeca/keccak/dist/index.js
A Node.js API is used (Buffer at line: 99) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/@cafeca/keccak/dist/index.js
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./src/lib/common.ts
A Node.js API is used (Buffer at line: 333) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./src/lib/common.ts
A Node.js API is used (Buffer at line: 338) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./src/lib/common.ts
A Node.js API is used (Buffer at line: 345) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./src/lib/common.ts
A Node.js API is used (Buffer at line: 350) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./src/lib/common.ts
A Node.js API is used (Buffer at line: 358) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./src/lib/common.ts
./src/interfaces/tidebit_defi_background/sharing_order.ts

./node_modules/next/dist/server/web/spec-extension/image-response.js
A Node.js API is used (process.turbopack at line: 47) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/next/dist/server/web/spec-extension/image-response.js
./node_modules/next/dist/server/web/exports/image-response.js

info  - Collecting page data  
info  - Generating static pages (84/84)
info  - Finalizing page optimization  

Route (pages)                              Size     First Load JS
┌ ● /                                      8.65 kB         460 kB
├   /_app                                  0 B             442 kB
├ ○ /404                                   53.9 kB         505 kB
├ ● /500                                   54.6 kB         506 kB
├ λ /api/hello                             0 B             442 kB
├ ℇ /api/images/badge/[badgeId]            0 B             442 kB
├ ℇ /api/images/cfd/[cfdId]                0 B             442 kB
├ λ /api/proxy                             0 B             442 kB
├ λ /api/pusher/auth                       0 B             442 kB
├ λ /api/user/balances                     0 B             442 kB
├ λ /api/user/histories                    0 B             442 kB
├ λ /api/user/tickers                      0 B             442 kB
├ ● /coming-soon                           56.6 kB         508 kB
├ ● /leaderboard                           4.12 kB         455 kB
├ ● /my-assets                             11.9 kB         464 kB
├ ● /news                                  2.49 kB         454 kB
├ ● /news/[newsId] (2180 ms)               2.16 kB         453 kB
├   ├ /tw/news/news-btc-20230707001
├   ├ /en/news/news-btc-20230707001
├   ├ /cn/news/news-btc-20230707001
├   └ [+54 more paths]
├ λ /share/badge/[badgeId]                 1.19 kB         443 kB
├ λ /share/cfd/[cfdId]                     1.05 kB         443 kB
└ ● /trade/cfd/[instId] (517 ms)           67.7 kB         518 kB
    ├ /tw/trade/cfd/eth-usdt (319 ms)
    ├ /en/trade/cfd/eth-usdt
    ├ /cn/trade/cfd/eth-usdt
    ├ /tw/trade/cfd/btc-usdt
    ├ /en/trade/cfd/btc-usdt
    └ /cn/trade/cfd/btc-usdt
+ First Load JS shared by all              458 kB
  ├ chunks/framework-2c79e2a64abdb08b.js   45.2 kB
  ├ chunks/main-fc32d4de6efcc99e.js        27.8 kB
  ├ chunks/pages/_app-bb54d6b7885ff687.js  367 kB
  ├ chunks/webpack-57940facedc48128.js     1.73 kB
  └ css/0f5cec3610acf32b.css               15.7 kB

ℇ  (Streaming)  server-side renders with streaming (uses React 18 SSR streaming or Server Components)
λ  (Server)     server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)     automatically rendered as static HTML (uses no initial props)
●  (SSG)        automatically generated as static HTML + JSON (uses getStaticProps)

info  - Creating an optimized production build ..%
arealclimber commented 1 year ago

taking 5 hrs

嘗試區隔給 edge runtime 用的 helper function,但無效,最後嘗試升級 Next.js,則可修正警告訊息

修正後,執行 npm run build 可得以下結果

image