@zohodesk/client_build_tool 0.0.14-exp.1 → 0.0.14-exp.3
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.
|
@@ -105,8 +105,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
105
105
|
*/
|
|
106
106
|
|
|
107
107
|
return _webpack.Template.asString([`const ntc = ${JSON.stringify(needsMap ? nameIdMap : {})};
|
|
108
|
-
// const cns = Object.keys(ntc);
|
|
109
|
-
const preloadChunkGraph = {{--preload-chunk-graph-object}}
|
|
108
|
+
// const cns = Object.keys(ntc);
|
|
110
109
|
|
|
111
110
|
function clt(href, rel) {
|
|
112
111
|
let link = document.createElement("link");
|
|
@@ -146,6 +145,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
146
145
|
|
|
147
146
|
// Preload a chunk (${pluginName})
|
|
148
147
|
${_webpack.RuntimeGlobals.require}.plc = function preloadChunk(chunkId) {
|
|
148
|
+
const preloadChunkGraph = {{--preload-chunk-graph-object}}
|
|
149
149
|
${`
|
|
150
150
|
if (typeof preloadChunkGraph !== 'object' || !preloadChunkGraph) return;
|
|
151
151
|
preloadChunkGraph[chunkId].forEach(idOfAChunk => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/client_build_tool",
|
|
3
|
-
"version": "0.0.14-exp.
|
|
3
|
+
"version": "0.0.14-exp.3",
|
|
4
4
|
"description": "A CLI tool to build web applications and client libraries",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@babel/preset-env": "7.18.2",
|
|
33
33
|
"@babel/preset-react": "7.17.12",
|
|
34
34
|
"@babel/preset-typescript": "7.23.2",
|
|
35
|
+
"@zohodesk-private/client_dev_cert": "^1.0.6",
|
|
35
36
|
"@zohodesk/client_packages_group": "1.0.2",
|
|
36
37
|
"babel-loader": "9.1.2",
|
|
37
38
|
"babel-plugin-module-resolver": "5.0.2",
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
RawSource
|
|
5
|
-
} = require('webpack-sources');
|
|
6
|
-
|
|
7
|
-
class InjectChunkGraphPlugin {
|
|
8
|
-
constructor({
|
|
9
|
-
chunkName,
|
|
10
|
-
globalVarName = 'chunkGraph'
|
|
11
|
-
}) {
|
|
12
|
-
this.chunkNames = ['ticketDetailview'];
|
|
13
|
-
this.globalVarName = globalVarName;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
apply(compiler) {
|
|
17
|
-
console.log('inject');
|
|
18
|
-
compiler.hooks.thisCompilation.tap('InjectChunkGraphPlugin', compilation => {
|
|
19
|
-
compilation.hooks.processAssets.tap({
|
|
20
|
-
name: 'InjectChunkGraphPlugin',
|
|
21
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
22
|
-
}, () => {
|
|
23
|
-
const stats = compilation.getStats().toJson({
|
|
24
|
-
all: true
|
|
25
|
-
});
|
|
26
|
-
const chunkGraph = {};
|
|
27
|
-
this.chunkNames.forEach(chunkName => {
|
|
28
|
-
const chunkGroup = stats.namedChunkGroups?.[chunkName];
|
|
29
|
-
|
|
30
|
-
if (!chunkGroup) {
|
|
31
|
-
compilation.warnings.push(new Error(`[InjectChunkGraphPlugin] Chunk group "${chunkName}" not found.`));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
chunkGraph[chunkName] = chunkGroup.chunks;
|
|
36
|
-
});
|
|
37
|
-
const code = `
|
|
38
|
-
window.preloadChunkGraph=${JSON.stringify(chunkGraph)};
|
|
39
|
-
`; // Find runtime chunk file
|
|
40
|
-
|
|
41
|
-
const runtimeChunk = stats.chunks.find(chunk => chunk.names?.some(n => n.includes('runtime~main')));
|
|
42
|
-
const runtimeChunkName = runtimeChunk.files[0];
|
|
43
|
-
const originalSource = compilation.assets[runtimeChunkName].source();
|
|
44
|
-
console.log(originalSource);
|
|
45
|
-
const newSource = originalSource + '\n' + code; // Update the runtime asset with injected code
|
|
46
|
-
|
|
47
|
-
compilation.updateAsset(runtimeChunkName, new RawSource(newSource));
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = InjectChunkGraphPlugin;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.configInjectChunkGraphPlugin = configInjectChunkGraphPlugin;
|
|
7
|
-
|
|
8
|
-
var _a = _interopRequireDefault(require("../custom_plugins/a"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function configInjectChunkGraphPlugin(options) {
|
|
13
|
-
console.log('whats');
|
|
14
|
-
return new _a.default(options);
|
|
15
|
-
}
|