@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2
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/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
- package/lib/babel/cmjs-plugins-presets.js +1 -8
- package/lib/babel/es-plugins-presets.js +1 -8
- package/lib/common/buildEs.js +1 -0
- package/lib/common/getEntries.js +2 -13
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +1 -6
- package/lib/common/runPreProcess.js +6 -15
- package/lib/common/splitChunks.js +2 -21
- package/lib/common/sslcertUpdater.js +7 -18
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +1 -16
- package/lib/configs/jest.config.js +1 -10
- package/lib/configs/libAlias.js +8 -14
- package/lib/configs/resolvers.js +4 -14
- package/lib/configs/webpack.component.umd.config.js +1 -6
- package/lib/configs/webpack.css.umd.config.js +6 -14
- package/lib/configs/webpack.dev.config.js +1 -14
- package/lib/configs/webpack.docs.config.js +1 -9
- package/lib/configs/webpack.impact.config.js +1 -8
- package/lib/configs/webpack.prod.config.js +4 -17
- package/lib/constants.js +9 -18
- package/lib/deprecationLogger.js +0 -7
- package/lib/hooks/docsProptypeHook.js +4 -8
- package/lib/jest/commitedFilesResult.js +4 -46
- package/lib/jest/coverageCollector.js +1 -12
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
- package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
- package/lib/jest/result.js +1 -23
- package/lib/jest/run.js +7 -18
- package/lib/jest/setup.js +8 -60
- package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
- package/lib/loaderUtils/getCSSLoaders.js +10 -22
- package/lib/loaderUtils/getDevJsLoaders.js +4 -13
- package/lib/loaderUtils/index.js +1 -4
- package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
- package/lib/loaderUtils/windowsModification.js +2 -3
- package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
- package/lib/loaders/composeLoader.js +13 -37
- package/lib/loaders/docsLoader.js +1 -12
- package/lib/loaders/docsPropsLoader.js +4 -8
- package/lib/loaders/enhancedReactLiveConverter.js +2 -23
- package/lib/loaders/fileBountryLoader.js +1 -3
- package/lib/loaders/fileLoader.js +12 -23
- package/lib/loaders/markdownLoader.js +14 -19
- package/lib/loaders/reactLiveConvertor.js +5 -15
- package/lib/loaders/scriptInstrumentLoader.js +7 -16
- package/lib/loaders/selectorMappingLoader.js +7 -26
- package/lib/loaders/workerLoader.js +9 -24
- package/lib/logger.js +0 -4
- package/lib/middlewares/HMRMiddleware.js +13 -27
- package/lib/middlewares/SSTMiddleware.js +1 -5
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
- package/lib/pluginUtils/getDevPlugins.js +9 -42
- package/lib/pluginUtils/getDocsPlugins.js +3 -13
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
- package/lib/pluginUtils/getLibraryPlugins.js +2 -8
- package/lib/pluginUtils/getProdPlugins.js +8 -47
- package/lib/pluginUtils/getServerPlugins.js +2 -8
- package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
- package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
- package/lib/pluginUtils/index.js +1 -9
- package/lib/plugins/CdnChangePlugin.js +2 -18
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/CssOrderControlPlugin.js +3 -6
- package/lib/plugins/CustomAttributePlugin.js +14 -19
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
- package/lib/plugins/EFCPlugin.js +20 -34
- package/lib/plugins/EFCTemplatePlugin.js +19 -30
- package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
- package/lib/plugins/EventsHandlingPlugin.js +2 -4
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
- package/lib/plugins/I18nSplitPlugin/index.js +13 -24
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
- package/lib/plugins/ManifestPlugin.js +1 -18
- package/lib/plugins/MinifyPlugin.js +1 -10
- package/lib/plugins/ModuleStatsPlugin.js +1 -24
- package/lib/plugins/OptimizeJSPlugin.js +2 -10
- package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
- package/lib/plugins/PublicPathChangePlugin.js +6 -39
- package/lib/plugins/ReportGeneratePlugin.js +5 -32
- package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
- package/lib/plugins/ResourceHintsPlugin.js +4 -13
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
- package/lib/plugins/SelectorPlugin.js +6 -32
- package/lib/plugins/ServiceWorkerPlugin.js +5 -22
- package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
- package/lib/plugins/SourceMapHookPlugin.js +2 -12
- package/lib/plugins/StatsPlugin.js +0 -14
- package/lib/plugins/TPHashMappingPlugin.js +3 -18
- package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
- package/lib/plugins/VariableConversionCollector.js +15 -42
- package/lib/plugins/index.js +1 -20
- package/lib/plugins/libraryImpactPlugin.js +1 -33
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
- package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
- package/lib/plugins/utils/classHandling.js +0 -6
- package/lib/plugins/utils/fileHandling.js +6 -15
- package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
- package/lib/plugins/variableConvertorUtils.js +14 -29
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/EmptyPlugin.js +3 -4
- package/lib/postcss-plugins/ExcludePlugin.js +1 -5
- package/lib/postcss-plugins/IncludePlugin.js +1 -5
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
- package/lib/postcss-plugins/SelectorReplace.js +1 -16
- package/lib/postcss-plugins/ValueReplacer.js +7 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
- package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
- package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
- package/lib/schemas/index.js +3 -9
- package/lib/servers/clusterHubServer.js +1 -11
- package/lib/servers/devBuild.js +14 -26
- package/lib/servers/docsServer.js +1 -3
- package/lib/servers/docsServerCore.js +1 -22
- package/lib/servers/getCliPath.js +0 -9
- package/lib/servers/helpServer.js +1 -6
- package/lib/servers/httpsOptions.js +2 -8
- package/lib/servers/impactServer.js +3 -35
- package/lib/servers/mockserver.js +1 -10
- package/lib/servers/nowatchserver.js +12 -37
- package/lib/servers/requireLocalOrGlobal.js +6 -17
- package/lib/servers/scrServer.js +14 -21
- package/lib/servers/server.js +6 -36
- package/lib/servers/ssServer.js +1 -17
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +7 -13
- package/lib/templates/linterConstant.js +2 -4
- package/lib/utils/babelPresets.js +3 -7
- package/lib/utils/clean.js +3 -9
- package/lib/utils/copy.js +1 -7
- package/lib/utils/copyTimezones.js +1 -9
- package/lib/utils/createEventStream.js +1 -6
- package/lib/utils/cssClassNameGenerate.js +10 -30
- package/lib/utils/cssURLReplacer.js +1 -22
- package/lib/utils/dependencyPostPublish.js +1 -10
- package/lib/utils/deprecationSupport.js +7 -32
- package/lib/utils/fileUtils.js +1 -28
- package/lib/utils/folderIterator.js +2 -13
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +1 -22
- package/lib/utils/getFileType.js +2 -10
- package/lib/utils/getHash.js +1 -8
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +16 -53
- package/lib/utils/getServerURL.js +1 -10
- package/lib/utils/index.js +4 -51
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +7 -30
- package/lib/utils/jsonHelper.js +3 -22
- package/lib/utils/libraryImpactConfig.js +2 -5
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/log.js +0 -1
- package/lib/utils/mailSender.js +1 -8
- package/lib/utils/object-manipulation.js +1 -17
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +1 -29
- package/lib/utils/removeAttributes.js +1 -8
- package/lib/utils/repoClone.js +3 -28
- package/lib/utils/request.js +0 -12
- package/lib/utils/rtl.js +5 -17
- package/lib/utils/selectorReplacer.js +10 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +1 -11
- package/lib/utils/switchBranch.js +0 -5
- package/lib/utils/typeCheck.js +0 -1
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/lib/utils/variableConverter.js +22 -31
- package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
- package/package.json +1 -1
@@ -1,15 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var esprima = _interopRequireWildcard(require("esprima"));
|
4
|
-
|
5
4
|
var _escodegen = _interopRequireDefault(require("escodegen"));
|
6
|
-
|
7
|
-
function
|
8
|
-
|
9
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
10
|
-
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
12
|
-
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
6
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
7
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
13
8
|
let start = {
|
14
9
|
type: 'ExpressionStatement',
|
15
10
|
expression: {
|
@@ -53,26 +48,21 @@ let start = {
|
|
53
48
|
}]
|
54
49
|
}
|
55
50
|
};
|
56
|
-
|
57
51
|
let scriptInstrumentLoader = function (source) {
|
58
52
|
let parsed = esprima.parseModule(source, {
|
59
53
|
jsx: true
|
60
54
|
});
|
61
|
-
|
62
55
|
for (let i in parsed.body) {
|
63
56
|
if (parsed.body[i].type === 'FunctionDeclaration' || parsed.body[i].type === 'ExportDefaultDeclaration' || parsed.body[i].type === 'ExportNamedDeclaration') {
|
64
57
|
let ParsedTemp;
|
65
|
-
|
66
58
|
if (parsed.body[i].type === 'FunctionDeclaration') {
|
67
59
|
ParsedTemp = parsed.body[i];
|
68
60
|
} else {
|
69
61
|
ParsedTemp = parsed.body[i].declaration;
|
70
62
|
}
|
71
|
-
|
72
63
|
if (ParsedTemp) {
|
73
64
|
if (ParsedTemp.id) {
|
74
65
|
let funcname = ParsedTemp.id.name;
|
75
|
-
|
76
66
|
if (funcname !== 'mapStateToProps') {
|
77
67
|
if (!funcname.includes('_')) {
|
78
68
|
let startFunc = JSON.parse(JSON.stringify(start));
|
@@ -87,8 +77,8 @@ let scriptInstrumentLoader = function (source) {
|
|
87
77
|
}
|
88
78
|
}
|
89
79
|
}
|
90
|
-
|
91
|
-
|
80
|
+
return _escodegen.default.generate(parsed);
|
81
|
+
// function removeDuplicates(arr) {
|
92
82
|
// let uniqueArray = [];
|
93
83
|
// for (let i = 0; i < arr.length; i++) {
|
94
84
|
// if (uniqueArray.indexOf(arr[i]) == -1) {
|
@@ -99,8 +89,9 @@ let scriptInstrumentLoader = function (source) {
|
|
99
89
|
// }
|
100
90
|
// funcArray = removeDuplicates(funcArray);
|
101
91
|
};
|
92
|
+
module.exports = scriptInstrumentLoader;
|
102
93
|
|
103
|
-
|
94
|
+
// let start = {
|
104
95
|
// type: 'ExpressionStatement',
|
105
96
|
// expression: {
|
106
97
|
// type: 'CallExpression',
|
@@ -1,75 +1,56 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
|
-
|
5
4
|
var _fs = _interopRequireDefault(require("fs"));
|
6
|
-
|
7
5
|
var _utils = require("../utils");
|
8
|
-
|
9
6
|
var _logger = require("../logger");
|
10
|
-
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
-
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
8
|
const options = (0, _utils.getOptions)();
|
14
9
|
const {
|
15
10
|
cssSelectorZipPath
|
16
11
|
} = options.impactService;
|
12
|
+
const zipname = _path.default.parse(cssSelectorZipPath).name;
|
17
13
|
|
18
|
-
|
14
|
+
// TODO:NOTE: need to check about .. path related files creation
|
19
15
|
// for now no css files have given form react-cli need to make sure about it.
|
20
16
|
|
21
|
-
|
22
17
|
const zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
|
23
|
-
|
24
18
|
if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
|
25
19
|
_fs.default.rmSync(zippath);
|
20
|
+
(0, _logger.messageLogger)('zip file deleted', zippath);
|
21
|
+
// fs.rmSync(zippath, {force:true})
|
22
|
+
}
|
26
23
|
|
27
|
-
|
28
|
-
} // const minicssComment =
|
24
|
+
// const minicssComment =
|
29
25
|
// '// extracted by mini-css-extract-plugin\n';
|
30
|
-
|
31
|
-
|
32
26
|
const startStr = '// extracted by mini-css-extract-plugin\n' + 'module.exports = ';
|
33
|
-
|
34
27
|
module.exports = function (source) {
|
35
28
|
const {
|
36
29
|
rootContext,
|
37
30
|
resourcePath
|
38
31
|
} = this;
|
39
|
-
|
40
32
|
const relativePath = _path.default.relative(rootContext, resourcePath);
|
41
|
-
|
42
33
|
const fpath = _path.default.join(rootContext, zipname, relativePath);
|
43
|
-
|
44
34
|
const originalpath = _path.default.join(rootContext, relativePath);
|
45
|
-
|
46
35
|
if (relativePath.startsWith('..')) {
|
47
36
|
throw `unexpected path ${relativePath}`;
|
48
37
|
}
|
49
|
-
|
50
38
|
const dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
|
51
|
-
|
52
39
|
if (!_fs.default.existsSync(originalpath)) {
|
53
40
|
throw `originalpath not exixt ${originalpath}`;
|
54
41
|
}
|
55
|
-
|
56
42
|
if (!_fs.default.existsSync(dpath)) {
|
57
43
|
_fs.default.mkdirSync(dpath, {
|
58
44
|
recursive: true
|
59
45
|
});
|
60
46
|
}
|
61
|
-
|
62
47
|
let jsonStr = '{}';
|
63
|
-
|
64
48
|
if (source.startsWith(startStr)) {
|
65
49
|
// source will be like
|
66
50
|
// `// extracted by mini-css-extract-plugin\nmodule.exports = {"app":"zd-app"};`
|
67
51
|
jsonStr = source.slice(startStr.length, -1);
|
68
52
|
}
|
69
|
-
|
70
53
|
_fs.default.writeFileSync(`${fpath}_map`, jsonStr);
|
71
|
-
|
72
54
|
_fs.default.writeFileSync(fpath, _fs.default.readFileSync(originalpath));
|
73
|
-
|
74
55
|
return source;
|
75
56
|
};
|
@@ -5,19 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = loader;
|
7
7
|
exports.pitch = pitch;
|
8
|
-
|
9
8
|
var _path = _interopRequireDefault(require("path"));
|
10
|
-
|
11
9
|
var _loaderUtils = require("loader-utils");
|
12
|
-
|
13
10
|
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
14
|
-
|
15
11
|
var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin"));
|
16
|
-
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
|
-
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
19
13
|
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
20
14
|
import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
|
15
|
+
|
21
16
|
const schema = {
|
22
17
|
type: 'object',
|
23
18
|
properties: {
|
@@ -45,22 +40,18 @@ const schema = {
|
|
45
40
|
}
|
46
41
|
},
|
47
42
|
additionalProperties: false
|
48
|
-
};
|
49
|
-
|
43
|
+
};
|
44
|
+
// eslint-disable-next-line
|
50
45
|
function loader() {}
|
51
|
-
|
52
46
|
function getDefaultFilename(filename) {
|
53
47
|
if (typeof filename === 'function') {
|
54
48
|
return filename;
|
55
49
|
}
|
56
|
-
|
57
50
|
return filename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
|
58
51
|
}
|
59
|
-
|
60
52
|
function getDefaultChunkFilename(chunkFilename) {
|
61
53
|
return chunkFilename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
|
62
54
|
}
|
63
|
-
|
64
55
|
function pitch(request) {
|
65
56
|
this.cacheable(false);
|
66
57
|
const options = (0, _loaderUtils.getOptions)(this);
|
@@ -80,6 +71,7 @@ function pitch(request) {
|
|
80
71
|
globalObject: 'self'
|
81
72
|
};
|
82
73
|
workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
|
74
|
+
|
83
75
|
/*
|
84
76
|
new WebWorkerTemplatePlugin().apply(workerContext.compiler);
|
85
77
|
|
@@ -95,28 +87,22 @@ function pitch(request) {
|
|
95
87
|
const cb = this.async();
|
96
88
|
workerContext.compiler.runAsChild((errorArg, entries, compilation) => {
|
97
89
|
let error = errorArg;
|
98
|
-
|
99
90
|
if (!error && compilation.errors && compilation.errors.length) {
|
100
91
|
// eslint-disable-next-line
|
101
92
|
error = compilation.errors[0];
|
102
93
|
}
|
103
|
-
|
104
94
|
const entry = entries && entries[0] && entries[0].files.values().next().value;
|
105
|
-
|
106
95
|
if (!error && !entry) {
|
107
96
|
error = Error(`WorkerPlugin: no entry for ${request}`);
|
108
97
|
}
|
109
|
-
|
110
98
|
if (error) {
|
111
99
|
return cb(error);
|
112
100
|
}
|
113
|
-
|
114
101
|
function workerCode() {
|
115
102
|
// if (this.workerInstance) {
|
116
103
|
// return this.workerInstance;
|
117
104
|
// }
|
118
105
|
let blob;
|
119
|
-
|
120
106
|
try {
|
121
107
|
blob = new Blob([`importScripts('${this.workerUrl}');`], {
|
122
108
|
type: 'application/javascript'
|
@@ -124,22 +110,21 @@ function pitch(request) {
|
|
124
110
|
} catch (e1) {
|
125
111
|
throw new Error(e1);
|
126
112
|
}
|
127
|
-
|
128
113
|
const url = window.URL || window.webkitURL;
|
129
|
-
const blobUrl = url.createObjectURL(blob);
|
114
|
+
const blobUrl = url.createObjectURL(blob);
|
115
|
+
// this.workerInstance = new Worker(blobUrl);
|
130
116
|
// return this.workerInstance;
|
131
|
-
|
132
117
|
let worker = new Worker(blobUrl);
|
133
118
|
return worker;
|
134
119
|
}
|
135
|
-
|
136
120
|
return cb(null, `const workerObj ={\n
|
137
121
|
workerInstance: null, \n
|
138
122
|
workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
|
139
123
|
getInstance: ${workerCode} \n
|
140
124
|
};\n
|
141
125
|
${options.esModule ? 'export default' : 'module.exports ='} workerObj;
|
142
|
-
`);
|
126
|
+
`);
|
127
|
+
// return cb(
|
143
128
|
// null,
|
144
129
|
// `${options.esModule ? 'export default' : 'module.exports ='} {\n
|
145
130
|
// workerInstance: null, \n
|
package/lib/logger.js
CHANGED
@@ -7,20 +7,16 @@ exports.errorLogger = errorLogger;
|
|
7
7
|
exports.messageLogger = messageLogger;
|
8
8
|
exports.verboseLogger = verboseLogger;
|
9
9
|
exports.warnLogger = warnLogger;
|
10
|
-
|
11
10
|
/* eslint-disable no-console */
|
12
11
|
function messageLogger(...args) {
|
13
12
|
console.log(...args);
|
14
13
|
}
|
15
|
-
|
16
14
|
function errorLogger(...args) {
|
17
15
|
console.error(...args);
|
18
16
|
}
|
19
|
-
|
20
17
|
function warnLogger(...args) {
|
21
18
|
console.warn(...args);
|
22
19
|
}
|
23
|
-
|
24
20
|
function verboseLogger(...args) {
|
25
21
|
// TODO: need to be remove when publish happens
|
26
22
|
process.env.VERBOSE === 'true' && console.log('\x1b[33m [verbose] \x1b[0m', ...args);
|
@@ -4,31 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = HMRMiddleware;
|
7
|
-
|
8
7
|
function pathMatch(url, path) {
|
9
8
|
if (url === path) {
|
10
9
|
return true;
|
11
10
|
}
|
12
|
-
|
13
11
|
let q = url.indexOf('?');
|
14
|
-
|
15
12
|
if (q === -1) {
|
16
13
|
return false;
|
17
14
|
}
|
18
|
-
|
19
15
|
return url.substring(0, q) === path;
|
20
16
|
}
|
21
|
-
|
22
17
|
function createEventStream(heartbeat) {
|
23
18
|
let clientId = 0;
|
24
19
|
let clients = {};
|
25
|
-
|
26
20
|
function everyClient(fn) {
|
27
21
|
Object.keys(clients).forEach(id => {
|
28
22
|
fn(clients[id]);
|
29
23
|
});
|
30
24
|
}
|
31
|
-
|
32
25
|
setInterval(() => {
|
33
26
|
everyClient(client => {
|
34
27
|
client.write(`data: ${JSON.stringify({
|
@@ -59,22 +52,20 @@ function createEventStream(heartbeat) {
|
|
59
52
|
}
|
60
53
|
};
|
61
54
|
}
|
62
|
-
|
63
55
|
function extractBundles(stats) {
|
64
56
|
// Stats has modules, single bundle
|
65
57
|
if (stats.modules) {
|
66
58
|
return [stats];
|
67
|
-
}
|
68
|
-
|
59
|
+
}
|
69
60
|
|
61
|
+
// Stats has children, multiple bundles
|
70
62
|
if (stats.children && stats.children.length) {
|
71
63
|
return stats.children;
|
72
|
-
}
|
73
|
-
|
64
|
+
}
|
74
65
|
|
66
|
+
// Not sure, assume single
|
75
67
|
return [stats];
|
76
68
|
}
|
77
|
-
|
78
69
|
function publishStats(action, statsResult, eventStream, log) {
|
79
70
|
// For multi-compiler, stats will be an object with a 'children' array of stats
|
80
71
|
let bundles = extractBundles(statsResult.toJson({
|
@@ -83,7 +74,8 @@ function publishStats(action, statsResult, eventStream, log) {
|
|
83
74
|
bundles.forEach(stats => {
|
84
75
|
if (log) {
|
85
76
|
log(`webpack built ${stats.name ? `${stats.name} ` : ''}${stats.hash} in ${stats.time}ms`);
|
86
|
-
}
|
77
|
+
}
|
78
|
+
// if (
|
87
79
|
// // !force &&
|
88
80
|
// action !== 'sync' &&
|
89
81
|
// stats &&
|
@@ -95,13 +87,10 @@ function publishStats(action, statsResult, eventStream, log) {
|
|
95
87
|
// type: 'still-ok'
|
96
88
|
// });
|
97
89
|
// }
|
98
|
-
|
99
|
-
|
100
90
|
eventStream.publish({
|
101
91
|
type: 'hash',
|
102
92
|
data: stats.hash
|
103
93
|
});
|
104
|
-
|
105
94
|
if (stats.errors.length > 0) {
|
106
95
|
eventStream.publish({
|
107
96
|
type: 'errors',
|
@@ -119,9 +108,9 @@ function publishStats(action, statsResult, eventStream, log) {
|
|
119
108
|
}
|
120
109
|
});
|
121
110
|
}
|
122
|
-
|
123
111
|
function HMRMiddleware(compiler, opts = {}) {
|
124
|
-
opts.log =
|
112
|
+
opts.log =
|
113
|
+
// eslint-disable-next-line no-console
|
125
114
|
typeof opts.log === 'undefined' ? console.log.bind(console) : opts.log;
|
126
115
|
opts.path = opts.path || '/__webpack_hmr';
|
127
116
|
opts.heartbeat = opts.heartbeat || 10 * 1000;
|
@@ -133,16 +122,13 @@ function HMRMiddleware(compiler, opts = {}) {
|
|
133
122
|
opts.log('webpack compilation starts...');
|
134
123
|
loggedInfo = true;
|
135
124
|
}
|
136
|
-
|
137
125
|
callback && callback();
|
138
126
|
});
|
139
127
|
compiler.hooks.compile.tap('HMRMiddleware', () => {
|
140
128
|
latestStats = null;
|
141
|
-
|
142
129
|
if (opts.log) {
|
143
130
|
opts.log('webpack building...');
|
144
131
|
}
|
145
|
-
|
146
132
|
eventStream.publish({
|
147
133
|
type: 'building'
|
148
134
|
});
|
@@ -152,22 +138,22 @@ function HMRMiddleware(compiler, opts = {}) {
|
|
152
138
|
latestStats = statsResult;
|
153
139
|
publishStats('built', latestStats, eventStream, opts.log);
|
154
140
|
});
|
155
|
-
|
156
141
|
let middleware = function (req, res, next) {
|
157
142
|
if (!pathMatch(req.url, opts.path)) {
|
158
143
|
return next();
|
159
144
|
}
|
160
|
-
|
161
|
-
|
145
|
+
eventStream.handler(req, res);
|
146
|
+
// if (latestStats) {
|
162
147
|
// // Explicitly not passing in `log` fn as we don't want to log again on
|
163
148
|
// // the server
|
164
149
|
// // publishStats('sync', latestStats, eventStream);
|
165
150
|
// }
|
166
151
|
};
|
167
|
-
|
168
152
|
middleware.publish = eventStream.publish;
|
169
153
|
return middleware;
|
170
|
-
}
|
154
|
+
}
|
155
|
+
|
156
|
+
// function buildModuleMap(modules) {
|
171
157
|
// let map = {};
|
172
158
|
// modules.forEach(function(module) {
|
173
159
|
// map[module.id] = module.name;
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _utils = require("../utils");
|
9
|
-
|
10
8
|
function SSTMiddleware(compiler, callback) {
|
11
9
|
compiler.hooks.done.tap('SSTMiddleware', stats => {
|
12
10
|
(0, _utils.log)('Compilation finished!');
|
@@ -16,6 +14,4 @@ function SSTMiddleware(compiler, callback) {
|
|
16
14
|
next();
|
17
15
|
};
|
18
16
|
}
|
19
|
-
|
20
|
-
var _default = SSTMiddleware;
|
21
|
-
exports.default = _default;
|
17
|
+
var _default = exports.default = SSTMiddleware;
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.configHtmlWebpackPlugins = configHtmlWebpackPlugins;
|
7
|
-
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
11
|
-
|
12
9
|
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
13
|
-
|
14
10
|
var _common = require("../common");
|
15
|
-
|
16
11
|
var _utils = require("../utils");
|
17
|
-
|
18
12
|
var _CustomScriptLoadingStrategyPlugin = _interopRequireDefault(require("../plugins/CustomScriptLoadingStrategyPlugin"));
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
22
14
|
const defaultHTMLMiniFyOption = {
|
23
15
|
collapseWhitespace: true,
|
24
16
|
minifyCSS: true,
|
@@ -32,50 +24,39 @@ const defaultHTMLMiniFyOption = {
|
|
32
24
|
};
|
33
25
|
const defaultScriptLoadingStrategy = 'defer';
|
34
26
|
const allowedScriptLoadingStrategies = ['blocking', 'defer', 'async', 'module'];
|
35
|
-
|
36
27
|
function isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey) {
|
37
28
|
return allowedScriptLoadingStrategies.includes(scriptLoadingStategey);
|
38
29
|
}
|
39
|
-
|
40
30
|
function getScriptLoadingStrategyForStringType(scriptLoadingStategey) {
|
41
31
|
if (isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey)) {
|
42
32
|
return scriptLoadingStategey;
|
43
33
|
}
|
44
|
-
|
45
34
|
return defaultScriptLoadingStrategy;
|
46
35
|
}
|
47
|
-
|
48
36
|
function getScriptLoadingStrategyForObject(scriptLoadingStategey) {
|
49
37
|
if (Object.keys(scriptLoadingStategey).length === 0) {
|
50
38
|
return defaultScriptLoadingStrategy;
|
51
39
|
}
|
52
|
-
|
53
40
|
const isAllowedScriptLoadingStrategy = Object.keys(scriptLoadingStategey).every(key => isAllowedScriptLoadingStrategyUsed(key));
|
54
|
-
|
55
41
|
if (isAllowedScriptLoadingStrategy) {
|
56
42
|
return Object.assign({}, scriptLoadingStategey);
|
57
43
|
}
|
58
|
-
|
59
44
|
console.warn('un supported script loading strategy used', scriptLoadingStategey);
|
60
45
|
return defaultScriptLoadingStrategy;
|
61
46
|
}
|
62
|
-
|
63
47
|
function getScriptLoadingStrategy(scriptLoadingStategey) {
|
64
48
|
if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'string') {
|
65
49
|
return {
|
66
50
|
[getScriptLoadingStrategyForStringType(scriptLoadingStategey)]: [/.*/]
|
67
51
|
};
|
68
52
|
}
|
69
|
-
|
70
53
|
if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'object') {
|
71
54
|
return getScriptLoadingStrategyForObject(scriptLoadingStategey);
|
72
55
|
}
|
73
|
-
|
74
56
|
return {
|
75
57
|
[defaultScriptLoadingStrategy]: [/.*/]
|
76
58
|
};
|
77
59
|
}
|
78
|
-
|
79
60
|
function configHtmlWebpackPlugins(plugins, {
|
80
61
|
enableChunkHash = false,
|
81
62
|
folder,
|
@@ -97,19 +78,15 @@ function configHtmlWebpackPlugins(plugins, {
|
|
97
78
|
scriptLoading: defaultScriptLoadingStrategy,
|
98
79
|
inject: inject
|
99
80
|
};
|
100
|
-
|
101
81
|
if (hasEFC) {
|
102
82
|
optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
|
103
83
|
}
|
104
|
-
|
105
84
|
plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
|
106
85
|
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
107
86
|
crossorigin: 'anonymous'
|
108
87
|
}));
|
109
|
-
|
110
88
|
if (customScriptLoadingStrategey.enable) {
|
111
89
|
const currentScriptLoadingStrategy = getScriptLoadingStrategy(customScriptLoadingStrategey.options);
|
112
|
-
|
113
90
|
if ((0, _utils.getTypeOf)(currentScriptLoadingStrategy) === 'object') {
|
114
91
|
plugins.push(new _CustomScriptLoadingStrategyPlugin.default({
|
115
92
|
scriptLoadingStategey: currentScriptLoadingStrategy
|