@enact/cli 5.1.2 → 6.0.0
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.
- package/.eslintrc.js +7 -0
- package/.travis.yml +1 -1
- package/CHANGELOG.md +24 -0
- package/bin/enact.js +0 -2
- package/commands/eject.js +0 -1
- package/commands/pack.js +9 -3
- package/commands/serve.js +2 -1
- package/commands/test.js +1 -1
- package/config/jest/cssTransform.js +3 -1
- package/config/jest/fileTransform.js +3 -1
- package/config/jest/jest.config.js +4 -2
- package/config/webpack.config.js +16 -7
- package/docs/building-apps.md +21 -1
- package/docs/starting-a-new-app.md +5 -1
- package/npm-shrinkwrap.json +52868 -134991
- package/package.json +47 -48
package/.eslintrc.js
CHANGED
|
@@ -3,6 +3,13 @@ module.exports = {
|
|
|
3
3
|
node: true
|
|
4
4
|
},
|
|
5
5
|
extends: ['enact', 'plugin:prettier/recommended', 'prettier'],
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaFeatures: {
|
|
8
|
+
jsx: true
|
|
9
|
+
},
|
|
10
|
+
ecmaVersion: 'latest',
|
|
11
|
+
sourceType: 'module'
|
|
12
|
+
},
|
|
6
13
|
plugins: ['import'],
|
|
7
14
|
rules: {
|
|
8
15
|
'import/no-unresolved': ['error', {commonjs: true, caseSensitive: true}],
|
package/.travis.yml
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 6.0.0 (May 19, 2023)
|
|
2
|
+
|
|
3
|
+
* Updated all dependencies to the latest including Jest 29 and Typescript 5.
|
|
4
|
+
* Updated the minimum version of Node to `14.17.0` and dropped the support for Node 12 and 17.
|
|
5
|
+
|
|
6
|
+
### pack
|
|
7
|
+
|
|
8
|
+
* Added `--content-hash` option to add a unique hash to output file names to support better caching.
|
|
9
|
+
|
|
10
|
+
### serve
|
|
11
|
+
|
|
12
|
+
* Fixed to disable overlay for runtime errors.
|
|
13
|
+
|
|
14
|
+
### test
|
|
15
|
+
|
|
16
|
+
* Removed `@testing-library/dom` dependency.
|
|
17
|
+
* Updated `@testing-library/react` version to `^14.0.0`.
|
|
18
|
+
* Fixed `--watch` option is not working with the latest `jest-watch-typeahead` module.
|
|
19
|
+
|
|
20
|
+
## 5.1.3 (April 11, 2023)
|
|
21
|
+
|
|
22
|
+
* Updated `eslint-plugin-react` version to `^7.32.2`.
|
|
23
|
+
* Updated dependencies.
|
|
24
|
+
|
|
1
25
|
## 5.1.2 (February 21, 2023)
|
|
2
26
|
|
|
3
27
|
### pack
|
package/bin/enact.js
CHANGED
package/commands/eject.js
CHANGED
package/commands/pack.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// @remove-on-eject-end
|
|
14
14
|
const path = require('path');
|
|
15
15
|
const chalk = require('chalk');
|
|
16
|
-
const filesize = require('filesize');
|
|
16
|
+
const {filesize} = require('filesize');
|
|
17
17
|
const fs = require('fs-extra');
|
|
18
18
|
const minimist = require('minimist');
|
|
19
19
|
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
@@ -31,6 +31,7 @@ function displayHelp() {
|
|
|
31
31
|
console.log();
|
|
32
32
|
console.log(' Options');
|
|
33
33
|
console.log(' -o, --output Specify an output directory');
|
|
34
|
+
console.log(' --content-hash Add a unique hash to output file names based on the content of an asset');
|
|
34
35
|
console.log(' -w, --watch Rebuild on file changes');
|
|
35
36
|
console.log(' -p, --production Build in production mode');
|
|
36
37
|
console.log(' -i, --isomorphic Use isomorphic code layout');
|
|
@@ -54,13 +55,14 @@ function displayHelp() {
|
|
|
54
55
|
console.log();
|
|
55
56
|
/*
|
|
56
57
|
Private Options:
|
|
57
|
-
--entry
|
|
58
|
+
--entry Specify an override entrypoint
|
|
58
59
|
--no-minify Will skip minification during production build
|
|
59
60
|
--framework Builds the @enact/*, react, and react-dom into an external framework
|
|
60
61
|
--externals Specify a local directory path to the standalone external framework
|
|
61
62
|
--externals-public Remote public path to the external framework for use injecting into HTML
|
|
62
63
|
--externals-polyfill Flag whether to use external polyfill (or include in framework build)
|
|
63
64
|
--ilib-additional-path Specify iLib additional resources path
|
|
65
|
+
--no-animation Build without effects such as animation and shadow
|
|
64
66
|
*/
|
|
65
67
|
process.exit(0);
|
|
66
68
|
}
|
|
@@ -252,7 +254,9 @@ function api(opts = {}) {
|
|
|
252
254
|
const configFactory = require('../config/webpack.config');
|
|
253
255
|
const config = configFactory(
|
|
254
256
|
opts.production ? 'production' : 'development',
|
|
257
|
+
opts['content-hash'],
|
|
255
258
|
opts.isomorphic,
|
|
259
|
+
!opts.animation,
|
|
256
260
|
opts['ilib-additional-path']
|
|
257
261
|
);
|
|
258
262
|
|
|
@@ -280,6 +284,7 @@ function api(opts = {}) {
|
|
|
280
284
|
function cli(args) {
|
|
281
285
|
const opts = minimist(args, {
|
|
282
286
|
boolean: [
|
|
287
|
+
'content-hash',
|
|
283
288
|
'custom-skin',
|
|
284
289
|
'minify',
|
|
285
290
|
'framework',
|
|
@@ -288,12 +293,13 @@ function cli(args) {
|
|
|
288
293
|
'production',
|
|
289
294
|
'isomorphic',
|
|
290
295
|
'snapshot',
|
|
296
|
+
'animation',
|
|
291
297
|
'verbose',
|
|
292
298
|
'watch',
|
|
293
299
|
'help'
|
|
294
300
|
],
|
|
295
301
|
string: ['externals', 'externals-public', 'locales', 'entry', 'ilib-additional-path', 'output', 'meta'],
|
|
296
|
-
default: {minify: true},
|
|
302
|
+
default: {minify: true, animation: true},
|
|
297
303
|
alias: {
|
|
298
304
|
o: 'output',
|
|
299
305
|
p: 'production',
|
package/commands/serve.js
CHANGED
package/commands/test.js
CHANGED
|
@@ -20,6 +20,8 @@ const path = require('path');
|
|
|
20
20
|
module.exports = {
|
|
21
21
|
process(src, filename) {
|
|
22
22
|
const assetFilename = JSON.stringify(path.basename(filename));
|
|
23
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
code: `module.exports = ${assetFilename};`
|
|
25
|
+
};
|
|
24
26
|
}
|
|
25
27
|
};
|
|
@@ -72,8 +72,10 @@ module.exports = {
|
|
|
72
72
|
],
|
|
73
73
|
testPathIgnorePatterns: ignorePatterns,
|
|
74
74
|
testEnvironment: 'jsdom',
|
|
75
|
-
testEnvironmentOptions: {
|
|
76
|
-
|
|
75
|
+
testEnvironmentOptions: {
|
|
76
|
+
pretendToBeVisual: true,
|
|
77
|
+
url: 'http://localhost'
|
|
78
|
+
},
|
|
77
79
|
transform: {
|
|
78
80
|
'^.+\\.(js|jsx|ts|tsx)$': require.resolve('./babelTransform'),
|
|
79
81
|
'^.+\\.(css|less|sass|scss)$': require.resolve('./cssTransform.js'),
|
package/config/webpack.config.js
CHANGED
|
@@ -41,7 +41,13 @@ const createEnvironmentHash = require('./createEnvironmentHash');
|
|
|
41
41
|
|
|
42
42
|
// This is the production and development configuration.
|
|
43
43
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
44
|
-
module.exports = function (
|
|
44
|
+
module.exports = function (
|
|
45
|
+
env,
|
|
46
|
+
contentHash = false,
|
|
47
|
+
isomorphic = false,
|
|
48
|
+
noAnimation = false,
|
|
49
|
+
ilibAdditionalResourcesPath
|
|
50
|
+
) {
|
|
45
51
|
process.chdir(app.context);
|
|
46
52
|
|
|
47
53
|
// Load applicable .env files into environment variables.
|
|
@@ -208,10 +214,10 @@ module.exports = function (env, isomorphic = false, ilibAdditionalResourcesPath)
|
|
|
208
214
|
// Generated JS file names (with nested folders).
|
|
209
215
|
// There will be one main bundle, and one file per asynchronous chunk.
|
|
210
216
|
// We don't currently advertise code splitting but Webpack supports it.
|
|
211
|
-
filename: '[name].js',
|
|
217
|
+
filename: contentHash ? '[name].[contenthash].js' : '[name].js',
|
|
212
218
|
// There are also additional JS chunk files if you use code splitting.
|
|
213
|
-
chunkFilename: 'chunk.[name].js',
|
|
214
|
-
assetModuleFilename: '[path][name][ext]',
|
|
219
|
+
chunkFilename: contentHash ? 'chunk.[name].[contenthash].js' : 'chunk.[name].js',
|
|
220
|
+
assetModuleFilename: contentHash ? '[path][name][contenthash][ext]' : '[path][name][ext]',
|
|
215
221
|
// Add /* filename */ comments to generated require()s in the output.
|
|
216
222
|
pathinfo: !isEnvProduction,
|
|
217
223
|
publicPath,
|
|
@@ -481,15 +487,18 @@ module.exports = function (env, isomorphic = false, ilibAdditionalResourcesPath)
|
|
|
481
487
|
'process.env.PUBLIC_URL': JSON.stringify(publicPath),
|
|
482
488
|
// Define ENACT_PACK_ISOMORPHIC global variable to determine to use
|
|
483
489
|
// `hydrateRoot` for isomorphic build and `createRoot` for non-isomorphic build by app.
|
|
484
|
-
ENACT_PACK_ISOMORPHIC: isomorphic
|
|
490
|
+
ENACT_PACK_ISOMORPHIC: isomorphic,
|
|
491
|
+
// Define ENACT_PACK_NO_ANIMATION global variable to determine
|
|
492
|
+
// whether to build including effects such as animation or shadow or not.
|
|
493
|
+
ENACT_PACK_NO_ANIMATION: noAnimation
|
|
485
494
|
}),
|
|
486
495
|
// Inject prefixed environment variables within code, when used
|
|
487
496
|
new EnvironmentPlugin(Object.keys(process.env).filter(key => /^(REACT_APP|WDS_SOCKET)/.test(key))),
|
|
488
497
|
// Note: this won't work without MiniCssExtractPlugin.loader in `loaders`.
|
|
489
498
|
!process.env.INLINE_STYLES &&
|
|
490
499
|
new MiniCssExtractPlugin({
|
|
491
|
-
filename: '[name].css',
|
|
492
|
-
chunkFilename: 'chunk.[name].css'
|
|
500
|
+
filename: contentHash ? '[name].[contenthash].css' : '[name].css',
|
|
501
|
+
chunkFilename: contentHash ? 'chunk.[name].[contenthash].css' : 'chunk.[name].css'
|
|
493
502
|
}),
|
|
494
503
|
// Webpack5 removed node polyfills but we need this to run screenshot tests
|
|
495
504
|
new NodePolyfillPlugin(),
|
package/docs/building-apps.md
CHANGED
|
@@ -8,6 +8,7 @@ order: 4
|
|
|
8
8
|
enact pack [options]
|
|
9
9
|
|
|
10
10
|
Options
|
|
11
|
+
--content-hash Add a unique hash to output file names based on the content of an asset
|
|
11
12
|
-p, --production Build in production mode
|
|
12
13
|
-i, --isomorphic Use isomorphic code layout
|
|
13
14
|
(includes prerendering)
|
|
@@ -176,7 +177,7 @@ Here is the example.
|
|
|
176
177
|
```js
|
|
177
178
|
const MainPanel = kind({
|
|
178
179
|
name: 'MainPanel',
|
|
179
|
-
|
|
180
|
+
|
|
180
181
|
render: (props) => (
|
|
181
182
|
<Panel {...props}>
|
|
182
183
|
<p className="text-3xl font-bold underline">
|
|
@@ -218,6 +219,25 @@ my-app/
|
|
|
218
219
|
webos-meta/
|
|
219
220
|
```
|
|
220
221
|
|
|
222
|
+
## Caching
|
|
223
|
+
|
|
224
|
+
For supporting better [`caching`](https://webpack.js.org/guides/caching/), Enact CLI provides `--content-hash` option to add a unique hash to each output file name based on the content of an asset.
|
|
225
|
+
|
|
226
|
+
Building With this option should produce the following output:
|
|
227
|
+
|
|
228
|
+
```none
|
|
229
|
+
1.11 MB dist/main.1983e557b9a705c83e72.js
|
|
230
|
+
199.85 kB dist/main.2088c66150ab73b27793.css
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
When the content changes, the output file name will change as well.
|
|
234
|
+
```none
|
|
235
|
+
1.11 MB dist/main.7544f55b64439c8d0f0e.js
|
|
236
|
+
199.85 kB dist/main.2088c66150ab73b27793.css
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
> **NOTE** The filename `main.*.js` will be changed after another building, even without making any changes. This is because webpack includes certain boilerplate, specifically the runtime and manifest, in the entry chunk.
|
|
240
|
+
|
|
221
241
|
## Isomorphic Support & Prerendering
|
|
222
242
|
By using the isomorphic code layout option, your project bundle will be outputted in a versatile universal code format allowing potential usage outside the browser. The Enact CLI takes advantage of this mode by additionally generating an HTML output of your project and embedding it directly with the resulting **index.html**. By default, isomorphic mode will attempt to prerender only `en-US`, however with the `--locales` option, a wide variety of locales can be specified and prerendered. More details on isomorphic support and its limitations can be found [here](./isomorphic-support.md).
|
|
223
243
|
|
|
@@ -26,7 +26,8 @@ The @enact/cli tool will check the project's **package.json** looking for an opt
|
|
|
26
26
|
* `title` _[string]_ - Title text that should be put within the HTML's `<title></title>` tags. Note: if this is a webOS-project, the title will, by default, be auto-detected from the **appinfo.json** content.
|
|
27
27
|
* `theme` _[object]_ - A simplified string name to extrapolate `fontGenerator`, `ri`, and `screenTypes` preset values from. For example, `"sandstone"`.
|
|
28
28
|
* `fontGenerator` _[string]_ - Filepath to a CommonJS fontGenerator module which will build locale-specific font CSS to inject into the HTML. By default, will use any preset for a specified theme or fallback to sandstone.
|
|
29
|
-
* `ri` _[object]_ - Resolution independence options to be forwarded to the [
|
|
29
|
+
* `ri` _[object]_ - Resolution independence options to be forwarded to the [postcss-resolution-independence](https://github.com/enactjs/postcss-resolution-independence). By default, will use any preset for a specified theme or fallback to sandstone.
|
|
30
|
+
* `baseSize` _[number]_ - The root font-size to use when converting the value of the base unit to a resolution-independent unit. For example, when `baseSize` is set to 24, 48px in the LESS file will be converted to 2rem.
|
|
30
31
|
* `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
32
|
* `nodeBuiltins` _[object]_ - Configuration settings for polyfilling NodeJS built-ins. See `node` [webpack option](https://webpack.js.org/configuration/node/).
|
|
32
33
|
* `resolveFallback` _[object]_ - Configuration settings for redirecting module requests when normal resolving fails. See `resolve.fallback` [webpack option](https://webpack.js.org/configuration/resolve/#resolvefallback).
|
|
@@ -46,6 +47,9 @@ For example:
|
|
|
46
47
|
fs: false,
|
|
47
48
|
net: false,
|
|
48
49
|
tls: false
|
|
50
|
+
},
|
|
51
|
+
"ri": {
|
|
52
|
+
"baseSize": 24
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
...
|