@enact/cli 4.1.5 → 5.0.0-alpha.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.
- package/.eslintrc.js +1 -1
- package/CHANGELOG.md +33 -1
- package/README.md +2 -2
- 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 +140 -99
- package/npm-shrinkwrap.json +22521 -13933
- 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)
|
|
@@ -162,6 +176,11 @@ module.exports = function (env) {
|
|
|
162
176
|
}
|
|
163
177
|
});
|
|
164
178
|
|
|
179
|
+
const getAdditionalModulePaths = paths => {
|
|
180
|
+
if (!paths) return [];
|
|
181
|
+
return Array.isArray(paths) ? paths : [paths];
|
|
182
|
+
};
|
|
183
|
+
|
|
165
184
|
return {
|
|
166
185
|
mode: isEnvProduction ? 'production' : 'development',
|
|
167
186
|
// Don't attempt to continue if there are any errors.
|
|
@@ -186,6 +205,7 @@ module.exports = function (env) {
|
|
|
186
205
|
filename: '[name].js',
|
|
187
206
|
// There are also additional JS chunk files if you use code splitting.
|
|
188
207
|
chunkFilename: 'chunk.[name].js',
|
|
208
|
+
assetModuleFilename: '[path][name][ext]',
|
|
189
209
|
// Add /* filename */ comments to generated require()s in the output.
|
|
190
210
|
pathinfo: !isEnvProduction,
|
|
191
211
|
publicPath,
|
|
@@ -205,13 +225,21 @@ module.exports = function (env) {
|
|
|
205
225
|
} else {
|
|
206
226
|
return file;
|
|
207
227
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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'
|
|
215
243
|
},
|
|
216
244
|
resolve: {
|
|
217
245
|
// These are the reasonable defaults supported by the React/ES6 ecosystem.
|
|
@@ -219,7 +247,11 @@ module.exports = function (env) {
|
|
|
219
247
|
ext => useTypeScript || !ext.includes('ts')
|
|
220
248
|
),
|
|
221
249
|
// Allows us to specify paths to check for module resolving.
|
|
222
|
-
modules: [
|
|
250
|
+
modules: [
|
|
251
|
+
path.resolve('./node_modules'),
|
|
252
|
+
'node_modules',
|
|
253
|
+
...getAdditionalModulePaths(app.additionalModulePaths)
|
|
254
|
+
],
|
|
223
255
|
// Don't resolve symlinks to their underlying paths
|
|
224
256
|
symlinks: false,
|
|
225
257
|
// Backward compatibility for apps using new ilib references with old Enact
|
|
@@ -237,6 +269,12 @@ module.exports = function (env) {
|
|
|
237
269
|
// @remove-on-eject-end
|
|
238
270
|
module: {
|
|
239
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
|
+
},
|
|
240
278
|
{
|
|
241
279
|
// "oneOf" will traverse all following loaders until one will
|
|
242
280
|
// match the requirements. When no loader matches it will fall
|
|
@@ -264,13 +302,23 @@ module.exports = function (env) {
|
|
|
264
302
|
// options used at each level of processing.
|
|
265
303
|
{
|
|
266
304
|
test: /\.module\.css$/,
|
|
267
|
-
use: getStyleLoaders({
|
|
305
|
+
use: getStyleLoaders({
|
|
306
|
+
modules: {
|
|
307
|
+
getLocalIdent,
|
|
308
|
+
mode: 'local'
|
|
309
|
+
}
|
|
310
|
+
})
|
|
268
311
|
},
|
|
269
312
|
{
|
|
270
313
|
test: /\.css$/,
|
|
271
314
|
// The `forceCSSModules` Enact build option can be set true to universally apply
|
|
272
315
|
// modular CSS support.
|
|
273
|
-
use: getStyleLoaders({
|
|
316
|
+
use: getStyleLoaders({
|
|
317
|
+
modules: {
|
|
318
|
+
...(app.forceCSSModules ? {getLocalIdent} : {}),
|
|
319
|
+
mode: 'icss'
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
274
322
|
// Don't consider CSS imports dead code even if the
|
|
275
323
|
// containing package claims to have no side effects.
|
|
276
324
|
// Remove this when webpack adds a warning or an error for this.
|
|
@@ -279,18 +327,27 @@ module.exports = function (env) {
|
|
|
279
327
|
},
|
|
280
328
|
{
|
|
281
329
|
test: /\.module\.less$/,
|
|
282
|
-
use: getLessStyleLoaders({
|
|
330
|
+
use: getLessStyleLoaders({
|
|
331
|
+
modules: {
|
|
332
|
+
getLocalIdent,
|
|
333
|
+
mode: 'local'
|
|
334
|
+
}
|
|
335
|
+
})
|
|
283
336
|
},
|
|
284
337
|
{
|
|
285
338
|
test: /\.less$/,
|
|
286
|
-
use: getLessStyleLoaders({
|
|
339
|
+
use: getLessStyleLoaders({
|
|
340
|
+
modules: {
|
|
341
|
+
...(app.forceCSSModules ? {getLocalIdent} : {}),
|
|
342
|
+
mode: 'icss'
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
287
345
|
sideEffects: true
|
|
288
346
|
},
|
|
289
347
|
// "file" loader handles on all files not caught by the above loaders.
|
|
290
348
|
// When you `import` an asset, you get its output filename and the file
|
|
291
349
|
// is copied during the build process.
|
|
292
350
|
{
|
|
293
|
-
loader: require.resolve('file-loader'),
|
|
294
351
|
// Exclude `js` files to keep "css" loader working as it injects
|
|
295
352
|
// its runtime that would otherwise be processed through "file" loader.
|
|
296
353
|
// Also exclude `html` and `json` extensions so they get processed
|
|
@@ -298,36 +355,21 @@ module.exports = function (env) {
|
|
|
298
355
|
// Exclude `ejs` HTML templating language as that's handled by
|
|
299
356
|
// the HtmlWebpackPlugin.
|
|
300
357
|
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.ejs$/, /\.json$/],
|
|
301
|
-
|
|
302
|
-
name: '[path][name].[ext]'
|
|
303
|
-
}
|
|
358
|
+
type: 'asset/resource'
|
|
304
359
|
}
|
|
305
360
|
// ** STOP ** Are you adding a new loader?
|
|
306
361
|
// Make sure to add the new loader(s) before the "file" loader.
|
|
307
362
|
]
|
|
308
363
|
}
|
|
309
|
-
]
|
|
364
|
+
].filter(Boolean)
|
|
310
365
|
},
|
|
311
366
|
// Specific webpack-dev-server options.
|
|
312
367
|
devServer: {
|
|
313
368
|
// Broadcast http server on the localhost, port 8080.
|
|
314
369
|
host: '0.0.0.0',
|
|
315
|
-
port: 8080
|
|
316
|
-
// Support the same public path as webpack config.
|
|
317
|
-
publicPath: publicPath,
|
|
318
|
-
// By default WebpackDevServer serves files from public and __mocks__ directories
|
|
319
|
-
// in addition to all the virtual build products that it serves from memory.
|
|
320
|
-
contentBase: [path.resolve('./public'), path.resolve('./__mocks__')],
|
|
321
|
-
contentBasePublicPath: publicPath + '/',
|
|
322
|
-
// Any changes to files from `contentBase` should trigger a page reload.
|
|
323
|
-
watchContentBase: true,
|
|
324
|
-
// Reportedly, this avoids CPU overload on some systems.
|
|
325
|
-
// https://github.com/facebookincubator/create-react-app/issues/293
|
|
326
|
-
watchOptions: {
|
|
327
|
-
ignored: /node_modules[\\/](?!@enact[\\/](?!.*node_modules))/
|
|
328
|
-
}
|
|
370
|
+
port: 8080
|
|
329
371
|
},
|
|
330
|
-
// Target app to build for a specific environment (default '
|
|
372
|
+
// Target app to build for a specific environment (default 'browserslist')
|
|
331
373
|
target: app.environment,
|
|
332
374
|
// Optional configuration for polyfilling NodeJS built-ins.
|
|
333
375
|
node: app.nodeBuiltins,
|
|
@@ -373,29 +415,9 @@ module.exports = function (env) {
|
|
|
373
415
|
},
|
|
374
416
|
// Use multi-process parallel running to improve the build speed
|
|
375
417
|
// Default number of concurrent runs: os.cpus().length - 1
|
|
376
|
-
parallel: true
|
|
377
|
-
// Enable file caching
|
|
378
|
-
cache: true,
|
|
379
|
-
sourceMap: shouldUseSourceMap
|
|
418
|
+
parallel: true
|
|
380
419
|
}),
|
|
381
|
-
new
|
|
382
|
-
cssProcessorOptions: {
|
|
383
|
-
// TODO: verify calc issue fixed. Related: https://github.com/postcss/postcss-calc/issues/50
|
|
384
|
-
// calc: false,
|
|
385
|
-
parser: require('postcss-safe-parser'),
|
|
386
|
-
map: shouldUseSourceMap && {
|
|
387
|
-
// `inline: false` forces the sourcemap to be output into a
|
|
388
|
-
// separate file
|
|
389
|
-
inline: false,
|
|
390
|
-
// `annotation: true` appends the sourceMappingURL to the end of
|
|
391
|
-
// the css file, helping the browser find the sourcemap
|
|
392
|
-
annotation: true
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
cssProcessorPluginOptions: {
|
|
396
|
-
preset: ['default', {minifyFontValues: {removeQuotes: false}}]
|
|
397
|
-
}
|
|
398
|
-
})
|
|
420
|
+
new CssMinimizerPlugin()
|
|
399
421
|
]
|
|
400
422
|
},
|
|
401
423
|
plugins: [
|
|
@@ -436,15 +458,12 @@ module.exports = function (env) {
|
|
|
436
458
|
filename: '[name].css',
|
|
437
459
|
chunkFilename: 'chunk.[name].css'
|
|
438
460
|
}),
|
|
461
|
+
// Webpack5 removed node polyfills but we need this to run screenshot tests
|
|
462
|
+
new NodePolyfillPlugin(),
|
|
439
463
|
// Provide meaningful information when modules are not found
|
|
440
464
|
new ModuleNotFoundPlugin(app.context),
|
|
441
465
|
// Ensure correct casing in module filepathes
|
|
442
466
|
new CaseSensitivePathsPlugin(),
|
|
443
|
-
// If you require a missing module and then `npm install` it, you still have
|
|
444
|
-
// to restart the development server for Webpack to discover it. This plugin
|
|
445
|
-
// makes the discovery automatic so you don't have to restart.
|
|
446
|
-
// See https://github.com/facebookincubator/create-react-app/issues/186
|
|
447
|
-
!isEnvProduction && new WatchMissingNodeModulesPlugin('./node_modules'),
|
|
448
467
|
// Switch the internal NodeOutputFilesystem to use graceful-fs to avoid
|
|
449
468
|
// EMFILE errors when hanndling mass amounts of files at once, such as
|
|
450
469
|
// what happens when using ilib bundles/resources.
|
|
@@ -452,30 +471,52 @@ module.exports = function (env) {
|
|
|
452
471
|
// Automatically configure iLib library within @enact/i18n. Additionally,
|
|
453
472
|
// ensure the locale data files and the resource files are copied during
|
|
454
473
|
// the build to the output directory.
|
|
455
|
-
new ILibPlugin({symlinks: false}),
|
|
474
|
+
new ILibPlugin({publicPath, symlinks: false, ilibAdditionalResourcesPath}),
|
|
456
475
|
// Automatically detect ./appinfo.json and ./webos-meta/appinfo.json files,
|
|
457
476
|
// and parses any to copy over any webOS meta assets at build time.
|
|
458
477
|
new WebOSMetaPlugin({htmlPlugin: HtmlWebpackPlugin}),
|
|
459
478
|
// TypeScript type checking
|
|
460
479
|
useTypeScript &&
|
|
461
480
|
new ForkTsCheckerWebpackPlugin({
|
|
462
|
-
typescript: resolve.sync('typescript', {
|
|
463
|
-
basedir: 'node_modules'
|
|
464
|
-
}),
|
|
465
481
|
async: !isEnvProduction,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
+
}
|
|
479
520
|
}),
|
|
480
521
|
new ESLintPlugin({
|
|
481
522
|
// Plugin options
|