@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.170
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/.eslintignore +1 -0
- package/.eslintrc.js +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +855 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +98 -84
- package/lib/configs/webpack.docs.config.js +64 -57
- package/lib/configs/webpack.impact.config.js +108 -0
- package/lib/configs/webpack.prod.config.js +146 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +365 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +534 -66
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _utils = require("../utils");
|
9
|
+
|
10
|
+
let {
|
11
|
+
module: {
|
12
|
+
mode
|
13
|
+
}
|
14
|
+
} = (0, _utils.getOptions)();
|
15
|
+
let isProd = mode.toLowerCase() === 'prod';
|
16
|
+
|
17
|
+
var _default = () => ({
|
18
|
+
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
19
|
+
plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
20
|
+
__DOCS__: false
|
21
|
+
} : {}]]
|
22
|
+
});
|
23
|
+
|
24
|
+
exports.default = _default;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _utils = require("../utils");
|
9
|
+
|
10
|
+
let {
|
11
|
+
module: {
|
12
|
+
mode,
|
13
|
+
disableES5Transpile
|
14
|
+
}
|
15
|
+
} = (0, _utils.getOptions)();
|
16
|
+
let isProd = mode.toLowerCase() === 'prod';
|
17
|
+
|
18
|
+
var _default = () => ({
|
19
|
+
presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
|
20
|
+
modules: false,
|
21
|
+
useBuiltIns: 'usage',
|
22
|
+
corejs: 3,
|
23
|
+
targets: {
|
24
|
+
browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
|
25
|
+
}
|
26
|
+
} : {
|
27
|
+
modules: false
|
28
|
+
}], require.resolve('@babel/preset-react')],
|
29
|
+
plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
|
30
|
+
__DOCS__: false
|
31
|
+
} : {}], require.resolve('@babel/plugin-syntax-dynamic-import')]
|
32
|
+
});
|
33
|
+
|
34
|
+
exports.default = _default;
|
package/lib/common/getEntries.js
CHANGED
@@ -1,65 +1,52 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _path = require(
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _utils = require('../utils');
|
10
|
+
var _utils = require("../utils");
|
12
11
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
// mainJs.push(require.resolve('react-dev-utils/webpackHotDevClient'));
|
38
|
-
// mainJs.push(require.resolve('react-error-overlay'));
|
39
|
-
}
|
40
|
-
} else if (mode === 'production') {
|
41
|
-
mainJs.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
|
14
|
+
let getEntries = (appSchemas, mode) => {
|
15
|
+
let appPath = process.cwd();
|
16
|
+
let {
|
17
|
+
isReactMig,
|
18
|
+
hasWidget,
|
19
|
+
server,
|
20
|
+
folder
|
21
|
+
} = appSchemas.app;
|
22
|
+
const {
|
23
|
+
hasEFC: prevOptionForEnableEFC
|
24
|
+
} = appSchemas.app;
|
25
|
+
const {
|
26
|
+
hasEFC: newOptionForEnableEFC
|
27
|
+
} = appSchemas.efc;
|
28
|
+
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
29
|
+
let mainJs = [];
|
30
|
+
let entry = {
|
31
|
+
main: mainJs
|
32
|
+
};
|
33
|
+
|
34
|
+
if (mode === 'dev' || mode === 'dev-no-warn') {
|
35
|
+
mainJs.push(`${_path.default.join(__dirname, '..', 'templates', 'WMSTemplate')}?wmsPath=wss:${(0, _utils.getServerURL)(server)}`);
|
42
36
|
}
|
43
37
|
|
44
|
-
mainJs.push(
|
38
|
+
mainJs.push(_path.default.join(appPath, folder, isReactMig ? 'migration.js' : 'index.js'));
|
45
39
|
|
46
40
|
if (hasWidget) {
|
47
|
-
entry.widget = [];
|
48
|
-
entry.efc = [];
|
49
|
-
if (mode === 'production') {
|
50
|
-
/* no need this one - webpack4 multi entry build system updated*/
|
51
|
-
entry.widget.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
|
52
|
-
}
|
53
|
-
entry.widget.push(_path2.default.join(appPath, folder, 'widget.js'));
|
41
|
+
entry.widget = [_path.default.join(appPath, folder, 'widget.js')];
|
54
42
|
}
|
43
|
+
|
55
44
|
if (hasEFC) {
|
56
|
-
|
57
|
-
/* no need this one - webpack4 multi entry build system updated*/
|
58
|
-
entry.efc.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
|
59
|
-
}
|
60
|
-
entry.efc.push(_path2.default.join(appPath, folder, 'efc.js'));
|
45
|
+
entry.efc = [_path.default.join(appPath, folder, 'efc.js')];
|
61
46
|
}
|
62
47
|
|
63
48
|
return entry;
|
64
49
|
};
|
65
|
-
|
50
|
+
|
51
|
+
var _default = getEntries;
|
52
|
+
exports.default = _default;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _utils = require("../utils");
|
9
|
+
|
10
|
+
let {
|
11
|
+
app: {
|
12
|
+
publicPaths,
|
13
|
+
cdnMapping: {
|
14
|
+
isCdnEnabled,
|
15
|
+
variableName
|
16
|
+
},
|
17
|
+
server: {
|
18
|
+
mode
|
19
|
+
}
|
20
|
+
}
|
21
|
+
} = (0, _utils.getOptions)();
|
22
|
+
let isDevelopment = mode === 'dev' || mode === 'prod' || mode === 'dev-no-warn';
|
23
|
+
|
24
|
+
var _default = url => {
|
25
|
+
let type = (0, _utils.getFileType)(url);
|
26
|
+
|
27
|
+
if (!isDevelopment) {
|
28
|
+
if (publicPaths && publicPaths.callback) {
|
29
|
+
return `${publicPaths.callback}(${JSON.stringify(type)}) + ${JSON.stringify(url)}`;
|
30
|
+
} else if (isCdnEnabled) {
|
31
|
+
return `window["${variableName}"] + ${JSON.stringify(url)}`;
|
32
|
+
} else if (publicPaths) {
|
33
|
+
return `__REACT_CLI_${type.toUpperCase()}_PUBLIC_PATH__ + ${JSON.stringify(url)}`;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
return `__webpack_public_path__ + ${JSON.stringify(url)}`;
|
38
|
+
};
|
39
|
+
|
40
|
+
exports.default = _default;
|
package/lib/common/index.js
CHANGED
@@ -1,34 +1,39 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
|
-
var _splitChunks = require('./splitChunks');
|
8
|
-
|
9
|
-
Object.defineProperty(exports, 'splitChunks', {
|
6
|
+
Object.defineProperty(exports, "getEntries", {
|
10
7
|
enumerable: true,
|
11
|
-
get: function
|
12
|
-
return
|
8
|
+
get: function () {
|
9
|
+
return _getEntries.default;
|
13
10
|
}
|
14
11
|
});
|
15
|
-
|
16
|
-
var _getEntries = require('./getEntries');
|
17
|
-
|
18
|
-
Object.defineProperty(exports, 'getEntries', {
|
12
|
+
Object.defineProperty(exports, "getPublicPathConfig", {
|
19
13
|
enumerable: true,
|
20
|
-
get: function
|
21
|
-
return
|
14
|
+
get: function () {
|
15
|
+
return _getPublicPathConfig.default;
|
22
16
|
}
|
23
17
|
});
|
24
|
-
|
25
|
-
var _getInsertIntoFunction = require('./getInsertIntoFunction');
|
26
|
-
|
27
|
-
Object.defineProperty(exports, 'getInsertIntoFunction', {
|
18
|
+
Object.defineProperty(exports, "splitChunks", {
|
28
19
|
enumerable: true,
|
29
|
-
get: function
|
30
|
-
return
|
20
|
+
get: function () {
|
21
|
+
return _splitChunks.default;
|
31
22
|
}
|
32
23
|
});
|
24
|
+
Object.defineProperty(exports, "templateParameters", {
|
25
|
+
enumerable: true,
|
26
|
+
get: function () {
|
27
|
+
return _templateParameters.default;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
|
31
|
+
var _splitChunks = _interopRequireDefault(require("./splitChunks"));
|
32
|
+
|
33
|
+
var _getEntries = _interopRequireDefault(require("./getEntries"));
|
34
|
+
|
35
|
+
var _getPublicPathConfig = _interopRequireDefault(require("./getPublicPathConfig"));
|
36
|
+
|
37
|
+
var _templateParameters = _interopRequireDefault(require("./templateParameters"));
|
33
38
|
|
34
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -1,41 +1,126 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _path = require(
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _os = _interopRequireDefault(require("os"));
|
11
|
+
|
12
|
+
var _utils = require("../utils");
|
13
|
+
|
14
|
+
var _testPattern = require("./testPattern");
|
10
15
|
|
11
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
17
|
|
13
|
-
|
14
|
-
|
18
|
+
let isWindows = _os.default.platform().toLowerCase() === 'win32';
|
19
|
+
let ps = _path.default.sep;
|
20
|
+
let options = (0, _utils.getOptions)();
|
21
|
+
let {
|
22
|
+
app: {
|
23
|
+
vendorExclude,
|
24
|
+
customChunks,
|
25
|
+
vendorInclude
|
26
|
+
}
|
27
|
+
} = options;
|
15
28
|
|
16
|
-
|
29
|
+
let isVendor = function isVendor(module) {
|
30
|
+
let {
|
31
|
+
userRequest
|
32
|
+
} = module;
|
33
|
+
let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
|
34
|
+
excludeList = [...excludeList, ...vendorExclude];
|
35
|
+
return userRequest && (vendorInclude.some(item => userRequest.indexOf(item) !== -1) || userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && excludeList.every(item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1));
|
17
36
|
};
|
18
37
|
|
19
|
-
|
20
|
-
|
38
|
+
let isReact = module => {
|
39
|
+
let {
|
40
|
+
userRequest
|
41
|
+
} = module;
|
42
|
+
let reactBundle = ['react', 'react-dom'];
|
43
|
+
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
44
|
+
};
|
21
45
|
|
22
|
-
|
46
|
+
let defaultChunks = {
|
47
|
+
'react.vendor': {
|
48
|
+
name: 'react.vendor',
|
49
|
+
chunks: 'all',
|
50
|
+
minChunks: 1,
|
51
|
+
test: isReact,
|
52
|
+
enforce: true,
|
53
|
+
// priority: 10
|
54
|
+
priority: -10
|
55
|
+
},
|
56
|
+
vendor: {
|
57
|
+
name: 'vendor',
|
58
|
+
chunks: 'all',
|
59
|
+
// chunks: 'initial',
|
60
|
+
minChunks: 1,
|
61
|
+
test: isVendor,
|
62
|
+
// priority: 19,
|
63
|
+
priority: -10
|
64
|
+
}
|
23
65
|
};
|
66
|
+
let customChunksConfig = {};
|
67
|
+
customChunks.map((obj, index) => ({
|
68
|
+
name: obj.name,
|
69
|
+
pattern: obj.pattern,
|
70
|
+
minChunks: obj.minChunks || obj.size || 2,
|
71
|
+
rules: obj.rules,
|
72
|
+
// includeDepenency: obj.includeDepenency || false,
|
73
|
+
priority: obj.priority || -10 * (index + 2),
|
74
|
+
enforce: obj.enforce || true,
|
75
|
+
maxSize: obj.maxSize,
|
76
|
+
// || 0,
|
77
|
+
minSize: obj.minSize,
|
78
|
+
// || 20000,
|
79
|
+
chunks: obj.chunks || 'all'
|
80
|
+
})).map(({
|
81
|
+
name,
|
82
|
+
pattern,
|
83
|
+
minChunks,
|
84
|
+
rules,
|
85
|
+
priority,
|
86
|
+
// includeDepenency,
|
87
|
+
enforce,
|
88
|
+
minSize,
|
89
|
+
maxSize,
|
90
|
+
chunks = 'all'
|
91
|
+
}) => {
|
92
|
+
let obj = {
|
93
|
+
name,
|
94
|
+
test: rules ? m => {
|
95
|
+
const {
|
96
|
+
userRequest
|
97
|
+
} = m;
|
98
|
+
return (0, _testPattern.testPattern)(userRequest, rules); // return (
|
99
|
+
// pkgs.some(p => isRelated(userRequest, p)) ||
|
100
|
+
// (includeDepenency && isDependency(m, pkgs))
|
101
|
+
// );
|
102
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
103
|
+
chunks,
|
104
|
+
enforce,
|
105
|
+
minChunks,
|
106
|
+
priority
|
107
|
+
};
|
24
108
|
|
25
|
-
|
26
|
-
|
27
|
-
default: false,
|
28
|
-
'react.vendor': {
|
29
|
-
name: 'react.vendor',
|
30
|
-
chunks: 'all',
|
31
|
-
minChunks: 1,
|
32
|
-
test: isReact
|
33
|
-
},
|
34
|
-
vendor: {
|
35
|
-
name: 'vendor',
|
36
|
-
chunks: 'all',
|
37
|
-
minChunks: 1,
|
38
|
-
test: isVendor
|
39
|
-
}
|
109
|
+
if (minSize !== undefined) {
|
110
|
+
obj.minSize = minSize;
|
40
111
|
}
|
41
|
-
|
112
|
+
|
113
|
+
if (maxSize !== undefined) {
|
114
|
+
obj.maxSize = maxSize;
|
115
|
+
}
|
116
|
+
|
117
|
+
return customChunksConfig[name] = obj;
|
118
|
+
});
|
119
|
+
var _default = {
|
120
|
+
minSize: 12000,
|
121
|
+
cacheGroups: Object.assign({
|
122
|
+
default: false,
|
123
|
+
vendors: false
|
124
|
+
}, defaultChunks, customChunksConfig)
|
125
|
+
};
|
126
|
+
exports.default = _default;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _https = _interopRequireDefault(require("https"));
|
4
|
+
|
5
|
+
var _http = _interopRequireDefault(require("http"));
|
6
|
+
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
8
|
+
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
10
|
+
|
11
|
+
var _getOptions = _interopRequireDefault(require("../utils/getOptions"));
|
12
|
+
|
13
|
+
var _urlConcat = require("../utils/urlConcat");
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
const {
|
18
|
+
sslCertURL
|
19
|
+
} = (0, _getOptions.default)();
|
20
|
+
|
21
|
+
const CRET_FOLDER_PATH = _path.default.join(__dirname, '..', '..', 'cert');
|
22
|
+
|
23
|
+
console.log({
|
24
|
+
CRET_FOLDER_PATH,
|
25
|
+
sslCertURL
|
26
|
+
});
|
27
|
+
const CERT_PATH = 'cert.pem';
|
28
|
+
const KEY_PATH = 'key.pem';
|
29
|
+
const PASSPHRASE_PATH = 'passphrase.pem';
|
30
|
+
|
31
|
+
function updateSSlFile(sslCertURL, filename) {
|
32
|
+
let url = (0, _urlConcat.urlConcat)(sslCertURL, filename);
|
33
|
+
console.log({
|
34
|
+
url
|
35
|
+
});
|
36
|
+
(url.startsWith('https://') ? _https.default : _http.default).get(url, resp => {
|
37
|
+
let fpath = _path.default.join(CRET_FOLDER_PATH, filename);
|
38
|
+
|
39
|
+
let data = ''; // A chunk of data has been received.
|
40
|
+
|
41
|
+
resp.on('data', chunk => {
|
42
|
+
data += chunk;
|
43
|
+
}); // The whole response has been received. Print out the result.
|
44
|
+
|
45
|
+
resp.on('end', () => {
|
46
|
+
_fs.default.writeFileSync(fpath, data);
|
47
|
+
}); // return;
|
48
|
+
}).on('error', err => {
|
49
|
+
console.log(`Error: ${err.message}`);
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
if (!sslCertURL) {
|
54
|
+
throw 'sslCertURL not given';
|
55
|
+
}
|
56
|
+
|
57
|
+
updateSSlFile(sslCertURL, PASSPHRASE_PATH);
|
58
|
+
updateSSlFile(sslCertURL, CERT_PATH);
|
59
|
+
updateSSlFile(sslCertURL, KEY_PATH);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _default = (compilation, assets, assetTags, options) => {
|
9
|
+
Object.keys(assetTags).forEach(rootTag => {
|
10
|
+
assetTags[rootTag].forEach(tag => {
|
11
|
+
tag.attributes.nonce = '{{--CSP-nonce}}';
|
12
|
+
});
|
13
|
+
});
|
14
|
+
return {
|
15
|
+
compilation,
|
16
|
+
webpackConfig: compilation.options,
|
17
|
+
htmlWebpackPlugin: {
|
18
|
+
tags: assetTags,
|
19
|
+
files: assets,
|
20
|
+
options
|
21
|
+
}
|
22
|
+
};
|
23
|
+
};
|
24
|
+
|
25
|
+
exports.default = _default;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isDependency = isDependency;
|
7
|
+
exports.isRelatedPackage = exports.isRelated = void 0;
|
8
|
+
exports.testPattern = testPattern;
|
9
|
+
|
10
|
+
var _path = require("path");
|
11
|
+
|
12
|
+
// in our development we only use windows, mac and linux
|
13
|
+
const isWindows = _path.sep !== '/'; // this function will return true if pattern matched
|
14
|
+
|
15
|
+
function _testPattern(req, pattern) {
|
16
|
+
let modifyedPattern = pattern;
|
17
|
+
|
18
|
+
if (/[*.$^]/.test(modifyedPattern)) {
|
19
|
+
if (isWindows) {
|
20
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
21
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
|
22
|
+
}
|
23
|
+
|
24
|
+
modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
|
25
|
+
const re = new RegExp(modifyedPattern);
|
26
|
+
return re.test(req);
|
27
|
+
}
|
28
|
+
|
29
|
+
if (isWindows) {
|
30
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
31
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\');
|
32
|
+
}
|
33
|
+
|
34
|
+
return req.indexOf(modifyedPattern) !== -1;
|
35
|
+
}
|
36
|
+
|
37
|
+
function testPattern(req, pattern) {
|
38
|
+
if (!req || !pattern) {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (Array.isArray(pattern)) {
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
44
|
+
return pattern.every(p => testPattern(req, p));
|
45
|
+
}
|
46
|
+
|
47
|
+
if (pattern[0] === '!') {
|
48
|
+
return !_testPattern(req, pattern.slice(1));
|
49
|
+
}
|
50
|
+
|
51
|
+
return _testPattern(req, pattern);
|
52
|
+
}
|
53
|
+
|
54
|
+
const isRelated = (req, item) => req && req.indexOf(item) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
55
|
+
|
56
|
+
|
57
|
+
exports.isRelated = isRelated;
|
58
|
+
|
59
|
+
const isRelatedPackage = (req, item) => isRelated(req, `node_modules${_path.sep}${item}${_path.sep}`) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
60
|
+
|
61
|
+
|
62
|
+
exports.isRelatedPackage = isRelatedPackage;
|
63
|
+
|
64
|
+
function isDependency(m, excludeList) {
|
65
|
+
// let reasons = m.reasons.map(r => r.module.userRequest);
|
66
|
+
// m.reasons.some(r => !r.module || !r.module.userRequest) && console.log(m.reasons);
|
67
|
+
return m.reasons.some(r => excludeList.some(item => r.module && isRelated(r.module.userRequest, item)));
|
68
|
+
} // export function queryHandler(conditions, pattern) {
|
69
|
+
// }
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
6
|
+
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
8
|
+
|
9
|
+
var _folderIterator = _interopRequireDefault(require("../utils/folderIterator"));
|
10
|
+
|
11
|
+
var _utils = require("../utils");
|
12
|
+
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
|
15
|
+
const cwd = process.cwd();
|
16
|
+
|
17
|
+
const src = _path.default.join(cwd, process.argv[2]);
|
18
|
+
|
19
|
+
const dist = _path.default.join(cwd, process.argv[3]);
|
20
|
+
|
21
|
+
const docopy = process.argv[4] === 'true';
|
22
|
+
const {
|
23
|
+
css: {
|
24
|
+
valueReplacer
|
25
|
+
}
|
26
|
+
} = (0, _utils.getOptions)();
|
27
|
+
|
28
|
+
if (!_fs.default.existsSync(dist)) {
|
29
|
+
_fs.default.mkdirSync(dist, {
|
30
|
+
recursive: true
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
(0, _folderIterator.default)(src, dist, docopy ? false : ['.css'], false, (fromPath, toPath) => {
|
35
|
+
//console.log({ fromPath: fromPath, toPath: toPath });
|
36
|
+
let css = _fs.default.readFileSync(fromPath);
|
37
|
+
|
38
|
+
if (docopy && !fromPath.endsWith('.css')) {
|
39
|
+
//console.log(toPath,'....');
|
40
|
+
_fs.default.writeFileSync(toPath, css);
|
41
|
+
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
(0, _postcss.default)([valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer)]).process(css, {
|
46
|
+
from: fromPath,
|
47
|
+
to: toPath
|
48
|
+
}).then(result => {
|
49
|
+
_fs.default.writeFile(toPath, result.css, () => true);
|
50
|
+
|
51
|
+
if (result.map) {
|
52
|
+
_fs.default.writeFile(`${toPath}.map`, result.map, () => true);
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|