@enact/cli 5.0.0-alpha.3 → 5.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: Measuring Performance
3
+ order: 11
4
+ ---
5
+ By default, an app generated from `enact create` with Enact CLI includes a performance relayer that allows you to measure and analyze
6
+ the performance of your application using different metrics.
7
+
8
+ To measure any of the supported metrics, you only need to pass a function into the `reportWebVitals`
9
+ function in `index.js`:
10
+
11
+ ```js
12
+ reportWebVitals(console.log);
13
+ ```
14
+
15
+ This function is fired when the final values for any of the metrics have finished calculating on the
16
+ page. You can use it to log any of the results to the console or send to a particular endpoint.
17
+
18
+ ## Web Vitals
19
+
20
+ [Web Vitals](https://web.dev/vitals/) are a set of useful metrics that aim to capture the user
21
+ experience of a web page. In Create React App, a third-party library is used to measure these
22
+ metrics ([web-vitals](https://github.com/GoogleChrome/web-vitals)).
23
+
24
+ To understand more about the object returned to the function when a metric value is calculated,
25
+ refer to the [documentation](https://github.com/GoogleChrome/web-vitals/#types). The [Browser
26
+ Support](https://github.com/GoogleChrome/web-vitals/#browser-support) section also explains which browsers are supported.
27
+
28
+ ## Sending results to analytics
29
+
30
+ With the `reportWebVitals` function, you can send any of results to an analytics endpoint to measure and track real user performance on your site. For example:
31
+
32
+ ```js
33
+ function sendToAnalytics(metric) {
34
+ const body = JSON.stringify(metric);
35
+ const url = 'https://example.com/analytics';
36
+
37
+ // Use `navigator.sendBeacon()` if available, falling back to `fetch()`
38
+ if (navigator.sendBeacon) {
39
+ navigator.sendBeacon(url, body);
40
+ } else {
41
+ fetch(url, { body, method: 'POST', keepalive: true });
42
+ }
43
+ }
44
+
45
+ reportWebVitals(sendToAnalytics);
46
+ ```
47
+
48
+ > **Note:** If you use Google Analytics, use the `id` value to make it easier to construct metric distributions manually (to calculate percentiles, etc…).
49
+ >
50
+ > ```js
51
+ > function sendToAnalytics({ id, name, value }) {
52
+ > ga('send', 'event', {
53
+ > eventCategory: 'Web Vitals',
54
+ > eventAction: name,
55
+ > eventValue: Math.round(name === 'CLS' ? value * 1000 : value), // values must be integers
56
+ > eventLabel: id, // id unique to current page load
57
+ > nonInteraction: true, // avoids affecting bounce rate
58
+ > });
59
+ > }
60
+ >
61
+ > reportWebVitals(sendToAnalytics);
62
+ > ```
63
+ >
64
+ > Read more about sending results to Google Analytics [here](https://github.com/GoogleChrome/web-vitals#send-the-results-to-google-analytics).
@@ -29,6 +29,7 @@ The @enact/cli tool will check the project's **package.json** looking for an opt
29
29
  * `ri` _[object]_ - Resolution independence options to be forwarded to the [LESS plugin](https://github.com/enactjs/less-plugin-resolution-independence). By default, will use any preset for a specified theme or fallback to sandstone.
30
30
  * `screenTypes` _[array|string]_ - Array of 1 or more screentype definitions to be used with prerender HTML initialization. Can alternatively reference a json filepath to read for screentype definitions. By default, will use any preset for a specified theme or fallback to sandstone.
31
31
  * `nodeBuiltins` _[object]_ - Configuration settings for polyfilling NodeJS built-ins. See `node` [webpack option](https://webpack.js.org/configuration/node/).
32
+ * `resolveFallback` _[object]_ - Configuration settings for redirecting module requests when normal resolving fails. See `resolve.fallback` [webpack option](https://webpack.js.org/configuration/resolve/#resolvefallback).
32
33
  * `externalStartup` _[boolean]_ - Flag whether to externalize the startup/update js that is normally inlined within prerendered app HTML output.
33
34
  * `forceCSSModules` _[boolean]_ - Flag whether to force all LESS/CSS to be processed in a modular context (not just the `*.module.css` and `*.module.less` files).
34
35
  * `deep` _[string|array]_ - 1 or more JavaScript conditions that, when met, indicate deeplinking and any prerender should be discarded.
@@ -41,10 +42,10 @@ For example:
41
42
  ...
42
43
  "enact": {
43
44
  "theme": "sandstone",
44
- "nodeBuiltins": {
45
- fs: 'empty',
46
- net: 'empty',
47
- tls: 'empty'
45
+ "resolveFallback": {
46
+ fs: false,
47
+ net: false,
48
+ tls: false
48
49
  }
49
50
  }
50
51
  ...
@@ -15,7 +15,6 @@ order: 7
15
15
  The `enact test` command (aliased as `npm run test`) will activate a [Jest](https://jestjs.io/) test runner on all discovered *-specs.js files. All the complicated configuration is hidden away within Enact CLI to avoid any confusion or additional difficulty in testing source code.
16
16
 
17
17
  Internally Enact CLI supports [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) out of the box, so there's no need to install them locally on your project. Simply import/require it within specs files and it'll be there. You will want to familiarize yourself with React Testing Library's utilities in order to write more complex tests.
18
- Enzyme support is deprecated and will be removed in a future major release.
19
18
 
20
19
  To create a test please create a ***-specs.js** file in the folder of the component you wish to test.
21
20