@zohodesk/client_build_tool 0.0.6-exp.2 → 0.0.6-exp.21

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.
@@ -323,8 +323,6 @@ var _default = {
323
323
  cssAttributes: null,
324
324
  i18nAttributes: null
325
325
  },
326
- typeScript: {
327
- enable: false
328
- }
326
+ externals: null
329
327
  };
330
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
  }
@@ -15,10 +15,10 @@ var _modeUtils = require("./modeUtils");
15
15
  const templates = {
16
16
  html: ['index.html', 'index.[contenthash].html'],
17
17
  js: ['js/[name].js', 'js/[name].[contenthash].js'],
18
- chunkjs: ['js-chunks/[name].js', 'js-chunks/[name].[contenthash].js'],
19
- i18njs: ['i18n-chunks/[locale]/[name].i18n.js', 'i18n-chunks/[locale]/[name].[chunkhash].i18n.js'],
20
- i18nchunkjs: ['i18n-chunks/[locale]/[name].i18n.js', // 'i18n-chunks/[locale]/[name].[chunkhash].i18n.js'
21
- 'i18n-chunks/[locale]/[name].[contenthash].i18n.js'],
18
+ chunkjs: ['js-chunk/[name].js', 'js-chunks/[name].[contenthash].js'],
19
+ i18njs: ['i18n-chunk/[locale]/[name].i18n.js', 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'],
20
+ i18nchunkjs: ['i18n-chunk/[locale]/[name].i18n.js', // 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'
21
+ 'i18n-chunk/[locale]/[name].[contenthash].i18n.js'],
22
22
  i18nmanifest: ['i18n-manifest.json', 'i18n-manifest.json'],
23
23
  workerjs: ['js/[name].js', 'js/[name].[contenthash].js'],
24
24
  css: ['css/[name].css', 'css/[name].[contenthash].css'],
@@ -7,14 +7,20 @@ exports.default = void 0;
7
7
 
8
8
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
9
 
10
- var _nameTemplates = require("../common/nameTemplates");
10
+ var _webpack = require("webpack");
11
11
 
12
- var _modeUtils = require("../common/modeUtils");
12
+ var _nameTemplates = require("../../common/nameTemplates");
13
+
14
+ var _modeUtils = require("../../common/modeUtils");
15
+
16
+ var _webpackCustomJsUrlLoader = _interopRequireDefault(require("./webpackCustomJsUrlLoader"));
13
17
 
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
16
20
  // import { RuntimeGlobals, RuntimeModule } from 'webpack';
21
+ // eslint-disable-next-line import/extensions
17
22
  // import { Template } from 'webpack';
23
+ // eslint-disable-next-line import/extensions
18
24
  const pluginName = 'CdnChangePlugin'; // const MODULE_TYPE = 'css/mini-extract';
19
25
  // class CdnChangeRuntimePlugin extends RuntimeModule {
20
26
  // constructor(compiler, { variableName }) {
@@ -33,7 +39,7 @@ class CdnChangePlugin {
33
39
  constructor(options) {
34
40
  this.createSeparateSMap = options.createSeparateSMap;
35
41
  this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
36
- this.variableName = options.variableName || '__CSS_CDN__';
42
+ this.variableName = options.variableName || 'window.__SMAP_PATH__';
37
43
  this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
38
44
  this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
39
45
  this.mode = options.mode || 'prod';
@@ -71,15 +77,32 @@ class CdnChangePlugin {
71
77
  data.assets = { ...data.assets,
72
78
  css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
73
79
  js: data.assets.js.map(js => {
74
- if (((0, _modeUtils.isProductionMode)(mode) || createSeparateSMap) && !(0, _nameTemplates.isI18nFile)(js)) {
75
- js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
80
+ if ((0, _modeUtils.isProductionMode)(mode) && createSeparateSMap && !(0, _nameTemplates.isI18nFile)(js)) {
81
+ console.log(js, js.includes('smap'));
82
+
83
+ if (js.includes('smap')) {
84
+ js = js.replace('smap/js/', `{{--js-smap}}js/`); //eslint-disable-line
85
+ } else {
86
+ js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
87
+ }
76
88
  }
77
89
 
90
+ console.log('ending', js);
78
91
  return `${(0, _nameTemplates.isI18nFile)(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
79
92
  })
80
93
  };
81
94
  cb && cb(null, data);
82
95
  });
96
+
97
+ compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap(pluginName, (chunk, set) => {
98
+ if (typeof compilation.outputOptions.chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(compilation.outputOptions.chunkFilename)) {
99
+ set.add(_webpack.RuntimeGlobals.getFullHash);
100
+ }
101
+
102
+ compilation.addRuntimeModule(chunk, // eslint-disable-next-line new-cap
103
+ new _webpackCustomJsUrlLoader.default('javascript', 'javascript', _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false, this.variableName));
104
+ return true;
105
+ });
83
106
  });
84
107
  }
85
108
 
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ // import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';
9
+ const GetChunkFilenameRuntimeModule = require('webpack/lib/runtime/GetChunkFilenameRuntimeModule'); // import GetChunkFilenameRuntimeModule from 'webpack/lib/runtime/GetChunkFilenameRuntimeModule';
10
+ // const first = set => {
11
+ // const entry = set.values().next();
12
+ // return entry.done ? undefined : entry.value;
13
+ // };
14
+
15
+
16
+ class CustomizedGetChunkFilenameRuntimeModule extends GetChunkFilenameRuntimeModule {
17
+ /**
18
+ * @param {string} contentType the to use the content hash for
19
+ * @param {string} name kind of filename
20
+ * @param {string} global function name to be assigned
21
+ * @param {function(Chunk): string | FilenameFunction} getFilenameForChunk functor to get the filename or function
22
+ * @param {boolean} allChunks when false, only async chunks are included
23
+ */
24
+ constructor(contentType, name, global, getFilenameForChunk, allChunks, variableName) {
25
+ super(contentType, name, global, getFilenameForChunk, allChunks);
26
+ this.contentType = contentType;
27
+ this.global = global;
28
+ this.getFilenameForChunk = getFilenameForChunk;
29
+ this.allChunks = allChunks;
30
+ this.dependentHash = true;
31
+ this.variableName = variableName;
32
+ }
33
+
34
+ generate() {
35
+ const sourceCode = super.generate().toString();
36
+ const replaceCode = sourceCode.replaceAll('"js-chunks/', `${this.variableName} + "js-chunks/`);
37
+ return replaceCode;
38
+ }
39
+
40
+ }
41
+
42
+ var _default = CustomizedGetChunkFilenameRuntimeModule;
43
+ exports.default = _default;
@@ -13,7 +13,7 @@ function checkSmapFilePattern(assetName) {
13
13
  }
14
14
 
15
15
  function skipRuntimeFiles(assetName) {
16
- return !assetName.includes('runtime') || !assetName.includes('[locale]');
16
+ return !assetName.includes('[locale]');
17
17
  }
18
18
 
19
19
  const pluginName = 'SplitSourceMapPlugin'; // Purpose:
@@ -45,6 +45,21 @@ class SourceMapPlugin {
45
45
  }
46
46
  });
47
47
  });
48
+ compilation.hooks.processAssets.tap({
49
+ name: pluginName,
50
+ stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED // additionalAssets: true
51
+
52
+ }, assets => {
53
+ Object.keys(assets).forEach(assetName => {
54
+ if (assetName.includes('runtime') && skipRuntimeFiles(assetName)) {
55
+ const runtimeAssetCode = assets[assetName].source();
56
+ const newAssetName = `smap/${assetName}`;
57
+ compilation.emitAsset(newAssetName, new RawSource(runtimeAssetCode));
58
+ }
59
+
60
+ ;
61
+ });
62
+ });
48
63
  });
49
64
  }
50
65
 
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.devtoolConfig = devtoolConfig;
7
7
 
8
+ // eslint-disable-next-line consistent-return
8
9
  function devtoolConfig(options) {
9
- return options.devtool;
10
+ if (options.createSeparateSMap) {
11
+ return options.devtool;
12
+ }
10
13
  }
@@ -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.2",
3
+ "version": "0.0.6-exp.21",
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,30 +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
-
24
- if (enable) {
25
- // const jsSourceCode = readFileSync(filename).toString();
26
- const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
27
- const result = (0, _core.transformFileSync)(filename, babelConfig);
28
- (0, _copyFile.writeFile)(outputFile.replace('.ts', '.js'), result.code);
29
- }
30
- }
@@ -1,23 +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
-
13
- if (enable) {
14
- return [{
15
- test: /\.js$/,
16
- exclude: /node_modules/,
17
- use: 'ts-loader' // include: path.join(appPath, folder)
18
-
19
- }];
20
- }
21
-
22
- return [];
23
- }