@zohodesk/client_build_tool 0.0.6-exp.7 → 0.0.6-exp.8

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.
@@ -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 }) {
@@ -80,6 +86,12 @@ class CdnChangePlugin {
80
86
  };
81
87
  cb && cb(null, data);
82
88
  });
89
+
90
+ compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap(pluginName, (chunk, set) => {
91
+ compilation.addRuntimeModule(chunk, // eslint-disable-next-line new-cap
92
+ new _webpackCustomJsUrlLoader.default('javascript', 'javascript', _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false));
93
+ return true;
94
+ });
83
95
  });
84
96
  }
85
97
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Dummy = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _webpack = require("webpack");
9
9
 
@@ -12,126 +12,14 @@ const first = set => {
12
12
  return entry.done ? undefined : entry.value;
13
13
  };
14
14
 
15
- class Dummy {
16
- constructor() {
17
- this.variableName = '__CSS_CDN__';
18
- } // eslint-disable-next-line class-methods-use-this
19
- // apply(compiler) {
20
- // // Access processAssets hook from v5 API
21
- // const { RawSource } = compiler.webpack.sources;
22
- // compiler.hooks.compilation.tap('MyCutomPlugin', compilation => {
23
- // compilation.hooks.processAssets.tap(
24
- // {
25
- // name: 'MyCustomPlugin',
26
- // stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS // Choose an appropriate stage based on your needs
27
- // },
28
- // assets => {
29
- // console.log('working');
30
- // // Here you can interact with assets
31
- // const asset = 'js/runtime~main'; // Replace with your actual chunk file name pattern
32
- // Object.keys(assets).forEach(assetName => {
33
- // // if (assetName.includes('main')) console.log(assetName);
34
- // // });
35
- // if (assetName.includes(asset)) {
36
- // console.log('found');
37
- // const originalSource = assets[assetName].source();
38
- // // console.log(originalSource);
39
- // const modifiedSource = originalSource.replace(
40
- // '__webpack_require__.p + __webpack_require__.u(chunkId);',
41
- // `window['${this.variableName}'] + __webpack_require__.u(chunkId);`
42
- // );
43
- // console.log(assetName);
44
- // // console.log(modifiedSource);
45
- // // console.log(a);
46
- // // Apply your modifications here
47
- // // const modifiedSource = someModificationFunction(originalSource);
48
- // // Update the asset's source
49
- // // eslint-disable-next-line no-param-reassign
50
- // compilation.updateAsset(assetName, new RawSource(modifiedSource));
51
- // }
52
- // });
53
- // }
54
- // );
55
- // });
56
- // }
57
- // }
58
- // apply(compiler) {
59
- // compiler.hooks.compilation.tap('MyPlugin', compilation => {
60
- // console.log(compilation.moduleTemplates);
61
- // Object.keys(compilation).forEach(hi => {
62
- // console.log(hi);
63
- // })
64
- // const a = compilation.mainTemplate.hooks.localVars;
65
- // a.tap('nj',(source, chunk, hash) => {
66
- // console.log(source, 'pol');
67
- // })
68
- // console.log(compilation.moduleTemplates.javascript.hooks.localVars);
69
- // const { moduleTemplates } = compilation;
70
- // if (
71
- // moduleTemplates &&
72
- // moduleTemplates.javascript &&
73
- // moduleTemplates.javascript.hooks
74
- // ) {
75
- // moduleTemplates.javascript.hooks.localVars.tap(
76
- // 'MyPlugin',
77
- // (source, chunk, hash) => {
78
- // // Your logic for modifying localVars
79
- // return source;
80
- // }
81
- // );
82
- // } else {
83
- // console.error(
84
- // 'Hooks or module template not available for this compilation.'
85
- // );
86
- // }
87
- // });
88
- // }
89
- // }
90
- // apply(compiler) {
91
- // // Access the compilation hook
92
- // compiler.hooks.compilation.tap('MyCustomRuntimePlugin', compilation => {
93
- // console.log(webpack.javascript.JavascriptModulesPlugin.getCompilationHooks)
94
- // // Hook into the webpack runtime module template
95
- // webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(
96
- // compilation
97
- // ).renderRequire.tap('MyCustomRuntimePlugin', (source, renderContext) => {console.log(source)
98
- // // A naive example to demonstrate the replacement of __webpack_require__.u function.
99
- // // const newSource = source.replace('__webpack_require__.u', function () {
100
- // // // Your modified code or logic here
101
- // // return '/* custom logic */';
102
- // });
103
- // // return newSource;
104
- // });
105
- // };
106
- // }
107
- // MyCustomRuntimePlugin.js
108
- // }
109
- // apply(compiler) {
110
- // compiler.hooks.compilation.tap('MyWebpackPlugin', (compilation) => {
111
- // console.log(compilation.hooks.runtimeModule.compile.toString());
112
- // // Example: tapping into the 'optimize' hook
113
- // compilation.hooks.optimize.tap('MyWebpackPlugin', () => {
114
- // console.log('Assets are being optimized.');
115
- // });
116
- // });
117
- // }
118
-
119
-
120
- apply(compiler) {
121
- compiler.hooks.compilation.tap("k", compilation => {
122
- compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap("RuntimePlugin", (chunk, set) => {
123
- console.log('NUmber2');
124
- compilation.addRuntimeModule(chunk, new hello("javascript", "javascript", _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false));
125
- return true;
126
- });
127
- });
128
- }
129
-
130
- }
131
-
132
- exports.Dummy = Dummy;
133
-
134
- class hello extends _webpack.RuntimeModule {
15
+ class CustomizedGetChunkFilenameRuntimeModule extends _webpack.RuntimeModule {
16
+ /**
17
+ * @param {string} contentType the contentType to use the content hash for
18
+ * @param {string} name kind of filename
19
+ * @param {string} global function name to be assigned
20
+ * @param {function(Chunk): string | FilenameFunction} getFilenameForChunk functor to get the filename or function
21
+ * @param {boolean} allChunks when false, only async chunks are included
22
+ */
135
23
  constructor(contentType, name, global, getFilenameForChunk, allChunks) {
136
24
  super(`get ${name} chunk filename`);
137
25
  this.contentType = contentType;
@@ -305,7 +193,7 @@ class hello extends _webpack.RuntimeModule {
305
193
  const obj = {};
306
194
  let useId = false;
307
195
  let lastKey;
308
- let entries = 0;
196
+ let entries = 0; // eslint-disable-next-line no-restricted-syntax
309
197
 
310
198
  for (const c of dynamicUrlChunks) {
311
199
  const value = fn(c);
@@ -364,12 +252,14 @@ class hello extends _webpack.RuntimeModule {
364
252
  contentHashType: contentType
365
253
  });
366
254
  const cdn = `__CSS_CDN__`;
367
- console.log('jolly', dynamicFilename, url, 'url', cdn, url.endsWith('.js'), typeof url, url.includes('.js'));
368
- return _webpack.Template.asString([`// This function allow to reference ${includedChunksMessages.join(' and ')}`, `${global} = ${runtimeTemplate.basicFunction('chunkId', staticUrls.size > 0 ? ['// a return url for filenames not based on template', // it minimizes to `x===1?"...":x===2?"...":"..."`
255
+ return _webpack.Template.asString([`// This function allow to reference ${inclucdndedChunksMessages.join(' and ')}`, `${global} = ${runtimeTemplate.basicFunction('chunkId', staticUrls.size > 0 ? ['// return url for filenames not based on template', // it minimizes to `x===1?"...":x===2?"...":"..."`
369
256
  _webpack.Template.asString(Array.from(staticUrls, ([url, ids]) => {
370
257
  const condition = ids.size === 1 ? `chunkId === ${JSON.stringify(first(ids))}` : `{${Array.from(ids, id => `${JSON.stringify(id)}:1`).join(',')}}[chunkId]`;
371
258
  return `if (${condition}) return window.${cdn}+${url};`;
372
- })), '// b return url for filenames based on template', `return window.${cdn}+${url};`] : ['// c return url for filenames based on template', `return window.${cdn}+${url};`])};`]);
259
+ })), '// return url for filenames based on template', `return window.${cdn}+${url};`] : ['// return url for filenames based on template', `return window.${cdn}+${url};`])};`]);
373
260
  }
374
261
 
375
- }
262
+ }
263
+
264
+ var _default = CustomizedGetChunkFilenameRuntimeModule;
265
+ exports.default = _default;
@@ -33,10 +33,16 @@ class SourceMapPlugin {
33
33
  name: pluginName,
34
34
  stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
35
35
  }, assets => {
36
+ console.log('working');
36
37
  Object.keys(assets).forEach(assetName => {
38
+ if (assetName.includes('runtime')) {
39
+ console.log(assetName, true);
40
+ }
41
+
37
42
  const assetCode = assets[assetName].source();
38
43
 
39
- if (checkSmapFilePattern(assetName) && skipRuntimeFiles(assetName)) {
44
+ if (checkSmapFilePattern(assetName) // skipRuntimeFiles(assetName)
45
+ ) {
40
46
  compilation.renameAsset(assetName, `smap/${assetName}`);
41
47
 
42
48
  if (!/\.map$/.test(assetName)) {
@@ -47,12 +47,10 @@ var _configBundleIntegrityReport = require("./pluginConfigs/configBundleIntegrit
47
47
 
48
48
  var _configRuntimeResourceCleanup = require("./pluginConfigs/configRuntimeResourceCleanup");
49
49
 
50
- var _configDummy = require("./pluginConfigs/configDummy");
51
-
52
50
  // import { IgnorePlugin } from 'webpack';
53
51
  function plugins(options) {
54
52
  const {
55
53
  webpackPlugins
56
54
  } = options;
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);
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);
58
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.6-exp.7",
3
+ "version": "0.0.6-exp.8",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -1,12 +0,0 @@
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
- return new _dummy.Dummy();
12
- }