@zohodesk/client_build_tool 0.0.6-exp.4 → 0.0.6-exp.6

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.
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.commandExecutor = commandExecutor;
7
7
 
8
+ var _constants = require("../../shared/constants");
9
+
8
10
  var _watchRun = require("../../shared/fileUtils/watchRun");
9
11
 
10
12
  function commandExecutor(options) {
@@ -18,10 +20,13 @@ function commandExecutor(options) {
18
20
  extraArgs.splice(index, 1);
19
21
  }
20
22
 
23
+ let [src, target] = extraArgs;
24
+ src = (0, _constants.joinWithAppPath)(src || 'src');
25
+ target = (0, _constants.joinWithAppPath)(target || 'es');
21
26
  (0, _watchRun.watchRun)({
22
27
  options,
23
- src: 'src',
24
- target: 'es',
28
+ src,
29
+ target,
25
30
  canWatch,
26
31
  mode: 'es'
27
32
  });
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.commandExecutor = commandExecutor;
7
7
 
8
+ var _constants = require("../../shared/constants");
9
+
8
10
  var _watchRun = require("../../shared/fileUtils/watchRun");
9
11
 
10
12
  function commandExecutor(options) {
@@ -18,10 +20,13 @@ function commandExecutor(options) {
18
20
  extraArgs.splice(index, 1);
19
21
  }
20
22
 
23
+ let [src, target] = extraArgs;
24
+ src = (0, _constants.joinWithAppPath)(src || 'src');
25
+ target = (0, _constants.joinWithAppPath)(target || 'lib');
21
26
  (0, _watchRun.watchRun)({
22
27
  options,
23
- src: 'src',
24
- target: 'target',
28
+ src,
29
+ target,
25
30
  canWatch,
26
31
  mode: 'lib'
27
32
  });
@@ -323,11 +323,6 @@ var _default = {
323
323
  cssAttributes: null,
324
324
  i18nAttributes: null
325
325
  },
326
- typeScript: {
327
- enable: {
328
- value: false,
329
- cli: 'type_script_enable'
330
- }
331
- }
326
+ externals: null
332
327
  };
333
328
  exports.default = _default;
@@ -26,7 +26,7 @@ function babelWebConfig(options, mode) {
26
26
  browserList
27
27
  } = options.babelCustomizations;
28
28
  return {
29
- presets: [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react'), require.resolve('@babel/preset-typescript')],
29
+ presets: [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react')],
30
30
  plugins: customBabelPlugins(babelPlugins).concat((0, _getBabelPlugin.getBabelPlugin)(options)).filter(Boolean)
31
31
  };
32
32
  }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Dummy = void 0;
7
+
8
+ var _webpack = require("webpack");
9
+
10
+ class Dummy {
11
+ constructor() {
12
+ this.variableName = '__CSS_CDN__';
13
+ } // eslint-disable-next-line class-methods-use-this
14
+
15
+
16
+ apply(compiler) {
17
+ // Access processAssets hook from v5 API
18
+ const {
19
+ RawSource
20
+ } = compiler.webpack.sources;
21
+ compiler.hooks.compilation.tap('MyCutomPlugin', compilation => {
22
+ compilation.hooks.processAssets.tap({
23
+ name: 'MyCustomPlugin',
24
+ stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS // Choose an appropriate stage based on your needs
25
+
26
+ }, assets => {
27
+ console.log('working'); // Here you can interact with assets
28
+
29
+ const asset = 'js/runtime~main'; // Replace with your actual chunk file name pattern
30
+
31
+ Object.keys(assets).forEach(assetName => {
32
+ // if (assetName.includes('main')) console.log(assetName);
33
+ // });
34
+ if (assetName.includes(asset)) {
35
+ console.log('found');
36
+ const originalSource = assets[assetName].source(); // console.log(originalSource);
37
+
38
+ const modifiedSource = originalSource.replace('__webpack_require__.p + __webpack_require__.u(chunkId);', `window['${this.variableName}'] + __webpack_require__.u(chunkId);`);
39
+ console.log(assetName); // console.log(modifiedSource);
40
+ // console.log(a);
41
+ // Apply your modifications here
42
+ // const modifiedSource = someModificationFunction(originalSource);
43
+ // Update the asset's source
44
+ // eslint-disable-next-line no-param-reassign
45
+
46
+ compilation.updateAsset(assetName, new RawSource(modifiedSource));
47
+ }
48
+ });
49
+ });
50
+ });
51
+ }
52
+
53
+ }
54
+
55
+ exports.Dummy = Dummy;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configDummy = configDummy;
7
+
8
+ var _dummy = require("../custom_plugins/dummy");
9
+
10
+ function configDummy(options) {
11
+ console.log('running');
12
+ return new _dummy.Dummy();
13
+ }
@@ -47,10 +47,12 @@ var _configBundleIntegrityReport = require("./pluginConfigs/configBundleIntegrit
47
47
 
48
48
  var _configRuntimeResourceCleanup = require("./pluginConfigs/configRuntimeResourceCleanup");
49
49
 
50
+ var _configDummy = require("./pluginConfigs/configDummy");
51
+
50
52
  // import { IgnorePlugin } from 'webpack';
51
53
  function plugins(options) {
52
54
  const {
53
55
  webpackPlugins
54
56
  } = options;
55
- return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), (0, _configBundleIntegrityReport.configBundleIntegrityReport)(options), (0, _configRuntimeResourceCleanup.configRuntimeResourceCleanup)(options), ...webpackPlugins].filter(Boolean);
57
+ return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), (0, _configBundleIntegrityReport.configBundleIntegrityReport)(options), (0, _configRuntimeResourceCleanup.configRuntimeResourceCleanup)(options), (0, _configDummy.configDummy)(options), ...webpackPlugins].filter(Boolean);
56
58
  }
@@ -11,8 +11,6 @@ var _outputConfig = require("./outputConfig");
11
11
 
12
12
  var _jsLoaders = require("./jsLoaders");
13
13
 
14
- var _tsLoaders = require("./tsLoaders");
15
-
16
14
  var _cssLoaders = require("./cssLoaders");
17
15
 
18
16
  var _assetLoaders = require("./loaderConfigs/assetLoaders");
@@ -48,7 +46,7 @@ function webpackConfigCreator(options) {
48
46
  module: {
49
47
  /* strictExportPresence for break the build when imported module not present in respective file */
50
48
  // strictExportPresence: true,
51
- rules: [...(0, _jsLoaders.jsLoaders)(options), ...(0, _tsLoaders.tsLoaders)(options), ...(0, _cssLoaders.cssLoaders)(options), (0, _configWebWorkerLoader.configWebWorkerLoader)(options), (0, _configHtmlTemplateLoader.configHtmlTemplateLoader)(options), ...(0, _assetLoaders.assetLoaders)(options), ...(0, _configCustomLoaders.configCustomLoaders)(options)]
49
+ rules: [...(0, _jsLoaders.jsLoaders)(options), ...(0, _cssLoaders.cssLoaders)(options), (0, _configWebWorkerLoader.configWebWorkerLoader)(options), (0, _configHtmlTemplateLoader.configHtmlTemplateLoader)(options), ...(0, _assetLoaders.assetLoaders)(options), ...(0, _configCustomLoaders.configCustomLoaders)(options)]
52
50
  },
53
51
  plugins: (0, _plugins.plugins)(options),
54
52
  externals: (0, _externals.externals)(options),
@@ -11,8 +11,6 @@ var _watcher = _interopRequireDefault(require("watcher"));
11
11
 
12
12
  var _runBabelForJSFile = require("../babel/runBabelForJSFile");
13
13
 
14
- var _runBabelForTsFile = require("../babel/runBabelForTsFile");
15
-
16
14
  var _runPostCssForCssFile = require("../postcss/runPostCssForCssFile");
17
15
 
18
16
  var _directoryIterator = require("./directoryIterator");
@@ -25,8 +23,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
23
 
26
24
  const isJs = ext => ext === '.js';
27
25
 
28
- const isTs = ext => ext === '.ts';
29
-
30
26
  const isCss = ext => ext === '.css';
31
27
 
32
28
  function watchRun({
@@ -58,13 +54,6 @@ function watchRun({
58
54
  outputFile,
59
55
  options
60
56
  });
61
- } else if (isTs(ext)) {
62
- (0, _runBabelForTsFile.runBabelForTSFile)({
63
- filename,
64
- outputFile,
65
- options,
66
- mode
67
- });
68
57
  } else {
69
58
  (0, _copyFile.copyFile)(filename, outputFile);
70
59
  }
@@ -92,8 +81,7 @@ function watchRun({
92
81
  const watcher = new _watcher.default(src, {
93
82
  recursive: true,
94
83
  ignoreInitial: true,
95
- ignore: filename => filename.indexOf('__tests__') !== -1 // remove the test cases
96
-
84
+ ignore: filename => filename.indexOf('__tests__') !== -1
97
85
  });
98
86
  watcher.on('all', (event, filename) => {
99
87
  if (event === 'unlink' || event === 'unlinkDir') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.6-exp.4",
3
+ "version": "0.0.6-exp.6",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -55,9 +55,6 @@
55
55
  "webpack": "5.79.0",
56
56
  "webpack-bundle-analyzer": "4.8.0",
57
57
  "webpack-cli": "4.10.0",
58
- "webpack-dev-middleware": "6.1.1",
59
- "typescript": "5.2.2",
60
- "ts-loader": "8.2.0",
61
- "@babel/preset-typescript": "7.23.2"
58
+ "webpack-dev-middleware": "6.1.1"
62
59
  }
63
60
  }
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.runBabelForTSFile = runBabelForTSFile;
7
-
8
- var _core = require("@babel/core");
9
-
10
- var _babelWebConfig = require("./babelWebConfig");
11
-
12
- var _copyFile = require("../fileUtils/copyFile");
13
-
14
- function runBabelForTSFile({
15
- filename,
16
- outputFile,
17
- options,
18
- mode = 'es'
19
- }) {
20
- const {
21
- enable
22
- } = options.typeScript;
23
- console.log('typescript', enable);
24
-
25
- if (enable) {
26
- // const jsSourceCode = readFileSync(filename).toString();
27
- const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
28
- const result = (0, _core.transformFileSync)(filename, babelConfig);
29
- (0, _copyFile.writeFile)(outputFile.replace('.ts', '.js'), result.code);
30
- }
31
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.tsLoaders = tsLoaders;
7
-
8
- function tsLoaders(options) {
9
- const {
10
- enable
11
- } = options.typeScript;
12
- console.log('typescript', enable);
13
-
14
- if (enable) {
15
- return [{
16
- test: /\.(ts|tsx)$/,
17
- exclude: /node_modules/,
18
- use: 'ts-loader' // include: path.join(appPath, folder)
19
-
20
- }];
21
- }
22
-
23
- return [];
24
- }