farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.9k stars 161 forks source link

Production builds are bloated #250

Open oblador opened 1 year ago

oblador commented 1 year ago

Steps to reproduce

// farm.config.ts
export default {
  compilation: {
    mode: 'production',
    input: {
      index: './index.ts',
    },
  },
};

// index.ts
console.log('hello')

What is expected?

Something along the lines of this output:

// esbuild
(() => {
  // index.ts
  console.log("hello");
})();

// webpack
console.log("hello");

What is actually happening?

500+ lines of code

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 57.05 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.asdf/installs/nodejs/16.18.0/bin/node
    Yarn: 1.22.17 - ~/.asdf/shims/yarn
    npm: 8.19.2 - ~/.asdf/plugins/nodejs/shims/npm
    Watchman: 2023.03.27.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 112.0.5615.137
    Firefox: 107.0.1
    Safari: 16.4
  npmPackages:
    @farmfe/core: ^0.6.3 => 0.6.4

Any additional comments?

No response

wre232114 commented 1 year ago

This needs to determine whether the runtime is needed when compiling. For now, All runtime code are always included(but it only has hundred of lines, its size can be ignored when using with other libraries like react), we may optimize this in the future, but it is not our first goal at present.

Also, bundling is also our first goal as present, our first goal is to build a web project fast and makes sure it can run fast in browser and node(For SSR). Bundling is just to make sure the resource loading faster