@zohodesk/react-cli 1.1.20 → 1.1.22
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/README.md +16 -1
- package/bin/cli.js +4 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -9
- package/lib/babel/es-plugins-presets.js +33 -18
- package/lib/configs/jest.config.js +3 -3
- package/lib/configs/resolvers.js +1 -0
- package/lib/configs/webpack.dev.config.js +7 -2
- package/lib/configs/webpack.prod.config.js +8 -3
- package/lib/jest/preProcessors/jsPreprocessor.js +23 -2
- package/lib/loaderUtils/getDevJsLoaders.js +2 -1
- package/lib/pluginUtils/getDevPlugins.js +5 -2
- package/lib/pluginUtils/getProdPlugins.js +3 -0
- package/lib/plugins/EventsHandlingPlugin.js +34 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +5 -1
- package/lib/schemas/index.js +7 -0
- package/npm-shrinkwrap.json +983 -27
- package/package.json +4 -1
package/README.md
CHANGED
@@ -44,7 +44,22 @@ Now to run app
|
|
44
44
|
|
45
45
|
# Change Logs
|
46
46
|
|
47
|
-
# 1.1.
|
47
|
+
# 1.1.21 (4-6-2024)
|
48
|
+
|
49
|
+
- TypeScript support has been added for the application, library, and Jest.
|
50
|
+
|
51
|
+
- The `enable_typescript` option has been added in the react-cli.config.js. Set it to true to enable TypeScript
|
52
|
+
|
53
|
+
- Support for adding plugins is now available. To use this, configure your react-cli.config.js file as follows:
|
54
|
+
|
55
|
+
```
|
56
|
+
babelCustomizationForLibrary: {
|
57
|
+
babelPlugins: [<`your plugins`>]
|
58
|
+
},
|
59
|
+
```
|
60
|
+
- The Memory leak issue while downloading i18n and CSS files has been fixed
|
61
|
+
|
62
|
+
# 1.1.20 (27-5-2024)
|
48
63
|
|
49
64
|
**Feature**
|
50
65
|
|
package/bin/cli.js
CHANGED
@@ -300,6 +300,8 @@ switch (option) {
|
|
300
300
|
'src',
|
301
301
|
'-d',
|
302
302
|
'lib',
|
303
|
+
'--extensions',
|
304
|
+
'.js,.ts,.tsx',
|
303
305
|
`--presets=${require.resolve('../lib/babel/cmjs-plugins-presets.js')}`,
|
304
306
|
'--copy-files'
|
305
307
|
].concat(args),
|
@@ -316,6 +318,8 @@ switch (option) {
|
|
316
318
|
'src',
|
317
319
|
'--out-dir',
|
318
320
|
'es',
|
321
|
+
'--extensions',
|
322
|
+
'.js,.ts,.tsx',
|
319
323
|
`--presets=${require.resolve('../lib/babel/es-plugins-presets.js')}`,
|
320
324
|
'--copy-files'
|
321
325
|
].concat(args),
|
@@ -11,20 +11,35 @@ var _babelPresetReactOption = _interopRequireDefault(require("./babel-option-uti
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
-
|
14
|
+
const {
|
15
15
|
module: {
|
16
16
|
mode
|
17
|
-
}
|
17
|
+
},
|
18
|
+
babelCustomizationForLibrary: {
|
19
|
+
babelPlugins
|
20
|
+
},
|
21
|
+
enableTypeScript
|
18
22
|
} = (0, _utils.getOptions)();
|
19
|
-
|
23
|
+
const isProd = mode.toLowerCase() === 'prod';
|
24
|
+
const defaultPlugins = [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
25
|
+
__DOCS__: false
|
26
|
+
} : {}], require.resolve('@babel/plugin-syntax-dynamic-import')];
|
27
|
+
const resolvedPlugins = [];
|
28
|
+
babelPlugins.forEach(plugin => {
|
29
|
+
resolvedPlugins.push(require.resolve(plugin));
|
30
|
+
});
|
31
|
+
const plugins = [...defaultPlugins, ...resolvedPlugins];
|
32
|
+
const presets = [require.resolve('@babel/preset-env'), (0, _babelPresetReactOption.default)({
|
33
|
+
disableES5Transpile: false
|
34
|
+
})];
|
35
|
+
|
36
|
+
if (enableTypeScript) {
|
37
|
+
presets.push(require.resolve('@babel/preset-typescript'));
|
38
|
+
}
|
20
39
|
|
21
40
|
var _default = () => ({
|
22
|
-
presets:
|
23
|
-
|
24
|
-
})],
|
25
|
-
plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
26
|
-
__DOCS__: false
|
27
|
-
} : {}]]
|
41
|
+
presets: presets,
|
42
|
+
plugins: plugins
|
28
43
|
});
|
29
44
|
|
30
45
|
exports.default = _default;
|
@@ -11,30 +11,45 @@ var _babelPresetReactOption = _interopRequireDefault(require("./babel-option-uti
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
-
|
14
|
+
const {
|
15
15
|
module: {
|
16
16
|
mode,
|
17
17
|
disableES5Transpile
|
18
|
-
}
|
18
|
+
},
|
19
|
+
babelCustomizationForLibrary: {
|
20
|
+
babelPlugins
|
21
|
+
},
|
22
|
+
enableTypeScript
|
19
23
|
} = (0, _utils.getOptions)();
|
20
|
-
|
24
|
+
const isProd = mode.toLowerCase() === 'prod';
|
25
|
+
const defaultPlugins = [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
26
|
+
__DOCS__: false
|
27
|
+
} : {}], require.resolve('@babel/plugin-syntax-dynamic-import')];
|
28
|
+
const resolvedPlugins = [];
|
29
|
+
babelPlugins.forEach(plugin => {
|
30
|
+
resolvedPlugins.push(require.resolve(plugin));
|
31
|
+
});
|
32
|
+
const plugins = [...defaultPlugins, ...resolvedPlugins];
|
33
|
+
const presets = [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
|
34
|
+
modules: false,
|
35
|
+
useBuiltIns: 'usage',
|
36
|
+
corejs: 3,
|
37
|
+
targets: {
|
38
|
+
browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
|
39
|
+
}
|
40
|
+
} : {
|
41
|
+
modules: false
|
42
|
+
}], (0, _babelPresetReactOption.default)({
|
43
|
+
disableES5Transpile
|
44
|
+
})];
|
45
|
+
|
46
|
+
if (enableTypeScript) {
|
47
|
+
presets.push(require.resolve('@babel/preset-typescript'));
|
48
|
+
}
|
21
49
|
|
22
50
|
var _default = () => ({
|
23
|
-
presets:
|
24
|
-
|
25
|
-
useBuiltIns: 'usage',
|
26
|
-
corejs: 3,
|
27
|
-
targets: {
|
28
|
-
browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
|
29
|
-
}
|
30
|
-
} : {
|
31
|
-
modules: false
|
32
|
-
}], (0, _babelPresetReactOption.default)({
|
33
|
-
disableES5Transpile
|
34
|
-
})],
|
35
|
-
plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
36
|
-
__DOCS__: false
|
37
|
-
} : {}], require.resolve('@babel/plugin-syntax-dynamic-import')]
|
51
|
+
presets: presets,
|
52
|
+
plugins: plugins
|
38
53
|
});
|
39
54
|
|
40
55
|
exports.default = _default;
|
@@ -17,7 +17,7 @@ const commonConfig = {
|
|
17
17
|
collectCoverage: true,
|
18
18
|
moduleDirectories: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
19
19
|
transform: {
|
20
|
-
'^.+\\.(js|jsx)$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
|
20
|
+
'^.+\\.(js|jsx|ts|tsx)$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
|
21
21
|
'^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
|
22
22
|
'^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
|
23
23
|
},
|
@@ -28,7 +28,7 @@ const commonConfig = {
|
|
28
28
|
// },
|
29
29
|
transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
|
30
30
|
// transformIgnorePatterns: ['/node_modules.*?.js$'],
|
31
|
-
moduleFileExtensions: ['js'],
|
31
|
+
moduleFileExtensions: ['js', 'ts', 'tsx'],
|
32
32
|
setupFiles: [(0, _fs.existsSync)(appGlobals) && appGlobals, _path.default.resolve(__dirname, '..', 'jest', 'setup.js')].filter(Boolean),
|
33
33
|
globals: {
|
34
34
|
__DEVELOPMENT__: true,
|
@@ -52,7 +52,7 @@ module.exports = (...args) => {
|
|
52
52
|
testPathIgnorePatterns: ['/node_modules/', 'docs'],
|
53
53
|
unmockedModulePathPatterns: ['__tests__', 'node_modules', '.*'],
|
54
54
|
roots: [`<rootDir>/${appFolder}/`],
|
55
|
-
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(jsx|js|json|node)$',
|
55
|
+
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(jsx|js|json|node|ts|tsx)$',
|
56
56
|
testResultsProcessor: _path.default.resolve(__dirname, '..', 'jest', 'result.js')
|
57
57
|
});
|
58
58
|
};
|
package/lib/configs/resolvers.js
CHANGED
@@ -33,6 +33,7 @@ function moduleResolver(options) {
|
|
33
33
|
|
34
34
|
const nodeModulesPath = required ? required.nodeModulesPath : _client_packages_group.nodeModulesPath;
|
35
35
|
return {
|
36
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
36
37
|
modules: [nodeModulesPath, _constants.cliNodeModulesPath, 'node_modules'].filter(Boolean),
|
37
38
|
alias: disableES5Transpile ? _libAlias.libAlias : {} // alias: { ...libAlias, ...clientDependenies }
|
38
39
|
|
@@ -44,7 +44,8 @@ const {
|
|
44
44
|
postCssPluginOrder,
|
45
45
|
externals,
|
46
46
|
enableMjsLoader
|
47
|
-
}
|
47
|
+
},
|
48
|
+
enableTypeScript
|
48
49
|
} = options;
|
49
50
|
const {
|
50
51
|
disableContextURL
|
@@ -146,7 +147,11 @@ module.exports = {
|
|
146
147
|
minimize: true
|
147
148
|
}
|
148
149
|
}]
|
149
|
-
}, {
|
150
|
+
}, enableTypeScript ? {
|
151
|
+
test: /\.ts$|\.tsx$/,
|
152
|
+
use: 'ts-loader',
|
153
|
+
include: _path.default.join(appPath, folder)
|
154
|
+
} : null, {
|
150
155
|
test: /\.worker.js$/,
|
151
156
|
use: {
|
152
157
|
loader: require.resolve('../loaders/workerLoader.js'),
|
@@ -50,7 +50,8 @@ const {
|
|
50
50
|
crossorigin,
|
51
51
|
postCssPluginOrder,
|
52
52
|
externals
|
53
|
-
}
|
53
|
+
},
|
54
|
+
enableTypeScript
|
54
55
|
} = options;
|
55
56
|
let {
|
56
57
|
enableChunkHash
|
@@ -131,7 +132,7 @@ module.exports = {
|
|
131
132
|
modules: false
|
132
133
|
}], (0, _babelPresetReactOption.default)({
|
133
134
|
disableES5Transpile
|
134
|
-
})],
|
135
|
+
}), enableTypeScript ? require.resolve('@babel/preset-typescript') : null].filter(Boolean),
|
135
136
|
plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve(
|
136
137
|
// '@babel/plugin-proposal-object-rest-spread'
|
137
138
|
// ), REMOVING IT, BECAUSE WE ALREADY SUPPORT SPREAD SYNTAX FROM LIBRARIES.
|
@@ -237,7 +238,11 @@ module.exports = {
|
|
237
238
|
minimize: false
|
238
239
|
}
|
239
240
|
}]
|
240
|
-
}, {
|
241
|
+
}, enableTypeScript ? {
|
242
|
+
test: /\.ts$|\.tsx$/,
|
243
|
+
use: 'ts-loader',
|
244
|
+
include: _path.default.join(appPath, folder)
|
245
|
+
} : null, {
|
241
246
|
test: /\.worker.js$/,
|
242
247
|
use: {
|
243
248
|
loader: require.resolve('../loaders/workerLoader.js'),
|
@@ -4,7 +4,28 @@ var _babelJest = _interopRequireDefault(require("babel-jest"));
|
|
4
4
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
6
|
|
7
|
+
const getOptions = require('../../../lib/utils/getOptions').default;
|
8
|
+
|
9
|
+
const {
|
10
|
+
enableTypeScript,
|
11
|
+
babelCustomizationForLibrary
|
12
|
+
} = getOptions();
|
13
|
+
const {
|
14
|
+
babelPlugins
|
15
|
+
} = babelCustomizationForLibrary;
|
16
|
+
const resolvedPlugins = [];
|
17
|
+
babelPlugins.forEach(plugin => {
|
18
|
+
resolvedPlugins.push(require.resolve(plugin));
|
19
|
+
});
|
20
|
+
const presets = [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')];
|
21
|
+
|
22
|
+
if (enableTypeScript) {
|
23
|
+
presets.push(require.resolve('@babel/preset-typescript'));
|
24
|
+
}
|
25
|
+
|
26
|
+
const defaultPlugins = [require.resolve('babel-plugin-transform-dynamic-import')];
|
27
|
+
const plugins = [...defaultPlugins, ...resolvedPlugins];
|
7
28
|
module.exports = _babelJest.default.createTransformer({
|
8
|
-
presets:
|
9
|
-
plugins:
|
29
|
+
presets: presets,
|
30
|
+
plugins: plugins
|
10
31
|
});
|
@@ -18,6 +18,7 @@ let getDevJsLoaders = options => {
|
|
18
18
|
instrumentScript,
|
19
19
|
devConsoleExculde
|
20
20
|
},
|
21
|
+
enableTypeScript,
|
21
22
|
esLint: {
|
22
23
|
enable: enableEslint
|
23
24
|
}
|
@@ -44,7 +45,7 @@ let getDevJsLoaders = options => {
|
|
44
45
|
modules: false
|
45
46
|
}], (0, _babelPresetReactOption.default)({
|
46
47
|
disableES5Transpile
|
47
|
-
})],
|
48
|
+
}), enableTypeScript ? require.resolve('@babel/preset-typescript') : null].filter(Boolean),
|
48
49
|
plugins: disableES5Transpile ? [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve('@babel/plugin-proposal-object-rest-spread'),
|
49
50
|
devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
|
50
51
|
exclude: ['error', 'log']
|
@@ -37,6 +37,8 @@ var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
|
37
37
|
|
38
38
|
var _EfcResourceCleanupPlugin = _interopRequireDefault(require("../plugins/EfcResourceCleanupPlugin"));
|
39
39
|
|
40
|
+
var _EventsHandlingPlugin = require("../plugins/EventsHandlingPlugin");
|
41
|
+
|
40
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
41
43
|
|
42
44
|
// import { windowsModification } from '../loaderUtils/windowsModification';
|
@@ -217,12 +219,13 @@ const getDevPlugins = (options, publicPath) => {
|
|
217
219
|
exclude: exclude.selectorWeight,
|
218
220
|
patterns
|
219
221
|
}));
|
220
|
-
}
|
222
|
+
}
|
223
|
+
|
224
|
+
pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin()); // if (pluginObject.minifier) {
|
221
225
|
// // console.log('minifier active');
|
222
226
|
// pluginsArr.push(new MinifierPlugin());
|
223
227
|
// }
|
224
228
|
|
225
|
-
|
226
229
|
return pluginsArr.filter(Boolean);
|
227
230
|
};
|
228
231
|
|
@@ -27,6 +27,8 @@ var _VariableConversionCollector = _interopRequireDefault(require("../plugins/Va
|
|
27
27
|
|
28
28
|
var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
|
29
29
|
|
30
|
+
var _EventsHandlingPlugin = require("../plugins/EventsHandlingPlugin");
|
31
|
+
|
30
32
|
var _plugins = require("../plugins");
|
31
33
|
|
32
34
|
var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
|
@@ -306,6 +308,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
306
308
|
statsOutputExcludeKeys,
|
307
309
|
statsFileName
|
308
310
|
}));
|
311
|
+
pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin());
|
309
312
|
return pluginsArr;
|
310
313
|
};
|
311
314
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.EventsHandlingPlugin = void 0;
|
7
|
+
|
8
|
+
/* eslint-disable no-use-before-define */
|
9
|
+
class EventsHandlingPlugin {
|
10
|
+
constructor(options) {}
|
11
|
+
|
12
|
+
apply(compiler) {
|
13
|
+
// NOTE: we not using this, Reason currently this option is only need for EFC,
|
14
|
+
// So it do not needed.
|
15
|
+
compiler.hooks.thisCompilation.tap({
|
16
|
+
name: 'CustomAttributePlugin',
|
17
|
+
stage: 1,
|
18
|
+
fn: compilation => {
|
19
|
+
compilation.mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
20
|
+
// const str = attributeSetTemplate(cssAttributes, 'linkTag');
|
21
|
+
const sourceStr = source.replace('linkTag.onerror = function(event) {', 'linkTag.onerror = function(event) { linkTag.onerror = linkTag.onload = null');
|
22
|
+
const replacedSourceStr = sourceStr.replace('linkTag.onload = resolve', `linkTag.onload = () => {
|
23
|
+
resolve();
|
24
|
+
linkTag.onerror = linkTag.onload = null
|
25
|
+
};`);
|
26
|
+
return replacedSourceStr;
|
27
|
+
});
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
exports.EventsHandlingPlugin = EventsHandlingPlugin;
|
@@ -228,8 +228,12 @@ class I18nDownlodLogic {
|
|
228
228
|
if(dataSrc === srcPath || dataSrc === fullsrcPath){ return resolve();}
|
229
229
|
}
|
230
230
|
var scriptTag = document.createElement("script");
|
231
|
-
scriptTag.onload =
|
231
|
+
scriptTag.onload = () => {
|
232
|
+
resolve();
|
233
|
+
scriptTag.onerror = scriptTag.onload = null;
|
234
|
+
};
|
232
235
|
scriptTag.onerror = function(event) {
|
236
|
+
scriptTag.onerror = scriptTag.onload = null;
|
233
237
|
var request = event && event.target && event.target.src || fullsrcPath;
|
234
238
|
var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + request + ")");
|
235
239
|
err.code = "I18N_CHUNK_LOAD_FAILED";
|
package/lib/schemas/index.js
CHANGED
@@ -738,6 +738,13 @@ var _default = {
|
|
738
738
|
fileName: null,
|
739
739
|
options: null,
|
740
740
|
excludeKeys: null
|
741
|
+
},
|
742
|
+
babelCustomizationForLibrary: {
|
743
|
+
babelPlugins: []
|
744
|
+
},
|
745
|
+
enableTypeScript: {
|
746
|
+
value: false,
|
747
|
+
cli: 'enable_typescript'
|
741
748
|
}
|
742
749
|
};
|
743
750
|
exports.default = _default;
|