UNPKG

8.13 kBMarkdownView Raw
1# fusion-cli
2
3[![Build status](https://badge.buildkite.com/7a82192275779f6a8ba81f7d4a1b0d294256838faa1dfdf080.svg?branch=master)](https://buildkite.com/uberopensource/fusionjs)
4
5The CLI interface for Fusion.js
6
7The `fusion-cli` package is responsible for orchestrating compile-time configuration for server and browser bundles, as well as development, test and production variations. It provides a standardized Babel configuration that includes async/await support as well as stage 3+ Ecmascript features.
8
9Due to the complexity involved in configuring many permutations of configurations, Fusion.js does not support custom `webpack.config`. This design decision allows Fusion.js to eventually move away from Webpack if faster and better bundlers become available. Additionally, it allows Fusion.js to make changes to the internal webpack configuration without the concern of breaking users customizations. If you run into a situation where you feel you need to make a webpack customization, please reach out to us on [slack](https://join.slack.com/t/fusionjs/shared_invite/enQtMzk3NjM0MTg0MTI4LWJhNzVjYjk5ZDVlYWIxZWViMjA3YzE5OTc4YWZkNzBkZmNkYmJkMDYyOGEzODEwMzRmMWExMzc1NDIzMmY2NDQ) or create an issue describing your use case.
10
11The CLI is also responsible for hot module reloading in development mode, and for running the web server.
12
13### Installation
14
15```sh
16yarn add fusion-cli
17```
18
19---
20
21### CLI API
22
23The CLI API can be most easily run through the Yarn or NPX CLI, e.g. `yarn fusion build` or `npx fusion build`.
24
25- `fusion build [dir] [--production] [--log-level] [--maxWorkers]`
26 Builds your application assets
27
28 This command generates transpiled javascript/source map files (aka assets, artifacts) for browser and server. By default it builds development assets, but can also build test and production assets, given the respective flags.
29
30 Build artifacts are stored in the `.fusion` directory.
31
32 - `--production`: Build production assets
33 - `--log-level`: Log level to output to console `[default: "info"]`
34 - `--skipSourceMaps`: Skip building source maps
35 - `--maxWorkers`: Maximum number of workers create by webpack during build process
36
37 Builds where the ENABLE_REACT_PROFILER environment variable is set to `'true'` will enable the [Fusion React Profiler](https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html) in apps deployed to production. (NOTE: using the react profiler will itself slightly degrade performance):
38
39 - `ENABLE_REACT_PROFILER=true fusion build`
40
41- `fusion dev [dir] [--port] [--no-hmr] [--test] [--log-level] [--forceLegacyBuild]`
42 Builds development assets and runs the application in development mode
43
44 Note that this command only builds browser artifacts in memory, and it doesn't save them to the filesystem. This allows hot module reloading to occur faster since there's no performance cost due to I/O access.
45
46 - `--port`: The port on which the application runs `[default: 3000]`
47 - `--no-hmr`: Run without hot modules replacement
48 - `--test`: Run tests as well as application
49 - `--log-level`: Log level to output to console `[default: "info"]`
50 - `--forceLegacyBuild`: Force enable legacy build. By default not compiled in dev.
51 - `--exitOnError`: Exit the process if a compiliation error occurs.
52 - `--preserveNames`: Disable name mangling during script minification
53
54<!--
55* `fusion profile [--environment] [--watch] [--file-count]`: Profile your application
56 * `--environment`: Either `production` or `development` `[default: "production"]`
57 * `--watch`: After profiling, launch source-map-explorer with file watch
58 * `--file-count`: The number of file sizes to output, sorted largest to smallest (-1 for all files) `[default: 20]`
59-->
60
61- `fusion start [--environment]`
62 Runs your application, assuming you have previously built them via `fusion build`. Note that build artifacts must be saved to disk (i.e. this command will fail if you use `fusion dev` to build artifacts instead of `fusion build`.
63
64 - `--environment`: Which environment/assets to run - defaults to first available assets among `["development", "production"]`
65
66- `fusion test [options]`
67 Builds test assets and runs tests
68
69 Tests are run with Jest
70
71 - `--dir`: Root path for the application relative to CLI CWD. (default .)
72 - `--debug`: Debug tests using --inspect-brk and --runInBand. (default false)
73 - `--match`: Runs test files that match a given string
74 - `--env`: Comma-separated list of environments to run tests in. Defaults to running both node and browser tests. (default jsdom,node)
75 - `--testFolder`: Which folder to look for tests in. Deprecated, use testMatch or testRegex instead.
76 - `--testMatch`: Which folder to look for tests in. A comma-separated list of glob patterns.
77 - `--testRegex`: Which folder to look for tests in. A comma-separated list of regexp strings.
78 - `--configPath`: Path to the jest configuration, used for testing. (default [path-to-fusion-cli]/build/jest/jest-config.js)
79 - `--updateSnapshot`, `-u`: Updates snapshots
80
81 Jest pass-through options
82
83 - `--collectCoverageFrom`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#collectcoveragefrom
84 - `--changedFilesWithAncestor`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#changedfileswithancestor
85 - `--changedSince`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#changedsince
86 - `--ci`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#ci
87 - `--clearCache`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#clearcache
88 - `--colors`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#colors
89 - `--coverage`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#coverage
90 - `--detectOpenHandles`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#detectopenhandles
91 - `--errorOnDeprecated`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#errorondeprecated
92 - `--expand`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#expand
93 - `--findRelatedTests`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#findrelatedtests
94 - `--json`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#json
95 - `--lastCommit`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#lastcommit
96 - `--listTests`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#listtests
97 - `--logHeapUsage`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#logheapusage
98 - `--noStackTrace`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#nostacktrace
99 - `--noVerbose`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#verbose
100 - `--notify`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#notify
101 - `--onlyChanged`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#onlychanged
102 - `--outputPath`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#outputpath
103 - `--passWithNoTests`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#passwithnotests
104 - `--reporters`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#reporters
105 - `--showConfig`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#showconfig
106 - `--silent`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#silent
107 - `--testLocationInResults`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#testlocationinresults
108 - `--useStderr`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#usestderr
109 - `--version`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#version
110 - `--watch`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#watch
111 - `--watchAll`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#watchall
112 - `--watchman`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#watchman
113 - `--maxWorkers`: Jest CLI argument. See: https://jestjs.io/docs/en/cli.html#maxworkers
114
115- `fusion profile`
116 Generates a graph diagram of dependencies
117
118### Webpack stats.json file
119
120Building an app generates a `.fusion/stats.json` file, which can be used with [`webpack-bundle-analyzer`](https://www.npmjs.com/package/webpack-bundle-analyzer)