@zohodesk/client_build_tool 0.0.22-exp.4 → 0.0.22-exp.5
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 +0 -723
- package/README_backup.md +0 -723
- package/app/README.MD +30 -0
- package/app/es/test.js +47 -0
- package/app/package.json +12 -0
- package/lib/schemas/defaultConfigValues.js +3 -6
- package/lib/shared/babel/babelWebConfig.js +2 -1
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
- package/lib/shared/bundler/webpack/entryConfig.js +2 -3
- package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
- package/lib/shared/bundler/webpack/optimizationConfig.js +8 -10
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
- package/package.json +1 -1
- package/es/allCommandsConfigs.js +0 -15
- package/es/commands/build/commandExecutor.js +0 -6
- package/es/commands/build/config.js +0 -5
- package/es/commands/build/optionsProcessor.js +0 -25
- package/es/commands/build/preProcessor.js +0 -4
- package/es/commands/buildEs/commandExecutor.js +0 -29
- package/es/commands/buildEs/config.js +0 -5
- package/es/commands/buildEs/preProcessor.js +0 -9
- package/es/commands/buildLib/commandExecutor.js +0 -24
- package/es/commands/buildLib/config.js +0 -5
- package/es/commands/buildLib/preProcessor.js +0 -9
- package/es/commands/mockserver/commandExecutor.js +0 -32
- package/es/commands/mockserver/config.js +0 -5
- package/es/commands/pre_process/commandExecutor.js +0 -10
- package/es/commands/pre_process/config.js +0 -5
- package/es/commands/start/commandExecutor.js +0 -4
- package/es/commands/start/config.js +0 -5
- package/es/commands/start/optionsProcessor.js +0 -21
- package/es/commands/start/preProcessor.js +0 -4
- package/es/commands/template/commandExecutor.js +0 -17
- package/es/commands/template/config.js +0 -5
- package/es/commands/version/commandExecutor.js +0 -5
- package/es/commands/version/config.js +0 -5
- package/es/commandsRouter.js +0 -58
- package/es/index.js +0 -4
- package/es/logger.js +0 -23
- package/es/schemas/applyValuesToSchema/index.js +0 -25
- package/es/schemas/applyValuesToSchema/isObject.js +0 -3
- package/es/schemas/applyValuesToSchema/isValid.js +0 -7
- package/es/schemas/cliArgsToObject.js +0 -32
- package/es/schemas/defaultConfigValues.js +0 -394
- package/es/schemas/defaultConfigValuesOnly.js +0 -196
- package/es/schemas/deprecatedOptionsHandler.js +0 -60
- package/es/schemas/getNpmVersion.js +0 -13
- package/es/schemas/giveDefaultValue.js +0 -11
- package/es/schemas/npmConfigToObject.js +0 -27
- package/es/schemas/readOptions.js +0 -67
- package/es/schemas/readOptionsForConfigFile.js +0 -28
- package/es/shared/babel/addDefaultPlugins.js +0 -8
- package/es/shared/babel/babelWebConfig.js +0 -43
- package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
- package/es/shared/babel/getBabelPlugin.js +0 -36
- package/es/shared/babel/runBabelForJSFile.js +0 -15
- package/es/shared/babel/runBabelForTsFile.js +0 -34
- package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
- package/es/shared/bundler/webpack/common/libAlias.js +0 -24
- package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
- package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
- package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
- package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
- package/es/shared/bundler/webpack/cssLoaders.js +0 -8
- package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
- package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
- package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
- package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
- package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
- package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
- package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
- package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
- package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
- package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
- package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
- package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
- package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
- package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
- package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
- package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
- package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
- package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
- package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
- package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
- package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
- package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
- package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
- package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
- package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
- package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
- package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
- package/es/shared/bundler/webpack/entryConfig.js +0 -25
- package/es/shared/bundler/webpack/externals.js +0 -10
- package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
- package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
- package/es/shared/bundler/webpack/jsLoaders.js +0 -16
- package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
- package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
- package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
- package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
- package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
- package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
- package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
- package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
- package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
- package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
- package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
- package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
- package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
- package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
- package/es/shared/bundler/webpack/outputConfig.js +0 -35
- package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
- package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
- package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
- package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
- package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
- package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
- package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
- package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
- package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
- package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
- package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
- package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
- package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
- package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
- package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
- package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
- package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
- package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
- package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
- package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
- package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
- package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
- package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
- package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
- package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
- package/es/shared/bundler/webpack/plugins.js +0 -33
- package/es/shared/bundler/webpack/resolvers.js +0 -70
- package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
- package/es/shared/bundler/webpack/statsConfig.js +0 -23
- package/es/shared/bundler/webpack/tsLoaders.js +0 -16
- package/es/shared/bundler/webpack/utils/index.js +0 -8
- package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
- package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
- package/es/shared/bundler/webpack/webpackBuild.js +0 -14
- package/es/shared/bundler/webpack/webpackConfig.js +0 -35
- package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
- package/es/shared/commands-utils/getCliPath.js +0 -28
- package/es/shared/commands-utils/index.js +0 -3
- package/es/shared/commands-utils/log.js +0 -4
- package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
- package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
- package/es/shared/commands-utils/spawnSyncIO.js +0 -24
- package/es/shared/constants.js +0 -22
- package/es/shared/fileUtils/copyFile.js +0 -23
- package/es/shared/fileUtils/directoryIterator.js +0 -12
- package/es/shared/fileUtils/watchRun.js +0 -96
- package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
- package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
- package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
- package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
- package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
- package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
- package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
- package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
- package/es/shared/postcss/runPostCssForCssFile.js +0 -25
- package/es/shared/pre_process/runPreProcess.js +0 -47
- package/es/shared/server/configWebpackDevMiddleware.js +0 -26
- package/es/shared/server/corsHandling.js +0 -23
- package/es/shared/server/getIp.js +0 -18
- package/es/shared/server/getServerURL.js +0 -28
- package/es/shared/server/httpsOptions.js +0 -36
- package/es/shared/server/initExpressApp.js +0 -9
- package/es/shared/server/initialHTMLHandling.js +0 -92
- package/es/shared/server/mockApiHandler.js +0 -53
- package/es/shared/server/mockServer.js +0 -34
- package/es/shared/server/serveContextFiles.js +0 -17
- package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
- package/es/shared/server/startHttpServer.js +0 -18
- package/es/shared/server/startHttpsServer.js +0 -26
- package/es/shared/server/unwanted/addHttp2Server.js +0 -32
- package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
- package/es/shared/server/unwanted/mockApiSupport.js +0 -11
- package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
- package/es/shared/server/urlConcat.js +0 -35
- package/es/shared/utils/requireLocalOrGlobal.js +0 -57
- package/es/shared/utils/utils.js +0 -0
- package/es/shared/utils/versionPrint.js +0 -9
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-use-before-define */
|
|
2
|
-
import { nodeModulesPath as defaultNodeModulesPath } from '@zohodesk/client_packages_group';
|
|
3
|
-
import { cliNodeModulesPath, appNodeModules } from "../../constants";
|
|
4
|
-
import { libAlias } from "./common/libAlias";
|
|
5
|
-
import { requireAllPossible, requireGlobal } from "../../utils/requireLocalOrGlobal";
|
|
6
|
-
import { errorLogger, messageLogger, verboseLogger } from "../../../logger";
|
|
7
|
-
const defaultPackageGroupNpm = '@zohodesk/client_packages_group';
|
|
8
|
-
|
|
9
|
-
function decideNodeModulesPath(moduleResolvePath) {
|
|
10
|
-
if (typeof moduleResolvePath === 'string' && moduleResolvePath) {
|
|
11
|
-
const resolverPkg = requireAllPossible(moduleResolvePath);
|
|
12
|
-
|
|
13
|
-
if (resolverPkg.local) {
|
|
14
|
-
verboseLogger(`Local '${moduleResolvePath}' package taken as Module Resolver`);
|
|
15
|
-
return resolverPkg.local.nodeModulesPath;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (resolverPkg.global) {
|
|
19
|
-
messageLogger(`Global '${moduleResolvePath}' package taken as Module Resolver`);
|
|
20
|
-
return resolverPkg.global.nodeModulesPath;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
errorLogger(`
|
|
24
|
-
You have given 'resolve.moduleResolvePath' as "${moduleResolvePath}".
|
|
25
|
-
But it seems that file path have some problem;`);
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const globalResolverPkg = requireGlobal(defaultPackageGroupNpm);
|
|
30
|
-
|
|
31
|
-
if (globalResolverPkg) {
|
|
32
|
-
messageLogger(`Global '${defaultPackageGroupNpm}' package taken as Module Resolver`);
|
|
33
|
-
return globalResolverPkg.nodeModulesPath;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
verboseLogger(`CBT default '${defaultPackageGroupNpm}' package taken as Module Resolver`);
|
|
37
|
-
return defaultNodeModulesPath;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function moduleResolver(options) {
|
|
41
|
-
const {
|
|
42
|
-
preferLocalFirst,
|
|
43
|
-
alias,
|
|
44
|
-
defaultAlias,
|
|
45
|
-
moduleResolvePath
|
|
46
|
-
} = options.resolve;
|
|
47
|
-
const nodeModulesPath = decideNodeModulesPath(moduleResolvePath);
|
|
48
|
-
return {
|
|
49
|
-
modules: useAppNodeModulesAsPreferred(preferLocalFirst, [nodeModulesPath, cliNodeModulesPath].filter(Boolean)),
|
|
50
|
-
alias: { ...(defaultAlias ? libAlias : {}),
|
|
51
|
-
...(alias || {})
|
|
52
|
-
},
|
|
53
|
-
extensions: ['.ts', '.js', '.json', '.tsx']
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function loaderResolver(options) {
|
|
57
|
-
const {
|
|
58
|
-
preferLocalFirst
|
|
59
|
-
} = options.resolve;
|
|
60
|
-
return {
|
|
61
|
-
modules: useAppNodeModulesAsPreferred(preferLocalFirst, [cliNodeModulesPath])
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function useAppNodeModulesAsPreferred() {
|
|
66
|
-
let preferLocalFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
67
|
-
let paths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
68
|
-
const filteredPaths = paths.filter(Boolean);
|
|
69
|
-
return preferLocalFirst ? ['node_modules', ...filteredPaths, appNodeModules] : [...filteredPaths, 'node_modules', appNodeModules];
|
|
70
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { defaultVendorPatternList, reactBundleIncludeList } from "./defaultVendorPatternList";
|
|
2
|
-
import { getFilenameFromModule } from "./getFilenameFromModule";
|
|
3
|
-
import { checkIsPatternsMatchFilename } from "./loaderConfigs/checkIsPatternsMatchFilename";
|
|
4
|
-
export function splitChunksConfig(options) {
|
|
5
|
-
const {
|
|
6
|
-
vendorPatterns,
|
|
7
|
-
customChunks,
|
|
8
|
-
customChunksBaseConfig
|
|
9
|
-
} = options;
|
|
10
|
-
|
|
11
|
-
const isVendor = function isVendor(webpackModule) {
|
|
12
|
-
const userRequest = getFilenameFromModule(webpackModule);
|
|
13
|
-
const patterns = [...defaultVendorPatternList, ...vendorPatterns];
|
|
14
|
-
return checkIsPatternsMatchFilename(patterns, userRequest);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const isReact = webpackModule => {
|
|
18
|
-
const userRequest = getFilenameFromModule(webpackModule);
|
|
19
|
-
return checkIsPatternsMatchFilename(reactBundleIncludeList, userRequest);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const defaultChunks = {
|
|
23
|
-
'react.vendor': {
|
|
24
|
-
name: 'react.vendor',
|
|
25
|
-
chunks: 'all',
|
|
26
|
-
minChunks: 1,
|
|
27
|
-
test: isReact,
|
|
28
|
-
enforce: true,
|
|
29
|
-
priority: 30
|
|
30
|
-
},
|
|
31
|
-
vendor: {
|
|
32
|
-
name: 'vendor',
|
|
33
|
-
chunks: 'all',
|
|
34
|
-
minChunks: 1,
|
|
35
|
-
test: isVendor,
|
|
36
|
-
priority: 20
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const customChunksConfig = {};
|
|
40
|
-
customChunks.reverse().forEach((cacheGroupObj, index) => {
|
|
41
|
-
const cacheGroupName = cacheGroupObj.cacheGroupName || cacheGroupObj.name; // eslint-disable-next-line no-use-before-define
|
|
42
|
-
|
|
43
|
-
const obj = getCacheGroup(cacheGroupObj, index);
|
|
44
|
-
customChunksConfig[cacheGroupName] = obj;
|
|
45
|
-
});
|
|
46
|
-
const splitChunksConfig = {
|
|
47
|
-
minSize: 12000,
|
|
48
|
-
...(customChunksBaseConfig || {}),
|
|
49
|
-
cacheGroups: {
|
|
50
|
-
default: false,
|
|
51
|
-
defaultVendors: false,
|
|
52
|
-
...defaultChunks,
|
|
53
|
-
...customChunksConfig
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return splitChunksConfig;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getCacheGroup(obj, index) {
|
|
60
|
-
let {
|
|
61
|
-
minChunks,
|
|
62
|
-
priority,
|
|
63
|
-
chunks = 'all'
|
|
64
|
-
} = obj;
|
|
65
|
-
const {
|
|
66
|
-
name,
|
|
67
|
-
patterns,
|
|
68
|
-
enforce,
|
|
69
|
-
minSize,
|
|
70
|
-
maxSize,
|
|
71
|
-
reuseExistingChunk,
|
|
72
|
-
automaticNameDelimiter
|
|
73
|
-
} = obj;
|
|
74
|
-
chunks = obj.chunks || 'all';
|
|
75
|
-
minChunks = obj.minChunks || 2;
|
|
76
|
-
priority = obj.priority || 10 * (index + 2);
|
|
77
|
-
const cacheGroup = {
|
|
78
|
-
name,
|
|
79
|
-
test: m => {
|
|
80
|
-
const userRequest = getFilenameFromModule(m);
|
|
81
|
-
return userRequest && checkIsPatternsMatchFilename(patterns, userRequest);
|
|
82
|
-
},
|
|
83
|
-
chunks,
|
|
84
|
-
minChunks,
|
|
85
|
-
priority,
|
|
86
|
-
enforce
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
if (minSize !== undefined) {
|
|
90
|
-
cacheGroup.minSize = minSize;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (maxSize !== undefined) {
|
|
94
|
-
cacheGroup.maxSize = maxSize;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (reuseExistingChunk !== undefined) {
|
|
98
|
-
cacheGroup.reuseExistingChunk = reuseExistingChunk;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (automaticNameDelimiter !== undefined) {
|
|
102
|
-
cacheGroup.automaticNameDelimiter = automaticNameDelimiter;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return cacheGroup;
|
|
106
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
export function statsConfig(options) {
|
|
3
|
-
let {
|
|
4
|
-
statsLogConfig
|
|
5
|
-
} = options;
|
|
6
|
-
statsLogConfig = statsLogConfig || {};
|
|
7
|
-
|
|
8
|
-
if (typeof statsLogConfig === 'string') {
|
|
9
|
-
return statsLogConfig;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
preset: 'minimal',
|
|
14
|
-
warnings: false,
|
|
15
|
-
children: false,
|
|
16
|
-
colors: true,
|
|
17
|
-
errorDetails: true,
|
|
18
|
-
...statsLogConfig // excludeAssets: /i18n/,
|
|
19
|
-
// excludeAssets: /./,
|
|
20
|
-
// warningsFilter: /\[mini-css-extract-plugin\]/
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { babelLoaderConfig } from "./loaderConfigs/babelLoaderConfig";
|
|
2
|
-
import { i18nIdReplaceLoaderConfig } from "./loaderConfigs/i18nIdReplaceLoaderConfig";
|
|
3
|
-
export function tsLoaders(options) {
|
|
4
|
-
const useLoaders = ['ts-loader'];
|
|
5
|
-
const shouldUseNumericIndexing = options.i18nIndexing.enable;
|
|
6
|
-
|
|
7
|
-
if (shouldUseNumericIndexing) {
|
|
8
|
-
useLoaders.push(i18nIdReplaceLoaderConfig(options));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return [{
|
|
12
|
-
test: /\.tsx?$/,
|
|
13
|
-
exclude: /node_modules/,
|
|
14
|
-
use: useLoaders
|
|
15
|
-
}];
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const isCss = filename => path.extname(filename) === '.css';
|
|
3
|
-
export const isDirRelatedCss = filename => filename.includes('[dir]');
|
|
4
|
-
export const isJsFile = file => /\.js$/.test(file);
|
|
5
|
-
export const isCssFile = file => /\.css$/.test(file);
|
|
6
|
-
export function getTypeOf(value) {
|
|
7
|
-
return Object.prototype.toString.call(value).split(/\s/)[1].replace(/\]/, '').toLowerCase();
|
|
8
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-syntax */
|
|
2
|
-
function objectPathMatcher(currentKey) {
|
|
3
|
-
let objHierarchy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
4
|
-
let keysToBeRemoved = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
5
|
-
const objPathKey = objHierarchy.length > 0 ? `${objHierarchy.join('.')}.${currentKey}` : currentKey;
|
|
6
|
-
return keysToBeRemoved.some(key => {
|
|
7
|
-
const isWildPath = /^\*/.test(key);
|
|
8
|
-
|
|
9
|
-
if (isWildPath) {
|
|
10
|
-
const newKey = key.replace(/\*\.?/, '');
|
|
11
|
-
return objPathKey.includes(newKey);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return key === objPathKey;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/*
|
|
18
|
-
1) *.keyTobeRemoved -> means match every object path, this key will be removed
|
|
19
|
-
2) keyToBeremoved -> means root object key
|
|
20
|
-
3) nestedPath.keyToBeRemoved -> means only that nested path key
|
|
21
|
-
4) don't need to account for array iteration, just object key path is enough in the key to be removed.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export function removeKeysFromObject(obj, keysToBeRemoved) {
|
|
26
|
-
let prevKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
27
|
-
|
|
28
|
-
if (Array.isArray(obj)) {
|
|
29
|
-
return obj.map(item => removeKeysFromObject(item, keysToBeRemoved, prevKeys));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (obj && typeof obj === 'object') {
|
|
33
|
-
const filteredKeyObject = {};
|
|
34
|
-
const ObjectKeys = Object.keys(obj);
|
|
35
|
-
|
|
36
|
-
for (const objectKey of ObjectKeys) {
|
|
37
|
-
const isKeyToBeRemoved = objectPathMatcher(objectKey, prevKeys, keysToBeRemoved);
|
|
38
|
-
|
|
39
|
-
if (!isKeyToBeRemoved) {
|
|
40
|
-
filteredKeyObject[objectKey] = removeKeysFromObject(obj[objectKey], keysToBeRemoved, [...prevKeys, objectKey]);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return filteredKeyObject;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return obj;
|
|
48
|
-
}
|
|
49
|
-
export function* convertObjectToStringGen(obj) {
|
|
50
|
-
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
|
|
51
|
-
yield JSON.stringify(obj);
|
|
52
|
-
} else if (Array.isArray(obj)) {
|
|
53
|
-
yield '[';
|
|
54
|
-
let isFirst = true;
|
|
55
|
-
|
|
56
|
-
for (let item of obj) {
|
|
57
|
-
if (item === undefined) {
|
|
58
|
-
item = null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
yield `${isFirst ? '' : ','}`;
|
|
62
|
-
yield* convertObjectToStringGen(item);
|
|
63
|
-
isFirst = false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
yield ']';
|
|
67
|
-
} else {
|
|
68
|
-
yield '{';
|
|
69
|
-
let isFirst = true;
|
|
70
|
-
const entries = Object.entries(obj);
|
|
71
|
-
|
|
72
|
-
for (const [itemKey, itemValue] of entries) {
|
|
73
|
-
if (itemValue !== undefined) {
|
|
74
|
-
yield `${isFirst ? '' : ','}${JSON.stringify(itemKey)}: `;
|
|
75
|
-
yield* convertObjectToStringGen(itemValue);
|
|
76
|
-
isFirst = false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
yield '}';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export function updateArrayWithDefault(array) {
|
|
2
|
-
let defaultoptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
3
|
-
const index = array.indexOf('...');
|
|
4
|
-
|
|
5
|
-
if (index === -1) {
|
|
6
|
-
return array;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const newArray = [...array];
|
|
10
|
-
newArray.splice(index, 1, ...defaultoptions);
|
|
11
|
-
return newArray;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const isEqualVal = (a, b) => a === b;
|
|
15
|
-
|
|
16
|
-
export function getArrayWithDefault(array) {
|
|
17
|
-
let defaultoptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
18
|
-
let isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isEqualVal;
|
|
19
|
-
const index = array.indexOf('...');
|
|
20
|
-
|
|
21
|
-
if (index === -1) {
|
|
22
|
-
return array;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const filteredDefaultOptions = defaultoptions.filter(v => !array.some(v1 => isEqual(v, v1)));
|
|
26
|
-
const newArray = [...array];
|
|
27
|
-
newArray.splice(index, 1, ...filteredDefaultOptions);
|
|
28
|
-
return newArray;
|
|
29
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { webpack } from 'webpack';
|
|
2
|
-
import { statsConfig } from "./statsConfig";
|
|
3
|
-
import webpackConfigCreator from "./webpackConfig";
|
|
4
|
-
import { errorLogger, messageLogger } from "../../../logger";
|
|
5
|
-
export default function webpackBuild(options) {
|
|
6
|
-
const config = webpackConfigCreator(options);
|
|
7
|
-
webpack(config, (err, stats) => {
|
|
8
|
-
if (err || stats.hasErrors()) {
|
|
9
|
-
errorLogger('err', err);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
messageLogger(stats.toString(statsConfig(options)));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { entryConfig } from "./entryConfig";
|
|
2
|
-
import { outputConfig } from "./outputConfig";
|
|
3
|
-
import { jsLoaders } from "./jsLoaders";
|
|
4
|
-
import { tsLoaders } from "./tsLoaders";
|
|
5
|
-
import { cssLoaders } from "./cssLoaders";
|
|
6
|
-
import { assetLoaders } from "./loaderConfigs/assetLoaders";
|
|
7
|
-
import { plugins } from "./plugins";
|
|
8
|
-
import { loaderResolver, moduleResolver } from "./resolvers";
|
|
9
|
-
import { optimizationConfig } from "./optimizationConfig";
|
|
10
|
-
import { configHtmlTemplateLoader } from "./loaderConfigs/configHtmlTemplateLoader";
|
|
11
|
-
import { configWebWorkerLoader } from "./loaderConfigs/configWebWorkerLoader";
|
|
12
|
-
import { statsConfig } from "./statsConfig";
|
|
13
|
-
import { devtoolConfig } from "./devtoolConfig";
|
|
14
|
-
import { getWebpackMode } from "./common/modeUtils";
|
|
15
|
-
import { externals } from "./externals";
|
|
16
|
-
import { configCustomLoaders } from "./configCustomLoaders";
|
|
17
|
-
export default function webpackConfigCreator(options) {
|
|
18
|
-
return {
|
|
19
|
-
entry: entryConfig(options),
|
|
20
|
-
mode: getWebpackMode(options),
|
|
21
|
-
output: outputConfig(options),
|
|
22
|
-
devtool: devtoolConfig(options),
|
|
23
|
-
stats: statsConfig(options),
|
|
24
|
-
optimization: optimizationConfig(options),
|
|
25
|
-
module: {
|
|
26
|
-
/* strictExportPresence for break the build when imported module not present in respective file */
|
|
27
|
-
// strictExportPresence: true,
|
|
28
|
-
rules: [...jsLoaders(options), ...tsLoaders(options), ...cssLoaders(options), configWebWorkerLoader(options), configHtmlTemplateLoader(options), ...assetLoaders(options), ...configCustomLoaders(options)]
|
|
29
|
-
},
|
|
30
|
-
plugins: plugins(options),
|
|
31
|
-
externals: externals(options),
|
|
32
|
-
resolve: moduleResolver(options),
|
|
33
|
-
resolveLoader: loaderResolver(options)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-throw-literal */
|
|
2
|
-
export function doBasicRequirementCheck() {
|
|
3
|
-
const majorV = Number(process.version.slice(1, 4));
|
|
4
|
-
|
|
5
|
-
if (majorV >= 14 && majorV <= 18) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
throw `your node version not compatible with this cli please update node version to 14 - 18, and your current version is ${process.version}`;
|
|
10
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { platform } from 'os';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { cliNodeModulesPath } from "../constants";
|
|
5
|
-
const isWindows = platform().toLowerCase() === 'win32';
|
|
6
|
-
const suffixExt = isWindows ? '.cmd' : ''; // function searchForCommandPath(commandName) {
|
|
7
|
-
// let pathFolders = __dirname.split(sep);
|
|
8
|
-
// let cliPath;
|
|
9
|
-
// while (pathFolders.pop()) {
|
|
10
|
-
// cliPath = join(pathFolders.join(sep), 'node_modules', '.bin', commandName);
|
|
11
|
-
// if (existsSync(cliPath)) {
|
|
12
|
-
// return cliPath;
|
|
13
|
-
// }
|
|
14
|
-
// }
|
|
15
|
-
// console.warn(`unable to find command "${commandName}"`);
|
|
16
|
-
// return join(__dirname, '..', 'node_modules', '.bin', commandName);
|
|
17
|
-
// }
|
|
18
|
-
|
|
19
|
-
function searchForCommandPath(libName) {
|
|
20
|
-
const commandPath = join(cliNodeModulesPath, '.bin', libName); // TODO: need to check for windows machine reason command with ext added,
|
|
21
|
-
// when we use global react-cli package (executable) working or not
|
|
22
|
-
|
|
23
|
-
return existsSync(commandPath) ? commandPath : libName;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getCliPath(commandName) {
|
|
27
|
-
return searchForCommandPath(commandName + suffixExt);
|
|
28
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { spawnSync, spawn } from 'child_process';
|
|
2
|
-
import { errorLogger } from "../../logger";
|
|
3
|
-
import { getCliPath } from "./getCliPath";
|
|
4
|
-
export const defaultSpawnSyncOptions = {
|
|
5
|
-
stdio: 'inherit'
|
|
6
|
-
};
|
|
7
|
-
export function spawnSyncIO(commandName, args) {
|
|
8
|
-
let spawnSyncOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultSpawnSyncOptions;
|
|
9
|
-
const command = getCliPath(commandName);
|
|
10
|
-
const result = spawnSync(command, args, spawnSyncOptions);
|
|
11
|
-
|
|
12
|
-
if (result.error || result.stderr) {
|
|
13
|
-
errorLogger(result.error || result.stderr);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
export function spawnIO(commandName, args, cb) {
|
|
19
|
-
const command = getCliPath(commandName); // const result =
|
|
20
|
-
|
|
21
|
-
return spawn(command, args, {
|
|
22
|
-
stdio: 'inherit'
|
|
23
|
-
}, cb); // process.exit(result.status);
|
|
24
|
-
}
|
package/es/shared/constants.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import path, { join } from 'path';
|
|
2
|
-
export const BASE_CONFIG_KEY = 'react-cli';
|
|
3
|
-
export const cliRootPath = path.resolve(__dirname, '..', '..');
|
|
4
|
-
export const CONFIG_ROOT = 'client-build-config';
|
|
5
|
-
export const cliNodeModulesPath = path.resolve(cliRootPath, 'node_modules');
|
|
6
|
-
export const babelrcPath = join(cliRootPath, '.babelrc');
|
|
7
|
-
export const appPath = process.cwd();
|
|
8
|
-
export function joinWithAppPath(filePath) {
|
|
9
|
-
// TODO: test in windows
|
|
10
|
-
return join(appPath, filePath);
|
|
11
|
-
}
|
|
12
|
-
;
|
|
13
|
-
export const appNodeModules = joinWithAppPath('node_modules');
|
|
14
|
-
export const templatesPath = join(__dirname, '..', '..', 'templates');
|
|
15
|
-
export function getTemplatePath() {
|
|
16
|
-
for (var _len = arguments.length, filePath = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
-
filePath[_key] = arguments[_key];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// TODO: test in windows
|
|
21
|
-
return join(templatesPath, ...filePath);
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createReadStream, createWriteStream, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
export function createParentDir(filename) {
|
|
4
|
-
const {
|
|
5
|
-
dir
|
|
6
|
-
} = path.parse(filename);
|
|
7
|
-
|
|
8
|
-
if (!existsSync(dir)) {
|
|
9
|
-
mkdirSync(dir, {
|
|
10
|
-
recursive: true
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function copyFile(filename, outputFile) {
|
|
15
|
-
createParentDir(outputFile);
|
|
16
|
-
const readStream = createReadStream(filename);
|
|
17
|
-
const writeStream = createWriteStream(outputFile);
|
|
18
|
-
return readStream.pipe(writeStream);
|
|
19
|
-
}
|
|
20
|
-
export function writeFile(filename, data) {
|
|
21
|
-
createParentDir(filename);
|
|
22
|
-
return writeFileSync(filename, data);
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { readdirSync, statSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
export function directoryIterator(filename, callback) {
|
|
4
|
-
if (!statSync(filename).isDirectory()) {
|
|
5
|
-
callback(filename);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
readdirSync(filename).forEach(fileOrDir => {
|
|
10
|
-
directoryIterator(join(filename, fileOrDir), callback);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import Watcher from 'watcher';
|
|
3
|
-
import { runBabelForJSFile } from "../babel/runBabelForJSFile";
|
|
4
|
-
import { runBabelForTSFile } from "../babel/runBabelForTsFile";
|
|
5
|
-
import { runPostCssForCssFile } from "../postcss/runPostCssForCssFile";
|
|
6
|
-
import { directoryIterator } from "./directoryIterator";
|
|
7
|
-
import { copyFile } from "./copyFile";
|
|
8
|
-
import { messageLogger } from "../../logger";
|
|
9
|
-
|
|
10
|
-
const isJs = ext => ext === '.js';
|
|
11
|
-
|
|
12
|
-
const isTs = ext => ext === '.ts' || ext === '.tsx';
|
|
13
|
-
|
|
14
|
-
const isCss = ext => ext === '.css';
|
|
15
|
-
|
|
16
|
-
export function watchRun(_ref) {
|
|
17
|
-
let {
|
|
18
|
-
options,
|
|
19
|
-
src,
|
|
20
|
-
target,
|
|
21
|
-
canWatch,
|
|
22
|
-
mode
|
|
23
|
-
} = _ref;
|
|
24
|
-
let updatedFileCount = 0;
|
|
25
|
-
|
|
26
|
-
function doWorkForSeparateFile(filename) {
|
|
27
|
-
const outputFile = filename.replace(src, target);
|
|
28
|
-
const {
|
|
29
|
-
ext
|
|
30
|
-
} = path.parse(filename);
|
|
31
|
-
|
|
32
|
-
if (isJs(ext)) {
|
|
33
|
-
runBabelForJSFile({
|
|
34
|
-
filename,
|
|
35
|
-
outputFile,
|
|
36
|
-
options,
|
|
37
|
-
mode
|
|
38
|
-
});
|
|
39
|
-
} else if (isCss(ext)) {
|
|
40
|
-
runPostCssForCssFile({
|
|
41
|
-
filename,
|
|
42
|
-
outputFile,
|
|
43
|
-
options
|
|
44
|
-
});
|
|
45
|
-
} else if (isTs(ext)) {
|
|
46
|
-
runBabelForTSFile({
|
|
47
|
-
filename,
|
|
48
|
-
outputFile,
|
|
49
|
-
options,
|
|
50
|
-
mode
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
copyFile(filename, outputFile);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
updatedFileCount++;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function doWork(foldername) {
|
|
60
|
-
updatedFileCount = 0;
|
|
61
|
-
const startTime = Date.now();
|
|
62
|
-
directoryIterator(foldername, filename => {
|
|
63
|
-
try {
|
|
64
|
-
doWorkForSeparateFile(filename);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
messageLogger(`ERROR In: ${filename}`);
|
|
67
|
-
messageLogger(error);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
messageLogger(`Successfully compiled ${updatedFileCount} files with Babel and Post-CSS (${Date.now() - startTime}ms).`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
doWork(src);
|
|
74
|
-
|
|
75
|
-
if (canWatch) {
|
|
76
|
-
const watcher = new Watcher(src, {
|
|
77
|
-
recursive: true,
|
|
78
|
-
ignoreInitial: true,
|
|
79
|
-
ignore: filename => filename.indexOf('__tests__') !== -1 // remove the test cases
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
watcher.on('all', (event, filename) => {
|
|
83
|
-
if (event === 'unlink' || event === 'unlinkDir') {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
doWork(filename); // This is what the library does internally when you pass it a handler directly
|
|
88
|
-
// arguments [0] (event); // => could be any target event: 'add', 'addDir', 'change', 'rename', 'renameDir', 'unlink' or 'unlinkDir'
|
|
89
|
-
// arguments [1] (filename); // => the file system path where the event took place, this is always provided
|
|
90
|
-
// arguments [2] (targetPathNext); // => the file system path "targetPath" got renamed to, this is only provided on 'rename'/'renameDir' events
|
|
91
|
-
});
|
|
92
|
-
watcher.on('error', error => {
|
|
93
|
-
messageLogger(error); // => true, "Error" instances are always provided on "error"
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
const EmptyPlugin = function () {
|
|
3
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4
|
-
return {
|
|
5
|
-
postcssPlugin: 'postcss-empty',
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
Once(root, _ref) {
|
|
9
|
-
let {
|
|
10
|
-
result
|
|
11
|
-
} = _ref;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
EmptyPlugin.postcss = true;
|
|
18
|
-
export default EmptyPlugin;
|