Purpose of `--target ` option in `frontity dev` or `frontity build`

What is the use case of using this?

npx frontity dev --target es5
npx frontity build --target es5

What does really mean creating a bundle with “es5” or “module”? What are the implications? Why would anyone want to choose one or another?


This boils down to what features we want to transpile with babel.

With --target es5, we support as the minimum the following browsers:

es5: {
    browsers: [
      "and_chr >= 67",
      "and_ff >= 18",
      "and_uc >= 11.8",
      "android >= 67",
      "not android <= 4.4.4",
      "chrome >= 49",
      "edge >= 12",
      "firefox >= 18",
      "ios_saf >= 10",
      "not op_mini all",
      "op_mob >= 46",
      "opera >= 36",
      "safari >= 10",
      "samsung >= 5",

So, we don’t transpile any features that those browsers already support. In particular we aim to support only the browsers that ship with the built-in Proxy object . This list comes from here and it is used by the @babel/preset-env to determine how to transpile the files.

With --target module, we tell babel to only support the browsers that support ESModules