@zohodesk/client_build_tool 0.0.6-exp.27 → 0.0.6-exp.29

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.
@@ -330,6 +330,10 @@ var _default = {
330
330
  value: false,
331
331
  cli: 'type_script_enable'
332
332
  }
333
+ },
334
+ optimization: {
335
+ jsExcludePath: '',
336
+ cssExcludePath: ''
333
337
  }
334
338
  };
335
339
  exports.default = _default;
@@ -65,7 +65,7 @@ function getI18nLoadingRuntimeModule({
65
65
  return _webpack.Template.asString([`${prefixFunc(i18nChunks)}`, `var createI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId, fullsrc, resolve, reject', ['var scriptTag = document.createElement("script");', attributes ? _webpack.Template.asString(Object.entries(attributes).map(entry => {
66
66
  const [key, value] = entry;
67
67
  return `scriptTag.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
68
- })) : '', scriptType ? `scriptTag.type = ${JSON.stringify(scriptType)};` : '', `var onScriptComplete = ${runtimeTemplate.basicFunction('event', ['// avoid mem leaks.', 'scriptTag.onerror = scriptTag.onload = null;', 'if (event.type === \'load\') {', _webpack.Template.indent(['resolve();']), '} else {', _webpack.Template.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src || fullsrc;', 'var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + realSrc + ")");', 'err.code = "I18N_CHUNK_LOAD_FAILED";', 'err.type = errorType;', 'err.request = realSrc;', 'scriptTag.parentNode.removeChild(scriptTag)', 'reject(err);']), '}'])}`, 'scriptTag.onerror = scriptTag.onload = onScriptComplete;', 'scriptTag.src = fullsrc;', crossOriginLoading ? _webpack.Template.asString(['if (scriptTag.src.indexOf(window.location.origin + \'/\') !== 0) {', _webpack.Template.indent(`scriptTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insertRoot && insertPlace || _webpack.Template.asString(['document.head.appendChild(scriptTag);']), 'return scriptTag;'])};`, `var findI18nScriptTag = ${runtimeTemplate.basicFunction('src, fullsrc', ['var existingScriptTags = document.getElementsByTagName("script");', 'for(var i = 0; i < existingScriptTags.length; i++) {', _webpack.Template.indent(['var tag = existingScriptTags[i];', 'var dataSrc = tag.getAttribute("data-src") || tag.getAttribute("src");', 'if((dataSrc === src || dataSrc === fullsrc)) return tag;']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', _webpack.Template.indent(['var tag = existingStyleTags[i];', 'var dataSrc = tag.getAttribute("data-src");', 'if(dataSrc === src || dataSrc === fullsrc) return tag;']), '}'])};`, `var loadI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId', `return new Promise(${runtimeTemplate.basicFunction('resolve, reject', [`var src = ${_webpack.RuntimeGlobals.require}.miniI18nF(chunkId);`, `var fullsrc = ${_webpack.RuntimeGlobals.publicPath} + src;`, 'if(findI18nScriptTag(src, fullsrc)) return resolve();', 'createI18nScriptTag(chunkId, fullsrc, resolve, reject);'])});`)}`, '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(
68
+ })) : '', '__webpack_require__.nc && scriptTag.setAttribute("nonce", __webpack_require__.nc)', scriptType ? `scriptTag.type = ${JSON.stringify(scriptType)};` : '', `var onScriptComplete = ${runtimeTemplate.basicFunction('event', ['// avoid mem leaks.', 'scriptTag.onerror = scriptTag.onload = null;', 'if (event.type === \'load\') {', _webpack.Template.indent(['resolve();']), '} else {', _webpack.Template.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src || fullsrc;', 'var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + realSrc + ")");', 'err.code = "I18N_CHUNK_LOAD_FAILED";', 'err.type = errorType;', 'err.request = realSrc;', 'scriptTag.parentNode.removeChild(scriptTag)', 'reject(err);']), '}'])}`, 'scriptTag.onerror = scriptTag.onload = onScriptComplete;', 'scriptTag.src = fullsrc;', crossOriginLoading ? _webpack.Template.asString(['if (scriptTag.src.indexOf(window.location.origin + \'/\') !== 0) {', _webpack.Template.indent(`scriptTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insertRoot && insertPlace || _webpack.Template.asString(['document.head.appendChild(scriptTag);']), 'return scriptTag;'])};`, `var findI18nScriptTag = ${runtimeTemplate.basicFunction('src, fullsrc', ['var existingScriptTags = document.getElementsByTagName("script");', 'for(var i = 0; i < existingScriptTags.length; i++) {', _webpack.Template.indent(['var tag = existingScriptTags[i];', 'var dataSrc = tag.getAttribute("data-src") || tag.getAttribute("src");', 'if((dataSrc === src || dataSrc === fullsrc)) return tag;']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', _webpack.Template.indent(['var tag = existingStyleTags[i];', 'var dataSrc = tag.getAttribute("data-src");', 'if(dataSrc === src || dataSrc === fullsrc) return tag;']), '}'])};`, `var loadI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId', `return new Promise(${runtimeTemplate.basicFunction('resolve, reject', [`var src = ${_webpack.RuntimeGlobals.require}.miniI18nF(chunkId);`, `var fullsrc = ${_webpack.RuntimeGlobals.publicPath} + src;`, 'if(findI18nScriptTag(src, fullsrc)) return resolve();', 'createI18nScriptTag(chunkId, fullsrc, resolve, reject);'])});`)}`, '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(
69
69
  /** @type {string[]} */
70
70
  chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', `${_webpack.RuntimeGlobals.ensureChunkHandlers}.miniI18n = ${runtimeTemplate.basicFunction('chunkId, promises', [`var i18nChunks = ${JSON.stringify(chunkMap)};`, 'if(installedI18nChunks[chunkId]) promises.push(installedI18nChunks[chunkId]);', 'else if(installedI18nChunks[chunkId] !== 0 && i18nChunks[chunkId]) {', _webpack.Template.indent([`promises.push(installedI18nChunks[chunkId] = loadI18nScriptTag(chunkId).then(${runtimeTemplate.basicFunction('', 'installedI18nChunks[chunkId] = 0;')}, ${runtimeTemplate.basicFunction('e', ['delete installedI18nChunks[chunkId];', 'throw e;'])}));`]), '}'])};`, '']);
71
71
  }
@@ -37,6 +37,10 @@ class InitialHtmlPlugin {
37
37
  const headTags = [];
38
38
  const bodyTags = [];
39
39
  data.headTags.forEach(tag => {
40
+ Object.assign(tag.attributes, {
41
+ nonce: '{{--CSP-nonce}}'
42
+ });
43
+
40
44
  if (tag.tagName === 'link') {
41
45
  headTags.push(tag);
42
46
  } else {
@@ -117,6 +117,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
117
117
  let link = document.createElement("link");
118
118
  link.href = href;
119
119
  link.rel = rel;
120
+ __webpack_require__.nc && link.setAttribute("nonce", __webpack_require__.nc)
120
121
  if(href.endsWith(".css")) {
121
122
  link.as="style";
122
123
  } else if (href.endsWith(".js")) {
@@ -29,7 +29,7 @@ class TPHashMappingPlugin {
29
29
 
30
30
  getFiles() {
31
31
  const hashMapping = {};
32
- this.fileMappings.filter(f => f.enable).forEach(fileInfo => {
32
+ this.fileMappings.forEach(fileInfo => {
33
33
  const filePath = _path.default.join(this.tpFolder, fileInfo.filePath);
34
34
 
35
35
  if (_fs.default.existsSync(filePath)) {
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.optimizationConfig = optimizationConfig;
7
7
 
8
+ var _terserWebpackPlugin = _interopRequireDefault(require("terser-webpack-plugin"));
9
+
8
10
  var _nameTemplates = require("./common/nameTemplates");
9
11
 
10
12
  var _hashUtils = require("./custom_plugins/I18nSplitPlugin/utils/hashUtils");
@@ -13,6 +15,8 @@ var _configCSSMinifierPlugin = require("./pluginConfigs/configCSSMinifierPlugin"
13
15
 
14
16
  var _splitChunksConfig = require("./splitChunksConfig");
15
17
 
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
16
20
  function optimizationConfig(options) {
17
21
  const {
18
22
  changeRuntimeChunkChar
@@ -31,10 +35,16 @@ function optimizationConfig(options) {
31
35
  const suffix = // chunkSplitEnable ? '_[locale]' : '';
32
36
  chunkSplitEnable && chunkFilenameHasContentHash ? '_[locale]' : '';
33
37
  const char = changeRuntimeChunkChar;
38
+ const excludeList = options.optimization.jsExcludePath;
34
39
  return {
35
40
  splitChunks: (0, _splitChunksConfig.splitChunksConfig)(options),
36
41
  minimizer: [// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
37
- '...', (0, _configCSSMinifierPlugin.configCSSMinifierPlugin)(options)].filter(Boolean),
42
+ // '...',
43
+ new _terserWebpackPlugin.default({
44
+ exclude: excludeList,
45
+ extractComments: false // Do not extract comments to .LICENSE.txt files
46
+
47
+ }), (0, _configCSSMinifierPlugin.configCSSMinifierPlugin)(options)].filter(Boolean),
38
48
  moduleIds: 'named',
39
49
  runtimeChunk: {
40
50
  name: entrypoint => `runtime${char}${entrypoint.name}${suffix}`
@@ -14,11 +14,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  // import UglifyCSSPlugin from '../custom_plugins/UglifyCSSPlugin';
15
15
  // eslint-disable-next-line no-unused-vars
16
16
  function configCSSMinifierPlugin(options) {
17
+ const excludeList = options.optimization.cssExcludePath;
18
+
17
19
  if ((0, _modeUtils.isNotProduction)(options)) {
18
20
  return null;
19
21
  } // return null;
20
22
  // return new UglifyCSSPlugin();
21
23
 
22
24
 
23
- return new _cssMinimizerWebpackPlugin.default();
25
+ return new _cssMinimizerWebpackPlugin.default({
26
+ exclude: excludeList
27
+ });
24
28
  }
@@ -15,7 +15,8 @@ function configMiniCSSExtractPlugin(options) {
15
15
  const {
16
16
  enableRTLSplit
17
17
  } = options.css.plugins.rtlSplit;
18
- const cssLTRFileNameTempalte = enableRTLSplit ? (0, _nameTemplates.nameTemplates)('cssdir', options) : (0, _nameTemplates.nameTemplates)('css', options);
18
+ const cssLTRFileNameTempalte = enableRTLSplit ? (0, _nameTemplates.nameTemplates)('cssdir', options) : (0, _nameTemplates.nameTemplates)('css', options); // eslint-disable-next-line no-undef
19
+
19
20
  return new _miniCssExtractPlugin.default({
20
21
  filename: cssLTRFileNameTempalte,
21
22
  chunkFilename: cssLTRFileNameTempalte
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.6-exp.26",
3
+ "version": "0.0.6-exp.27",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.6-exp.27",
3
+ "version": "0.0.6-exp.29",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {