@enact/cli 4.1.7 → 5.0.0-alpha.3
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 +1 -1
- package/CHANGELOG.md +36 -0
- package/README.md +1 -1
- package/bin/enact.js +7 -1
- package/commands/eject.js +1 -1
- package/commands/lint.js +1 -1
- package/commands/pack.js +24 -17
- package/commands/serve.js +66 -52
- package/config/babel.config.js +2 -0
- package/config/createEnvironmentHash.js +9 -0
- package/config/jest/babelTransform.js +1 -1
- package/config/jest/jest.config.js +0 -1
- package/config/webpack.config.js +130 -98
- package/docs/building-apps.md +2 -2
- package/docs/installation.md +0 -6
- package/npm-shrinkwrap.json +19116 -21094
- package/package.json +87 -96
package/config/webpack.config.js
CHANGED
|
@@ -16,15 +16,17 @@ const fs = require('fs');
|
|
|
16
16
|
const path = require('path');
|
|
17
17
|
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
|
18
18
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
19
|
-
const ForkTsCheckerWebpackPlugin =
|
|
19
|
+
const ForkTsCheckerWebpackPlugin =
|
|
20
|
+
process.env.TSC_COMPILE_ON_ERROR === 'true'
|
|
21
|
+
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
|
|
22
|
+
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
|
|
20
23
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
21
24
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
22
|
-
const
|
|
25
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
23
26
|
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
|
24
27
|
const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
|
|
25
28
|
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
|
26
|
-
const
|
|
27
|
-
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
|
|
29
|
+
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
|
|
28
30
|
const resolve = require('resolve');
|
|
29
31
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
30
32
|
const {DefinePlugin, EnvironmentPlugin} = require('webpack');
|
|
@@ -35,10 +37,11 @@ const {
|
|
|
35
37
|
ILibPlugin,
|
|
36
38
|
WebOSMetaPlugin
|
|
37
39
|
} = require('@enact/dev-utils');
|
|
40
|
+
const createEnvironmentHash = require('./createEnvironmentHash');
|
|
38
41
|
|
|
39
42
|
// This is the production and development configuration.
|
|
40
43
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
41
|
-
module.exports = function (env) {
|
|
44
|
+
module.exports = function (env, ilibAdditionalResourcesPath) {
|
|
42
45
|
process.chdir(app.context);
|
|
43
46
|
|
|
44
47
|
// Load applicable .env files into environment variables.
|
|
@@ -64,6 +67,9 @@ module.exports = function (env) {
|
|
|
64
67
|
// Check if TypeScript is setup
|
|
65
68
|
const useTypeScript = fs.existsSync('tsconfig.json');
|
|
66
69
|
|
|
70
|
+
// Check if Tailwind config exists
|
|
71
|
+
const useTailwind = fs.existsSync(path.join(app.context, 'tailwind.config.js'));
|
|
72
|
+
|
|
67
73
|
process.env.NODE_ENV = env || process.env.NODE_ENV;
|
|
68
74
|
const isEnvProduction = process.env.NODE_ENV === 'production';
|
|
69
75
|
|
|
@@ -97,15 +103,16 @@ module.exports = function (env) {
|
|
|
97
103
|
options: Object.assign(
|
|
98
104
|
{importLoaders: preProcessor ? 2 : 1, sourceMap: shouldUseSourceMap},
|
|
99
105
|
cssLoaderOptions,
|
|
100
|
-
cssLoaderOptions.modules && {modules: {getLocalIdent}},
|
|
101
106
|
{
|
|
102
|
-
url:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
url: {
|
|
108
|
+
filter: url => {
|
|
109
|
+
// Don't handle absolute path urls
|
|
110
|
+
if (url.startsWith('/')) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
)
|
|
@@ -117,26 +124,33 @@ module.exports = function (env) {
|
|
|
117
124
|
loader: require.resolve('postcss-loader'),
|
|
118
125
|
options: {
|
|
119
126
|
postcssOptions: {
|
|
127
|
+
// Necessary for external CSS imports to work
|
|
128
|
+
// https://github.com/facebook/create-react-app/issues/2677
|
|
129
|
+
ident: 'postcss',
|
|
120
130
|
plugins: [
|
|
131
|
+
useTailwind && require('tailwindcss'),
|
|
121
132
|
// Fix and adjust for known flexbox issues
|
|
122
133
|
// See https://github.com/philipwalton/flexbugs
|
|
123
|
-
|
|
134
|
+
'postcss-flexbugs-fixes',
|
|
124
135
|
// Support @global-import syntax to import css in a global context.
|
|
125
|
-
|
|
136
|
+
'postcss-global-import',
|
|
126
137
|
// Transpile stage-3 CSS standards based on browserslist targets.
|
|
127
138
|
// See https://preset-env.cssdb.org/features for supported features.
|
|
128
139
|
// Includes support for targetted auto-prefixing.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
[
|
|
141
|
+
'postcss-preset-env',
|
|
142
|
+
{
|
|
143
|
+
autoprefixer: {
|
|
144
|
+
flexbox: 'no-2009',
|
|
145
|
+
remove: false
|
|
146
|
+
},
|
|
147
|
+
stage: 3,
|
|
148
|
+
features: {'custom-properties': false}
|
|
149
|
+
}
|
|
150
|
+
],
|
|
137
151
|
// Adds PostCSS Normalize to standardize browser quirks based on
|
|
138
152
|
// the browserslist targets.
|
|
139
|
-
require('postcss-normalize')
|
|
153
|
+
!useTailwind && require('postcss-normalize'),
|
|
140
154
|
// Resolution indepedence support
|
|
141
155
|
app.ri !== false && require('postcss-resolution-independence')(app.ri)
|
|
142
156
|
].filter(Boolean)
|
|
@@ -191,6 +205,7 @@ module.exports = function (env) {
|
|
|
191
205
|
filename: '[name].js',
|
|
192
206
|
// There are also additional JS chunk files if you use code splitting.
|
|
193
207
|
chunkFilename: 'chunk.[name].js',
|
|
208
|
+
assetModuleFilename: '[path][name][ext]',
|
|
194
209
|
// Add /* filename */ comments to generated require()s in the output.
|
|
195
210
|
pathinfo: !isEnvProduction,
|
|
196
211
|
publicPath,
|
|
@@ -210,13 +225,21 @@ module.exports = function (env) {
|
|
|
210
225
|
} else {
|
|
211
226
|
return file;
|
|
212
227
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
cache: {
|
|
231
|
+
type: 'filesystem',
|
|
232
|
+
version: createEnvironmentHash(Object.keys(process.env)),
|
|
233
|
+
cacheDirectory: path.resolve('./node_modules/.cache'),
|
|
234
|
+
store: 'pack',
|
|
235
|
+
buildDependencies: {
|
|
236
|
+
defaultWebpack: ['webpack/lib/'],
|
|
237
|
+
config: [__filename],
|
|
238
|
+
tsconfig: useTypeScript ? ['tsconfig.json'] : []
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
infrastructureLogging: {
|
|
242
|
+
level: 'none'
|
|
220
243
|
},
|
|
221
244
|
resolve: {
|
|
222
245
|
// These are the reasonable defaults supported by the React/ES6 ecosystem.
|
|
@@ -246,6 +269,12 @@ module.exports = function (env) {
|
|
|
246
269
|
// @remove-on-eject-end
|
|
247
270
|
module: {
|
|
248
271
|
rules: [
|
|
272
|
+
shouldUseSourceMap && {
|
|
273
|
+
enforce: 'pre',
|
|
274
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
275
|
+
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
|
|
276
|
+
loader: require.resolve('source-map-loader')
|
|
277
|
+
},
|
|
249
278
|
{
|
|
250
279
|
// "oneOf" will traverse all following loaders until one will
|
|
251
280
|
// match the requirements. When no loader matches it will fall
|
|
@@ -273,13 +302,23 @@ module.exports = function (env) {
|
|
|
273
302
|
// options used at each level of processing.
|
|
274
303
|
{
|
|
275
304
|
test: /\.module\.css$/,
|
|
276
|
-
use: getStyleLoaders({
|
|
305
|
+
use: getStyleLoaders({
|
|
306
|
+
modules: {
|
|
307
|
+
getLocalIdent,
|
|
308
|
+
mode: 'local'
|
|
309
|
+
}
|
|
310
|
+
})
|
|
277
311
|
},
|
|
278
312
|
{
|
|
279
313
|
test: /\.css$/,
|
|
280
314
|
// The `forceCSSModules` Enact build option can be set true to universally apply
|
|
281
315
|
// modular CSS support.
|
|
282
|
-
use: getStyleLoaders({
|
|
316
|
+
use: getStyleLoaders({
|
|
317
|
+
modules: {
|
|
318
|
+
...(app.forceCSSModules ? {getLocalIdent} : {}),
|
|
319
|
+
mode: 'icss'
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
283
322
|
// Don't consider CSS imports dead code even if the
|
|
284
323
|
// containing package claims to have no side effects.
|
|
285
324
|
// Remove this when webpack adds a warning or an error for this.
|
|
@@ -288,18 +327,27 @@ module.exports = function (env) {
|
|
|
288
327
|
},
|
|
289
328
|
{
|
|
290
329
|
test: /\.module\.less$/,
|
|
291
|
-
use: getLessStyleLoaders({
|
|
330
|
+
use: getLessStyleLoaders({
|
|
331
|
+
modules: {
|
|
332
|
+
getLocalIdent,
|
|
333
|
+
mode: 'local'
|
|
334
|
+
}
|
|
335
|
+
})
|
|
292
336
|
},
|
|
293
337
|
{
|
|
294
338
|
test: /\.less$/,
|
|
295
|
-
use: getLessStyleLoaders({
|
|
339
|
+
use: getLessStyleLoaders({
|
|
340
|
+
modules: {
|
|
341
|
+
...(app.forceCSSModules ? {getLocalIdent} : {}),
|
|
342
|
+
mode: 'icss'
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
296
345
|
sideEffects: true
|
|
297
346
|
},
|
|
298
347
|
// "file" loader handles on all files not caught by the above loaders.
|
|
299
348
|
// When you `import` an asset, you get its output filename and the file
|
|
300
349
|
// is copied during the build process.
|
|
301
350
|
{
|
|
302
|
-
loader: require.resolve('file-loader'),
|
|
303
351
|
// Exclude `js` files to keep "css" loader working as it injects
|
|
304
352
|
// its runtime that would otherwise be processed through "file" loader.
|
|
305
353
|
// Also exclude `html` and `json` extensions so they get processed
|
|
@@ -307,36 +355,21 @@ module.exports = function (env) {
|
|
|
307
355
|
// Exclude `ejs` HTML templating language as that's handled by
|
|
308
356
|
// the HtmlWebpackPlugin.
|
|
309
357
|
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.ejs$/, /\.json$/],
|
|
310
|
-
|
|
311
|
-
name: '[path][name].[ext]'
|
|
312
|
-
}
|
|
358
|
+
type: 'asset/resource'
|
|
313
359
|
}
|
|
314
360
|
// ** STOP ** Are you adding a new loader?
|
|
315
361
|
// Make sure to add the new loader(s) before the "file" loader.
|
|
316
362
|
]
|
|
317
363
|
}
|
|
318
|
-
]
|
|
364
|
+
].filter(Boolean)
|
|
319
365
|
},
|
|
320
366
|
// Specific webpack-dev-server options.
|
|
321
367
|
devServer: {
|
|
322
368
|
// Broadcast http server on the localhost, port 8080.
|
|
323
369
|
host: '0.0.0.0',
|
|
324
|
-
port: 8080
|
|
325
|
-
// Support the same public path as webpack config.
|
|
326
|
-
publicPath: publicPath,
|
|
327
|
-
// By default WebpackDevServer serves files from public and __mocks__ directories
|
|
328
|
-
// in addition to all the virtual build products that it serves from memory.
|
|
329
|
-
contentBase: [path.resolve('./public'), path.resolve('./__mocks__')],
|
|
330
|
-
contentBasePublicPath: publicPath + '/',
|
|
331
|
-
// Any changes to files from `contentBase` should trigger a page reload.
|
|
332
|
-
watchContentBase: true,
|
|
333
|
-
// Reportedly, this avoids CPU overload on some systems.
|
|
334
|
-
// https://github.com/facebookincubator/create-react-app/issues/293
|
|
335
|
-
watchOptions: {
|
|
336
|
-
ignored: /node_modules[\\/](?!@enact[\\/](?!.*node_modules))/
|
|
337
|
-
}
|
|
370
|
+
port: 8080
|
|
338
371
|
},
|
|
339
|
-
// Target app to build for a specific environment (default '
|
|
372
|
+
// Target app to build for a specific environment (default 'browserslist')
|
|
340
373
|
target: app.environment,
|
|
341
374
|
// Optional configuration for polyfilling NodeJS built-ins.
|
|
342
375
|
node: app.nodeBuiltins,
|
|
@@ -382,29 +415,9 @@ module.exports = function (env) {
|
|
|
382
415
|
},
|
|
383
416
|
// Use multi-process parallel running to improve the build speed
|
|
384
417
|
// Default number of concurrent runs: os.cpus().length - 1
|
|
385
|
-
parallel: true
|
|
386
|
-
// Enable file caching
|
|
387
|
-
cache: true,
|
|
388
|
-
sourceMap: shouldUseSourceMap
|
|
418
|
+
parallel: true
|
|
389
419
|
}),
|
|
390
|
-
new
|
|
391
|
-
cssProcessorOptions: {
|
|
392
|
-
// TODO: verify calc issue fixed. Related: https://github.com/postcss/postcss-calc/issues/50
|
|
393
|
-
// calc: false,
|
|
394
|
-
parser: require('postcss-safe-parser'),
|
|
395
|
-
map: shouldUseSourceMap && {
|
|
396
|
-
// `inline: false` forces the sourcemap to be output into a
|
|
397
|
-
// separate file
|
|
398
|
-
inline: false,
|
|
399
|
-
// `annotation: true` appends the sourceMappingURL to the end of
|
|
400
|
-
// the css file, helping the browser find the sourcemap
|
|
401
|
-
annotation: true
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
cssProcessorPluginOptions: {
|
|
405
|
-
preset: ['default', {minifyFontValues: {removeQuotes: false}}]
|
|
406
|
-
}
|
|
407
|
-
})
|
|
420
|
+
new CssMinimizerPlugin()
|
|
408
421
|
]
|
|
409
422
|
},
|
|
410
423
|
plugins: [
|
|
@@ -445,15 +458,12 @@ module.exports = function (env) {
|
|
|
445
458
|
filename: '[name].css',
|
|
446
459
|
chunkFilename: 'chunk.[name].css'
|
|
447
460
|
}),
|
|
461
|
+
// Webpack5 removed node polyfills but we need this to run screenshot tests
|
|
462
|
+
new NodePolyfillPlugin(),
|
|
448
463
|
// Provide meaningful information when modules are not found
|
|
449
464
|
new ModuleNotFoundPlugin(app.context),
|
|
450
465
|
// Ensure correct casing in module filepathes
|
|
451
466
|
new CaseSensitivePathsPlugin(),
|
|
452
|
-
// If you require a missing module and then `npm install` it, you still have
|
|
453
|
-
// to restart the development server for Webpack to discover it. This plugin
|
|
454
|
-
// makes the discovery automatic so you don't have to restart.
|
|
455
|
-
// See https://github.com/facebookincubator/create-react-app/issues/186
|
|
456
|
-
!isEnvProduction && new WatchMissingNodeModulesPlugin('./node_modules'),
|
|
457
467
|
// Switch the internal NodeOutputFilesystem to use graceful-fs to avoid
|
|
458
468
|
// EMFILE errors when hanndling mass amounts of files at once, such as
|
|
459
469
|
// what happens when using ilib bundles/resources.
|
|
@@ -461,30 +471,52 @@ module.exports = function (env) {
|
|
|
461
471
|
// Automatically configure iLib library within @enact/i18n. Additionally,
|
|
462
472
|
// ensure the locale data files and the resource files are copied during
|
|
463
473
|
// the build to the output directory.
|
|
464
|
-
new ILibPlugin({symlinks: false}),
|
|
474
|
+
new ILibPlugin({publicPath, symlinks: false, ilibAdditionalResourcesPath}),
|
|
465
475
|
// Automatically detect ./appinfo.json and ./webos-meta/appinfo.json files,
|
|
466
476
|
// and parses any to copy over any webOS meta assets at build time.
|
|
467
477
|
new WebOSMetaPlugin({htmlPlugin: HtmlWebpackPlugin}),
|
|
468
478
|
// TypeScript type checking
|
|
469
479
|
useTypeScript &&
|
|
470
480
|
new ForkTsCheckerWebpackPlugin({
|
|
471
|
-
typescript: resolve.sync('typescript', {
|
|
472
|
-
basedir: 'node_modules'
|
|
473
|
-
}),
|
|
474
481
|
async: !isEnvProduction,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
482
|
+
typescript: {
|
|
483
|
+
typescriptPath: resolve.sync('typescript', {
|
|
484
|
+
basedir: 'node_modules'
|
|
485
|
+
}),
|
|
486
|
+
configOverwrite: {
|
|
487
|
+
compilerOptions: {
|
|
488
|
+
sourceMap: shouldUseSourceMap,
|
|
489
|
+
skipLibCheck: true,
|
|
490
|
+
inlineSourceMap: false,
|
|
491
|
+
declarationMap: false,
|
|
492
|
+
noEmit: true,
|
|
493
|
+
incremental: true,
|
|
494
|
+
tsBuildInfoFile: 'node_modules/.cache/tsconfig.tsbuildinfo'
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
context: app.context,
|
|
498
|
+
diagnosticOptions: {
|
|
499
|
+
syntactic: true
|
|
500
|
+
},
|
|
501
|
+
mode: 'write-references'
|
|
502
|
+
// profile: true,
|
|
503
|
+
},
|
|
504
|
+
issue: {
|
|
505
|
+
// prettier-ignore
|
|
506
|
+
include: [
|
|
507
|
+
{file: '../**/src/**/*.{ts,tsx}'},
|
|
508
|
+
{file: '**/src/**/*.{ts,tsx}'}
|
|
509
|
+
],
|
|
510
|
+
exclude: [
|
|
511
|
+
{file: '**/src/**/__tests__/**'},
|
|
512
|
+
{file: '**/src/**/?(*.){spec|test}.*'},
|
|
513
|
+
{file: '**/src/setupProxy.*'},
|
|
514
|
+
{file: '**/src/setupTests.*'}
|
|
515
|
+
]
|
|
516
|
+
},
|
|
517
|
+
logger: {
|
|
518
|
+
infrastructure: 'silent'
|
|
519
|
+
}
|
|
488
520
|
}),
|
|
489
521
|
new ESLintPlugin({
|
|
490
522
|
// Plugin options
|
package/docs/building-apps.md
CHANGED
|
@@ -33,7 +33,7 @@ By default, projects will build in development mode. When you're code is ready f
|
|
|
33
33
|
## Browser Support & Polyfills
|
|
34
34
|
The Enact CLI is designed to be compatible with a wide array of browsers and devices. [Browserslist standard](https://github.com/browserslist/browserslist) is used to handle targeting, with Enact's defaults being:
|
|
35
35
|
|
|
36
|
-
*
|
|
36
|
+
* \>1%
|
|
37
37
|
* last 2 versions
|
|
38
38
|
* last 5 Chrome versions
|
|
39
39
|
* last 5 Firefox versions
|
|
@@ -105,7 +105,7 @@ npm install --save typescript @types/react @types/react-dom @types/jest
|
|
|
105
105
|
Optionally, [ESLint](https://eslint.org) can be installed globally or locally and configured within a project to enable linting support within the `enact lint` command.
|
|
106
106
|
|
|
107
107
|
## Isomorphic Support & Prerendering
|
|
108
|
-
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
|
|
108
|
+
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).
|
|
109
109
|
|
|
110
110
|
## V8 Snapshot Generation
|
|
111
111
|
The v8 snapshot blob creation feature is highly experimental and temperamental depending on your code. It is considered an extension of the isomorphic code layout, bringing along all the same requirements. Given the highly-specific nature of a v8 snapshot blob being tied to particular versions of Chrome/Chromium/Electron/etc., developers must provide their own copy of the `mksnapshot` binary and have its filepath set to the `V8_MKSNAPSHOT` environment variable.
|
package/docs/installation.md
CHANGED
|
@@ -18,9 +18,3 @@ All releases are published, with the default (and `latest` tag) being the curren
|
|
|
18
18
|
### Linux Notes
|
|
19
19
|
|
|
20
20
|
When installing under Linux, it may be necessary to prefix the install command with `sudo`.
|
|
21
|
-
Additionally, if you receive an error when the install process attempts to install PhantomJS, try
|
|
22
|
-
the following:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
sudo npm install -g --unsafe-perm @enact/cli
|
|
26
|
-
```
|