farm icon indicating copy to clipboard operation
farm copied to clipboard

Farm Roadmap v2.0 🎉

Open ErKeLost opened this issue 1 year ago • 12 comments

This refactoring will ensure that a large number of api and property break changes will not be designed

  1. Optimize existing @farmfe/core config logic design

  2. Add debug debugging to the node layer

  3. Replace koa with connect

  4. Try to adapt some hmr, jsPlugin Hook, etc. to farm native servers, rather than putting pressure on farm's vite compatibility layer, which will cause excessive pressure on subsequent maintenance

  5. The middleware design needs to be re-considered to adapt to the existing koa middleware and user-written middleware or the reimplementation of other native middleware that needs to be replaced.

Currently, we are still thinking about design and finally achieve the goal of farm development rust ecosystem, and js ecosystem reuses vite ecosystem.

Now considering the initial stage, we are still in the process of design thinking, and may mainly consider it in the mojor version

Reasons for refactoring this node layer

Only by making the underlying infrastructure good enough can it better serve the stability of the upper framework.

This major and important update is mainly to accompany the sustainable development of the vite ecosystem, so that farm can follow the footsteps of vite's js ecosystem for a long time to come.

Progress till MVP

New Docs

Refctor functions

Node Side

vite adapter

Refactoring all vite proxy logic mainly targets errors caused by invalid configurations such as esbuild ,rollup options Elegant optimized performance Compatible with more vite plugins

  • [x] #1788
  • [ ] #1846

@farmfe/cli

  • [x] refactor cli (Without affecting the operation of coredao, all functions of this package have been reconstructed.)
    • [x] Optimize cli logic to make cli logic clearer and more readable
    • [x] refactor start command
    • [x] refactor build command
    • [x] refactor watch command
    • [x] refactor preview command
    • [x] optimize clean command
    • [x] All api method attribute configuration types are rewritten
    • [x] remove watch command save dev and build

@farmfe/core

DX

  • [ ] refactor handle error
  • [ ] refactor overlay page

Config

  • [x] Correlate all error return messages
  • [ ] provide cli shortcuts
  • [x] add server.watch options remove hmr.watch
  • [x] add cacheDir options
  • [x] clearScreen logic
  • [ ] rewrite all types
  • [x] refactor logger
    • [x] Optimize the usage logic of logger and the logic passed to different methods
  • [x] add debug Set debug mode
  • [ ] All api method attribute configuration types are rewritten
  • [x] Write js doc with methods
  • [ ] Add performance analysis function (speedscope analysis cpu profiler)
  • [x] Access all cli storage method functions
    • [x] start methods
    • [x] build methods
    • [x] preview methods
    • [x] clean methods
  • [x] optimize resolveUserConfig logic
    • [x] Optimize function method logic code logic
    • [x] Optimize readConfigFile logic We should determine whether to load this method based on whether to pass configFile instead of rootPath
    • [ ] #1776 (move to rust side)
    • [x] rewrite zod schema with farm config
    • [x] Go through all api methods and logic, and the ultimate goal is to use the api to successfully run all cli projects API methods

Server

  • [x] #1786
  • [x] optimize configureCompiler and configureServer hooks, and sortPlugin utils pluginHookUtils
  • [x] add appType ['spa' | 'mpa' | 'custom']
  • [ ] Extract the logic of the server (At present, all config logic is in the resolveConfig method. We should abstract away the server-related methods. However, because we have runtime transfer properties, we still need to consider whether this method is feasible.)
  • [x] normalize server options
  • [ ] All api method attribute configuration types are rewritten
  • [ ] write js doc with methods
  • [x] use connect instead of koa
    • [x] rewite http server
    • [x] #1842
  • [x] rewrite middleware
    • [x] publilcPathMiddleware
    • [x] resourceMiddleware
    • [x] publicMiddleware
    • [x] proxyMiddleware
    • [x] corsMiddleware
    • [x] lazyCompilationMiddleware
    • [x] staticMiddleware
    • [x] htmlFallbackMiddleware
    • [x] optimize all middwares (logic and types)
  • [x] refactor resolve compiler logic
  • [x] refactor watcher logic
  • [ ] refactor hmr logic
  • [ ] optimize handle error

jsplugin

  • [ ] #1840
  • [ ] #1841
  • [x] add js plugin tailwindcss
  • [ ] refactor updateModules hooks

vite

  • [x] refactor vite adaptor

Currently testing all supported vite and unplugin plugins in the new version

vite plugins

unplugin plugins

  • [x] unplugin-vue
  • [x] unplugin-auto-import
  • [x] unplugin-vue-components
  • [x] unplugin-vue-markdown
  • [x] unplugin-vue-fervid
  • [ ] unplugin-vue-router
  • [x] unplugin-icons
  • [x] unplugin-imagemin

Js plugins

  • [x] @farmfe/js-plugin-solid
  • [ ] @farmfe/js-plugin-svelte
  • [ ] @farmfe/js-plugin-preact
  • [ ] @farmfe/js-plugin-electron
  • [x] @farmfe/js-plugin-tailwindcss
Image

other

  • [ ] #1850

  • [ ] perform example tests on all common properties and remove some useless examples (Importants)

unit Test

  • [ ] add more unit test test
    • [ ] complete unit tests covering all api
    • [ ] complete unit test js plugin api

The entire node layer will be explained in more detail later, and everyone is welcome to participate and learn together. All code is in v2-dev branch,If you are interested, you can discuss the claim below

Rust Side

Persistent Cache Refactor

  • [ ] Cache of static assets and css modules should be stored with module, instead of using plugin cache
  • [ ] Reduce the number of files that write to disk
  • [ ] Optimize Cache invalidate logic, support only invalidating the package that are updated, instead of disable all cache when lockfile is changed

Plugin Hooks

  • [ ] Add a plugin that can process all the modules after the module graph is built
  • [ ] Support Rollup style moduleParsed hook
  • [ ] Analyze deps support new Worker(new URL(xxx))
  • [ ] Support handling resolve call cycle, currently caller is a string and it can not trace the caller chain

HMR Optimize

  • [ ] Support add and remove event when HMR

PublicDir logic

  • [ ] reintegrate publicDir, copyPublicDir logic

Resolver

  • [x] #1817

Module Federation

  • [ ] #1934

Refactor

  • [ ] Performance optimization
    • [ ] Tracking #2113
    • [x] use faster hashmap, https://crates.io/crates/rustc-hash #1941
  • [ ] Refactor render logic:
    • [ ] normalize runtime render and resource pot render
    • [ ] support multiple output format when targetEnv is library
    • [ ] remove minify resource pot content and just minify resource pot ast(merged from modules)
      • [ ] support multiple sourcemap swc ecma code emitter
  • [ ] Support compiling dynamically added inputs. Scenarios:
    • [ ] plugin worker compilation
    • [ ] framework authors #1887
  • [ ] Runtime
    • [ ] remove all class syntax and inject runtime helper function in need
    • [ ] refactor async module implementation, normalize implementation of lazy compile and top level await
  • [ ] Optimize error handling

Css Implementation Refactor

  • [ ] #1978
  • [ ] Do not throw error for some legacy css syntax #1748

Grocery

  • [ ] Upgrade SWC to optimize performance
  • [ ] Support swc_plugin_proxy to enable accessing global swc marks
  • [ ] Make migration from existing frameworks easier

Rust Plugins - All in Rust

  • [x] @farmfe/plugin-worker
  • [x] @farmfe/plugin-wasm
  • [x] @farmfe/plugin-mdx
  • [x] @farmfe/plugin-svgr
  • [x] @farmfe/plugin-icons
  • [x] @farmfe/plugin-dts
  • [ ] @farmfe/plugin-tailwindcss
  • [ ] @farmfe/plugin-vue
  • [ ] @farmfe/plugin-vue-jsx
  • [ ] @farmfe/plugin-sass (using grass)
  • [ ] @farmfe/plugin-compress farm-fe/plugins#117

Feature request

  • [ ] #1815
  • [ ] #1816
  • [ ] #1843

ErKeLost avatar Jul 11 '24 12:07 ErKeLost

this issues will be resolved

#1403

#1455

#1711

ErKeLost avatar Jul 15 '24 08:07 ErKeLost

It seems that the processing of the config in the core was a bit complicated before, and config was modified in almost many places. It feels like it can be unified and processed in one place.

callqh avatar Jul 18 '24 10:07 callqh

Final implementation version and roadmap (new Docs)

  1. A new preview version of farm is expected to begin deploying in early October using https://github.com/stackblitz-labs/pkg.pr.new

  2. Better vite support includes plugins and custom plugins

  3. Better development experience and ui ux

  4. More stable server-side functional integrity

  5. More interesting new farm features, more customization options

  6. A new bundle model is coming soon

ErKeLost avatar Sep 15 '24 03:09 ErKeLost

change previews (WIP)

  1. new overlay page

with farm

image image

with vite(WIP)

image

ErKeLost avatar Sep 18 '24 04:09 ErKeLost

Great and elegant design!

fu050409 avatar Sep 18 '24 06:09 fu050409

HMR wants batch updates

remloyal avatar Nov 11 '24 06:11 remloyal

it's already supported

wre232114 avatar Nov 12 '24 01:11 wre232114

能不能基于 farm 的能力,发布一个类似 rspress 的工具?现在看 rspress 的生态相对完善,如官方有 https://rspress.dev/zh/plugin/official-plugins/preview 等插件很适合做组件文档。希望 farm 团队也能补齐

ishowman avatar Nov 28 '24 05:11 ishowman

@ishowman 这个也在计划中, mdx 的 rust 插件已经实现,后期会准备开始进行

ErKeLost avatar Nov 28 '24 07:11 ErKeLost

@ishowman 这个也在计划中, mdx 的 rust 插件已经实现,后期会准备开始进行

有相关 issue 吗

ishowman avatar Nov 29 '24 16:11 ishowman

@ishowman 插件地址 https://github.com/farm-fe/plugins/blob/main/examples/mdx/farm.config.ts 具体 farm 文档类工具以及设计还没有开始,如果有想法 欢迎贡献 🎉

ErKeLost avatar Nov 30 '24 01:11 ErKeLost

For performance improvement, tracking on #2113. Descriptions has been updated.

fu050409 avatar Mar 12 '25 12:03 fu050409

Farm v2 is ready for merging to main. After merging v2-dev to main, following features will be implemented before releasing v2.0.0:

  • [ ] [fix] should refresh the page when index.html update
  • [ ] move option configured in config.custom to the right place of config
  • [ ] disable sourcemap in production by default
  • [ ] support file watch and remove event for rust plugins and js plugins
  • [ ] update all vite related plugins and bump all dependencies for vite adapter and fix compatible issues
  • [ ] update all lint and format tools for js/ts files, current version of biome is not stable
  • [ ] update rust plugins to v2 and finish rust plugin tailwind, js plugin tailwind, unocss and so on
  • [ ] merge @farmfe/cli @farmfe/core into the farm package

wre232114 avatar Aug 30 '25 07:08 wre232114