@zohodesk/client_build_tool 0.0.12-exp.3 → 0.0.12-exp.4
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.
- package/lib/shared/bundler/webpack/custom_plugins/DummyPlugin/index.js +31 -4
- package/lib/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +84 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configDummyPlugin.js +4 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +21 -0
- package/lib/shared/bundler/webpack/plugins.js +2 -2
- package/package.json +1 -1
|
@@ -5,15 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin.js"));
|
|
11
9
|
|
|
10
|
+
var _nameTemplates = require("../../common/nameTemplates");
|
|
11
|
+
|
|
12
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
class DummyPlugin {
|
|
15
|
-
constructor(entries = []) {
|
|
17
|
+
constructor(entries = [], options) {
|
|
16
18
|
this.entries = entries;
|
|
19
|
+
this.options = options;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
apply(compiler) {
|
|
@@ -24,7 +27,7 @@ class DummyPlugin {
|
|
|
24
27
|
}) => {
|
|
25
28
|
// Create child compiler for this entry
|
|
26
29
|
const childCompiler = compilation.createChildCompiler(`additional-entry ${name}`, {
|
|
27
|
-
filename:
|
|
30
|
+
filename: (0, _nameTemplates.nameTemplates)('js', this.options),
|
|
28
31
|
// output filename
|
|
29
32
|
chunkFilename: `${name}.[id].js`,
|
|
30
33
|
publicPath: compiler.options.output.publicPath,
|
|
@@ -43,7 +46,31 @@ class DummyPlugin {
|
|
|
43
46
|
if (childCompilation.errors && childCompilation.errors.length) {
|
|
44
47
|
compilation.errors.push(...childCompilation.errors);
|
|
45
48
|
} // Files are emitted automatically by child compiler
|
|
49
|
+
// ⚡ Hook HtmlWebpackPlugin and inject this file
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const childChunks = childCompilation.chunks;
|
|
46
53
|
|
|
54
|
+
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTags.tapAsync("DummyPlugin", (data, cb) => {
|
|
55
|
+
let fileName = "";
|
|
56
|
+
childChunks.forEach(chunk => {
|
|
57
|
+
fileName = compilation.getPath((0, _nameTemplates.nameTemplates)("js", this.options), {
|
|
58
|
+
chunk,
|
|
59
|
+
contentHashType: "javascript"
|
|
60
|
+
}); // ✅ Use Webpack's getPath to resolve your template properly
|
|
61
|
+
});
|
|
62
|
+
data.assetTags.scripts.unshift({
|
|
63
|
+
tagName: "script",
|
|
64
|
+
voidTag: false,
|
|
65
|
+
attributes: {
|
|
66
|
+
src: fileName
|
|
67
|
+
},
|
|
68
|
+
meta: {
|
|
69
|
+
plugin: "DummyPlugin"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
cb(null, data);
|
|
73
|
+
});
|
|
47
74
|
});
|
|
48
75
|
});
|
|
49
76
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin.js"));
|
|
9
|
+
|
|
10
|
+
var _nameTemplates = require("../../common/nameTemplates");
|
|
11
|
+
|
|
12
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const pluginName = 'MurphyInjectorPlugin';
|
|
17
|
+
|
|
18
|
+
class MurphyInjectorPlugin {
|
|
19
|
+
constructor(entries = [], options) {
|
|
20
|
+
this.entries = entries;
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
apply(compiler) {
|
|
25
|
+
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
26
|
+
this.entries.forEach(({
|
|
27
|
+
name,
|
|
28
|
+
file
|
|
29
|
+
}) => {
|
|
30
|
+
// Create child compiler for this entry
|
|
31
|
+
const childCompiler = compilation.createChildCompiler(`additional-entry ${name}`, {
|
|
32
|
+
filename: (0, _nameTemplates.nameTemplates)('js', this.options),
|
|
33
|
+
// output filename
|
|
34
|
+
chunkFilename: `${name}.[id].js`,
|
|
35
|
+
publicPath: compiler.options.output.publicPath,
|
|
36
|
+
globalObject: "self" // safe for workers too
|
|
37
|
+
|
|
38
|
+
}); // Attach the entry point
|
|
39
|
+
|
|
40
|
+
new _SingleEntryPlugin.default(compiler.context, file, name).apply(childCompiler); // Run the child compiler
|
|
41
|
+
|
|
42
|
+
childCompiler.runAsChild((err, entries, childCompilation) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
compilation.errors.push(err);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (childCompilation.errors && childCompilation.errors.length) {
|
|
49
|
+
compilation.errors.push(...childCompilation.errors);
|
|
50
|
+
} // Files are emitted automatically by child compiler
|
|
51
|
+
// ⚡ Hook HtmlWebpackPlugin and inject this file
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const childChunks = childCompilation.chunks;
|
|
55
|
+
|
|
56
|
+
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTags.tapAsync(pluginName, (data, cb) => {
|
|
57
|
+
let fileName = "";
|
|
58
|
+
childChunks.forEach(chunk => {
|
|
59
|
+
fileName = compilation.getPath((0, _nameTemplates.nameTemplates)("js", this.options), {
|
|
60
|
+
chunk,
|
|
61
|
+
contentHashType: "javascript"
|
|
62
|
+
}); // ✅ Use Webpack's getPath to resolve your template properly
|
|
63
|
+
});
|
|
64
|
+
data.assetTags.scripts.unshift({
|
|
65
|
+
tagName: "script",
|
|
66
|
+
voidTag: false,
|
|
67
|
+
attributes: {
|
|
68
|
+
src: fileName
|
|
69
|
+
},
|
|
70
|
+
meta: {
|
|
71
|
+
plugin: pluginName
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
cb(null, data);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var _default = MurphyInjectorPlugin;
|
|
84
|
+
exports.default = _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ConfigMurphyInjectorPlugin = ConfigMurphyInjectorPlugin;
|
|
7
7
|
|
|
8
8
|
var _constants = require("../../../constants");
|
|
9
9
|
|
|
@@ -13,10 +13,9 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
return new _DummyPlugin.default([{
|
|
16
|
+
function ConfigMurphyInjectorPlugin(options) {
|
|
17
|
+
return new MurphyInjectorPlugin([{
|
|
19
18
|
name: "murphy",
|
|
20
19
|
file: _path.default.join(_constants.appPath, "./src/library/murphy/initial_html/index.js")
|
|
21
|
-
}]);
|
|
20
|
+
}], options);
|
|
22
21
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConfigMurphyInjectorPlugin = ConfigMurphyInjectorPlugin;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../../../constants");
|
|
9
|
+
|
|
10
|
+
var _MurphyInjectorPlugin = _interopRequireDefault(require("../custom_plugins/MurphyInjectorPlugin"));
|
|
11
|
+
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function ConfigMurphyInjectorPlugin(options) {
|
|
17
|
+
return new _MurphyInjectorPlugin.default([{
|
|
18
|
+
name: "murphy",
|
|
19
|
+
file: _path.default.join(_constants.appPath, "./src/library/murphy/initial_html/index.js")
|
|
20
|
+
}], options);
|
|
21
|
+
}
|
|
@@ -47,7 +47,7 @@ var _configBundleIntegrityReport = require("./pluginConfigs/configBundleIntegrit
|
|
|
47
47
|
|
|
48
48
|
var _configRuntimeResourceCleanup = require("./pluginConfigs/configRuntimeResourceCleanup");
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _configMurphyInjectorPlugin = require("./pluginConfigs/configMurphyInjectorPlugin");
|
|
51
51
|
|
|
52
52
|
var _configCustomScriptLoadingStrategyPlugin = require("./pluginConfigs/configCustomScriptLoadingStrategyPlugin");
|
|
53
53
|
|
|
@@ -56,5 +56,5 @@ function plugins(options) {
|
|
|
56
56
|
const {
|
|
57
57
|
webpackPlugins
|
|
58
58
|
} = options;
|
|
59
|
-
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, _configCustomScriptLoadingStrategyPlugin.configCustomScriptLoadingStrategyPlugin)(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,
|
|
59
|
+
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, _configCustomScriptLoadingStrategyPlugin.configCustomScriptLoadingStrategyPlugin)(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, _configMurphyInjectorPlugin.configMurphyInjectorPlugin)(options), ...webpackPlugins].filter(Boolean);
|
|
60
60
|
}
|