@zohodesk/client_build_tool 0.0.5-exp.5 → 0.0.5-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.
@@ -16,7 +16,7 @@ function optionsProcessor(options) {
16
16
  noPublicPath
17
17
  } = options;
18
18
  const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
19
- const publicPath = noPublicPath ? '' : (0, _decidePublicPath.decidePublicPath)(serverExtras);
19
+ const publicPath = noPublicPath ? null : (0, _decidePublicPath.decidePublicPath)(serverExtras);
20
20
  const contextFolderPath = (0, _constants.joinWithAppPath)(context);
21
21
  const defaultAppliedOptions = { ...options,
22
22
  // eslint-disable-next-line no-nested-ternary
@@ -136,6 +136,7 @@ class I18nFilesEmitPlugin {
136
136
  const fileName = fileNameTemplate.replaceAll('[locale]', locale);
137
137
  const filename = (0, _pathCreator.pathCreator)(fileName, compilation, {
138
138
  hash: compilation.hash,
139
+ chunkName: chunk.name,
139
140
  chunkId: chunk.id,
140
141
  chunkHash: chunk.hash,
141
142
  contentHash
@@ -45,8 +45,8 @@ class ResourceHintsPlugin {
45
45
  }
46
46
 
47
47
  enabledChunks.add(entryRuntimeChunk);
48
- set.add(_webpack.RuntimeGlobals.getFullHash);
49
- set.add(_webpack.RuntimeGlobals.getChunkCssFilename);
48
+ set.add(_webpack.RuntimeGlobals.getFullHash); // set.add(RuntimeGlobals.getChunkCssFilename);
49
+
50
50
  const {
51
51
  publicPathsTemplateObj
52
52
  } = this;
@@ -94,15 +94,26 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
94
94
  needsMap = true;
95
95
  }
96
96
  });
97
- const {
97
+ let {
98
98
  js: jsPP,
99
99
  css: cssPP,
100
100
  i18n: i18nPP
101
101
  } = this.publicPathsTemplateObj;
102
- return _webpack.Template.asString([`const nameToChunkIdMap = ${JSON.stringify(needsMap ? nameIdMap : {})};
103
- const chunkNames = Object.keys(nameToChunkIdMap);
104
-
105
- function createLinkTag(href, rel) {
102
+ jsPP = jsPP || _webpack.RuntimeGlobals.publicPath;
103
+ cssPP = cssPP || _webpack.RuntimeGlobals.publicPath;
104
+ i18nPP = i18nPP || _webpack.RuntimeGlobals.publicPath;
105
+ /**
106
+ * naming abbr
107
+ * ntc -> nameToChunkIdMap
108
+ * cns -> chunkNames
109
+ * clt -> createLinkTag
110
+ * lpp -> loadAsPreloadOrPrefetch
111
+ */
112
+
113
+ return _webpack.Template.asString([`const ntc = ${JSON.stringify(needsMap ? nameIdMap : {})};
114
+ const cns = Object.keys(ntc);
115
+
116
+ function clt(href, rel) {
106
117
  let link = document.createElement("link");
107
118
  link.href = href;
108
119
  link.rel = rel;
@@ -117,24 +128,24 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
117
128
  //return !url.includes(".undefined.");
118
129
  return url.indexOf(".undefined.") === -1;
119
130
  }
120
- function loadAsPreloadOrPrefetch(_chunkId, rel) {
131
+ function lpp(_chunkId, rel) {
121
132
  let chunkId = ${_webpack.RuntimeGlobals.require}.getChunkId(_chunkId);
122
133
  // ${_webpack.RuntimeGlobals.require}.e(chunkId);
123
134
  if(__webpack_require__.O.j(chunkId)) {
124
135
  return;
125
136
  }
126
- const jsUrl = ${jsPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.u(chunkId);
127
- const cssUrl = ${cssPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.miniCssF(chunkId);
128
- isValidUrl(jsUrl) && createLinkTag(jsUrl, rel);
129
- isValidUrl(cssUrl) && createLinkTag(cssUrl, rel);
137
+ const jsUrl = ${jsPP} + __webpack_require__.u(chunkId);
138
+ const cssUrl = ${cssPP} + __webpack_require__.miniCssF(chunkId);
139
+ isValidUrl(jsUrl) && clt(jsUrl, rel);
140
+ isValidUrl(cssUrl) && clt(cssUrl, rel);
130
141
  if(__webpack_require__.miniI18nF) {
131
- const i18nUrl = ${i18nPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.miniI18nF(chunkId);
132
- isValidUrl(i18nUrl) && createLinkTag(i18nUrl, rel);
142
+ const i18nUrl = ${i18nPP} + __webpack_require__.miniI18nF(chunkId);
143
+ isValidUrl(i18nUrl) && clt(i18nUrl, rel);
133
144
  }
134
145
  }
135
146
 
136
147
  ${_webpack.RuntimeGlobals.require}.getChunkId = function getChunkId(chunkId) {
137
- ${needsMap ? 'chunkId = nameToChunkIdMap[chunkId]||chunkId;' : ''}
148
+ ${needsMap ? 'chunkId = ntc[chunkId]||chunkId;' : ''}
138
149
  return chunkId;
139
150
  }
140
151
  ${_webpack.RuntimeGlobals.require}.getChunkIds = function getChunkIds(chunkId) {
@@ -142,7 +153,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
142
153
  this.allowPrefetchingMultipleChunks ? `
143
154
  const isRegExAsChunkId = chunkId instanceof RegExp;
144
155
  if(isRegExAsChunkId) {
145
- return chunkNames.filter(chunkName => chunkId.test(chunkName)).map(chunkName => nameToChunkIdMap[chunkName]);
156
+ return cns.filter(chunkName => chunkId.test(chunkName)).map(chunkName => ntc[chunkName]);
146
157
  }
147
158
  return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];
148
159
  ` : `return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];`}
@@ -153,15 +164,13 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
153
164
  let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId);
154
165
  chunkIds.forEach(idOfAChunk => {
155
166
  ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
156
- // loadAsPreloadOrPrefetch(idOfAChunk, "prefetch");
157
167
  })`}
158
168
  };
159
169
 
160
170
  // Preload a chunk (${pluginName})
161
171
  ${_webpack.RuntimeGlobals.require}.plc = function preloadChunk(chunkId) {
162
172
  let idOfAChunk = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)[0];
163
- // ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
164
- loadAsPreloadOrPrefetch(idOfAChunk, "preload");
173
+ lpp(idOfAChunk, "preload");
165
174
  }
166
175
  ` // `// Prefetch a chunk (${pluginName})`,
167
176
  // `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.5-exp.5",
3
+ "version": "0.0.5-exp.6",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {