@zohodesk/react-cli 1.1.20 → 1.1.22-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +38 -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 +12 -4
- package/lib/jest/preProcessors/jsPreprocessor.js +23 -2
- package/lib/loaderUtils/getDevJsLoaders.js +2 -1
- package/lib/loaders/workerLoader.js +39 -24
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +57 -1
- package/lib/pluginUtils/getDevPlugins.js +9 -4
- package/lib/pluginUtils/getProdPlugins.js +6 -1
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +108 -0
- package/lib/plugins/EventsHandlingPlugin.js +34 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +5 -1
- package/lib/schemas/index.js +12 -1
- package/lib/utils/index.js +14 -0
- package/lib/utils/typeCheck.js +10 -0
- package/npm-shrinkwrap.json +983 -27
- package/package.json +4 -1
package/README.md
CHANGED
@@ -44,7 +44,44 @@ 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
|
+
|
63
|
+
# 1.1.20-exp.1
|
64
|
+
|
65
|
+
**Changes**
|
66
|
+
|
67
|
+
- Added memory leak fixes for script, links tags
|
68
|
+
|
69
|
+
**Feature**
|
70
|
+
- Custom Script loading strategy support for initial html script tags.
|
71
|
+
|
72
|
+
# 1.1.19-exp.18
|
73
|
+
|
74
|
+
**Changes**
|
75
|
+
|
76
|
+
- To do further build size optimization by utilizing webpack provided config.
|
77
|
+
|
78
|
+
```
|
79
|
+
innerGraph: true,
|
80
|
+
usedExports: true,
|
81
|
+
sideEffects: true
|
82
|
+
```
|
83
|
+
|
84
|
+
# 1.1.20 (27-5-2024)
|
48
85
|
|
49
86
|
**Feature**
|
50
87
|
|
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
|
@@ -102,7 +103,10 @@ module.exports = {
|
|
102
103
|
// exclude: /\/smap/
|
103
104
|
// })
|
104
105
|
// ],
|
105
|
-
moduleIds: 'named'
|
106
|
+
moduleIds: 'named',
|
107
|
+
usedExports: true,
|
108
|
+
// innerGraph: true, // this property present on webpack 5
|
109
|
+
sideEffects: true
|
106
110
|
},
|
107
111
|
stats: {
|
108
112
|
children: false,
|
@@ -131,7 +135,7 @@ module.exports = {
|
|
131
135
|
modules: false
|
132
136
|
}], (0, _babelPresetReactOption.default)({
|
133
137
|
disableES5Transpile
|
134
|
-
})],
|
138
|
+
}), enableTypeScript ? require.resolve('@babel/preset-typescript') : null].filter(Boolean),
|
135
139
|
plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve(
|
136
140
|
// '@babel/plugin-proposal-object-rest-spread'
|
137
141
|
// ), REMOVING IT, BECAUSE WE ALREADY SUPPORT SPREAD SYNTAX FROM LIBRARIES.
|
@@ -237,7 +241,11 @@ module.exports = {
|
|
237
241
|
minimize: false
|
238
242
|
}
|
239
243
|
}]
|
240
|
-
}, {
|
244
|
+
}, enableTypeScript ? {
|
245
|
+
test: /\.ts$|\.tsx$/,
|
246
|
+
use: 'ts-loader',
|
247
|
+
include: _path.default.join(appPath, folder)
|
248
|
+
} : null, {
|
241
249
|
test: /\.worker.js$/,
|
242
250
|
use: {
|
243
251
|
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']
|
@@ -19,32 +19,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
19
19
|
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
20
20
|
import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
|
21
21
|
const schema = {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
type: 'object',
|
23
|
+
properties: {
|
24
|
+
publicPath: {
|
25
|
+
anyOf: [{
|
26
|
+
type: 'string'
|
27
27
|
}, {
|
28
|
-
|
28
|
+
instanceof: 'Function'
|
29
29
|
}]
|
30
30
|
},
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
filename: {
|
32
|
+
anyOf: [{
|
33
|
+
type: 'string',
|
34
|
+
minLength: 1
|
35
35
|
}, {
|
36
|
-
|
36
|
+
instanceof: 'Function'
|
37
37
|
}]
|
38
38
|
},
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
chunkFilename: {
|
40
|
+
type: 'string',
|
41
|
+
minLength: 1
|
42
42
|
},
|
43
|
-
|
44
|
-
|
43
|
+
esModule: {
|
44
|
+
type: 'boolean'
|
45
45
|
}
|
46
46
|
},
|
47
|
-
|
47
|
+
additionalProperties: false
|
48
48
|
}; // eslint-disable-next-line
|
49
49
|
|
50
50
|
function loader() {}
|
@@ -112,25 +112,40 @@ function pitch(request) {
|
|
112
112
|
}
|
113
113
|
|
114
114
|
function workerCode() {
|
115
|
+
if (this.workerInstance) {
|
116
|
+
return this.workerInstance;
|
117
|
+
}
|
118
|
+
|
115
119
|
let blob;
|
116
120
|
|
117
121
|
try {
|
118
122
|
blob = new Blob([`importScripts('${this.workerUrl}');`], {
|
119
|
-
|
123
|
+
type: 'application/javascript'
|
120
124
|
});
|
121
125
|
} catch (e1) {
|
122
126
|
throw new Error(e1);
|
123
127
|
}
|
124
128
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
return
|
129
|
+
const url = window.URL || window.webkitURL;
|
130
|
+
const blobUrl = url.createObjectURL(blob);
|
131
|
+
this.workerInstance = new Worker(blobUrl);
|
132
|
+
return this.workerInstance;
|
129
133
|
}
|
130
134
|
|
131
|
-
return cb(null,
|
135
|
+
return cb(null, `const workerObj ={\n
|
136
|
+
workerInstance: null, \n
|
132
137
|
workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
|
133
138
|
getInstance: ${workerCode} \n
|
134
|
-
}
|
139
|
+
};\n
|
140
|
+
workerObj.getInstance();
|
141
|
+
${options.esModule ? 'export default' : 'module.exports ='} workerObj;
|
142
|
+
`); // return cb(
|
143
|
+
// null,
|
144
|
+
// `${options.esModule ? 'export default' : 'module.exports ='} {\n
|
145
|
+
// workerInstance: null, \n
|
146
|
+
// workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
|
147
|
+
// getInstance: ${workerCode} \n
|
148
|
+
// }`
|
149
|
+
// );
|
135
150
|
});
|
136
151
|
}
|
@@ -13,6 +13,10 @@ var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-we
|
|
13
13
|
|
14
14
|
var _common = require("../common");
|
15
15
|
|
16
|
+
var _utils = require("../utils");
|
17
|
+
|
18
|
+
var _CustomScriptLoadingStrategyPlugin = _interopRequireDefault(require("../plugins/CustomScriptLoadingStrategyPlugin"));
|
19
|
+
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
21
|
|
18
22
|
const defaultHTMLMiniFyOption = {
|
@@ -26,6 +30,47 @@ const defaultHTMLMiniFyOption = {
|
|
26
30
|
removeStyleLinkTypeAttributes: true,
|
27
31
|
useShortDoctype: true
|
28
32
|
};
|
33
|
+
const defaultScriptLoadingStrategy = 'defer';
|
34
|
+
const allowedScriptLoadingStrategies = ['blocking', 'defer', 'async', 'module'];
|
35
|
+
|
36
|
+
function isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey) {
|
37
|
+
return allowedScriptLoadingStrategies.includes(scriptLoadingStategey);
|
38
|
+
}
|
39
|
+
|
40
|
+
function getScriptLoadingStrategyForStringType(scriptLoadingStategey) {
|
41
|
+
if (isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey)) {
|
42
|
+
return scriptLoadingStategey;
|
43
|
+
}
|
44
|
+
|
45
|
+
return defaultScriptLoadingStrategy;
|
46
|
+
}
|
47
|
+
|
48
|
+
function getScriptLoadingStrategyForObject(scriptLoadingStategey) {
|
49
|
+
if (Object.keys(scriptLoadingStategey).length === 0) {
|
50
|
+
return defaultScriptLoadingStrategy;
|
51
|
+
}
|
52
|
+
|
53
|
+
const isAllowedScriptLoadingStrategy = Object.keys(scriptLoadingStategey).every(key => isAllowedScriptLoadingStrategyUsed(key));
|
54
|
+
|
55
|
+
if (isAllowedScriptLoadingStrategy) {
|
56
|
+
return Object.assign({}, scriptLoadingStategey);
|
57
|
+
}
|
58
|
+
|
59
|
+
console.warn('un supported script loading strategy used', scriptLoadingStategey);
|
60
|
+
return defaultScriptLoadingStrategy;
|
61
|
+
}
|
62
|
+
|
63
|
+
function getScriptLoadingStrategy(scriptLoadingStategey) {
|
64
|
+
if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'string') {
|
65
|
+
return getScriptLoadingStrategyForStringType(scriptLoadingStategey);
|
66
|
+
}
|
67
|
+
|
68
|
+
if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'object') {
|
69
|
+
return getScriptLoadingStrategyForObject(scriptLoadingStategey);
|
70
|
+
}
|
71
|
+
|
72
|
+
return 'defer';
|
73
|
+
}
|
29
74
|
|
30
75
|
function configHtmlWebpackPlugins(plugins, {
|
31
76
|
enableChunkHash = false,
|
@@ -33,7 +78,8 @@ function configHtmlWebpackPlugins(plugins, {
|
|
33
78
|
inject,
|
34
79
|
crossorigin,
|
35
80
|
hasEFC,
|
36
|
-
minify: minifyHtmlOptions = false
|
81
|
+
minify: minifyHtmlOptions = false,
|
82
|
+
customScriptLoadingStrategey = {}
|
37
83
|
}) {
|
38
84
|
const optionsHtmlWebpack = {
|
39
85
|
chunksSortMode: 'none',
|
@@ -56,4 +102,14 @@ function configHtmlWebpackPlugins(plugins, {
|
|
56
102
|
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
57
103
|
crossorigin: 'anonymous'
|
58
104
|
}));
|
105
|
+
|
106
|
+
if (customScriptLoadingStrategey.enable) {
|
107
|
+
const currentScriptLoadingStrategy = getScriptLoadingStrategy(customScriptLoadingStrategey.options);
|
108
|
+
|
109
|
+
if ((0, _utils.getTypeOf)(currentScriptLoadingStrategy) === 'object') {
|
110
|
+
plugins.push(new _CustomScriptLoadingStrategyPlugin.default({
|
111
|
+
scriptLoadingStategey: currentScriptLoadingStrategy
|
112
|
+
}));
|
113
|
+
}
|
114
|
+
}
|
59
115
|
}
|
@@ -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';
|
@@ -60,7 +62,8 @@ const getDevPlugins = (options, publicPath) => {
|
|
60
62
|
mode
|
61
63
|
},
|
62
64
|
htmlTemplate: {
|
63
|
-
inject
|
65
|
+
inject,
|
66
|
+
customScriptLoadingStrategey
|
64
67
|
},
|
65
68
|
crossorigin
|
66
69
|
},
|
@@ -166,7 +169,8 @@ const getDevPlugins = (options, publicPath) => {
|
|
166
169
|
minify: false,
|
167
170
|
inject,
|
168
171
|
crossorigin,
|
169
|
-
hasEFC
|
172
|
+
hasEFC,
|
173
|
+
customScriptLoadingStrategey
|
170
174
|
});
|
171
175
|
|
172
176
|
if (hasEFC) {
|
@@ -217,12 +221,13 @@ const getDevPlugins = (options, publicPath) => {
|
|
217
221
|
exclude: exclude.selectorWeight,
|
218
222
|
patterns
|
219
223
|
}));
|
220
|
-
}
|
224
|
+
}
|
225
|
+
|
226
|
+
pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin()); // if (pluginObject.minifier) {
|
221
227
|
// // console.log('minifier active');
|
222
228
|
// pluginsArr.push(new MinifierPlugin());
|
223
229
|
// }
|
224
230
|
|
225
|
-
|
226
231
|
return pluginsArr.filter(Boolean);
|
227
232
|
};
|
228
233
|
|
@@ -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");
|
@@ -78,7 +80,8 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
78
80
|
} = options.app;
|
79
81
|
const {
|
80
82
|
inject,
|
81
|
-
minify: minifyHtmlOptions
|
83
|
+
minify: minifyHtmlOptions,
|
84
|
+
customScriptLoadingStrategey
|
82
85
|
} = htmlTemplate;
|
83
86
|
const {
|
84
87
|
i18n
|
@@ -176,6 +179,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
176
179
|
folder,
|
177
180
|
inject,
|
178
181
|
minify: minifyHtmlOptions,
|
182
|
+
customScriptLoadingStrategey,
|
179
183
|
crossorigin,
|
180
184
|
hasEFC
|
181
185
|
});
|
@@ -306,6 +310,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
306
310
|
statsOutputExcludeKeys,
|
307
311
|
statsFileName
|
308
312
|
}));
|
313
|
+
pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin());
|
309
314
|
return pluginsArr;
|
310
315
|
};
|
311
316
|
|