@zohodesk/client_build_tool 0.0.12-exp.2 → 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 +82 -0
- package/lib/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +84 -0
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -12
- package/lib/shared/bundler/webpack/pluginConfigs/configDummyPlugin.js +21 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +21 -0
- package/lib/shared/bundler/webpack/plugins.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
class DummyPlugin {
|
|
17
|
+
constructor(entries = [], options) {
|
|
18
|
+
this.entries = entries;
|
|
19
|
+
this.options = options;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
apply(compiler) {
|
|
23
|
+
compiler.hooks.thisCompilation.tap("AdditionalEntriesPlugin", compilation => {
|
|
24
|
+
this.entries.forEach(({
|
|
25
|
+
name,
|
|
26
|
+
file
|
|
27
|
+
}) => {
|
|
28
|
+
// Create child compiler for this entry
|
|
29
|
+
const childCompiler = compilation.createChildCompiler(`additional-entry ${name}`, {
|
|
30
|
+
filename: (0, _nameTemplates.nameTemplates)('js', this.options),
|
|
31
|
+
// output filename
|
|
32
|
+
chunkFilename: `${name}.[id].js`,
|
|
33
|
+
publicPath: compiler.options.output.publicPath,
|
|
34
|
+
globalObject: "self" // safe for workers too
|
|
35
|
+
|
|
36
|
+
}); // Attach the entry point
|
|
37
|
+
|
|
38
|
+
new _SingleEntryPlugin.default(compiler.context, file, name).apply(childCompiler); // Run the child compiler
|
|
39
|
+
|
|
40
|
+
childCompiler.runAsChild((err, entries, childCompilation) => {
|
|
41
|
+
if (err) {
|
|
42
|
+
compilation.errors.push(err);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (childCompilation.errors && childCompilation.errors.length) {
|
|
47
|
+
compilation.errors.push(...childCompilation.errors);
|
|
48
|
+
} // Files are emitted automatically by child compiler
|
|
49
|
+
// ⚡ Hook HtmlWebpackPlugin and inject this file
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const childChunks = childCompilation.chunks;
|
|
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
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var _default = DummyPlugin;
|
|
82
|
+
exports.default = _default;
|
|
@@ -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;
|
|
@@ -44,18 +44,6 @@ class SourceMapPlugin {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
});
|
|
48
|
-
compilation.hooks.processAssets.tap({
|
|
49
|
-
name: pluginName,
|
|
50
|
-
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
51
|
-
}, assets => {
|
|
52
|
-
Object.keys(assets).forEach(assetName => {
|
|
53
|
-
const assetCode = assets[assetName].source();
|
|
54
|
-
|
|
55
|
-
if (/\.map$/.test(assetName)) {
|
|
56
|
-
compilation.emitAsset(assetName.split('smap/')[1], new RawSource(assetCode));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
47
|
}); // if contenthash enabled we need to add this to include the runtime files
|
|
60
48
|
// compilation.hooks.processAssets.tap(
|
|
61
49
|
// {
|
|
@@ -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 _DummyPlugin = _interopRequireDefault(require("../custom_plugins/DummyPlugin"));
|
|
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([{
|
|
18
|
+
name: "murphy",
|
|
19
|
+
file: _path.default.join(_constants.appPath, "./src/library/murphy/initial_html/index.js")
|
|
20
|
+
}], options);
|
|
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,6 +47,8 @@ var _configBundleIntegrityReport = require("./pluginConfigs/configBundleIntegrit
|
|
|
47
47
|
|
|
48
48
|
var _configRuntimeResourceCleanup = require("./pluginConfigs/configRuntimeResourceCleanup");
|
|
49
49
|
|
|
50
|
+
var _configMurphyInjectorPlugin = require("./pluginConfigs/configMurphyInjectorPlugin");
|
|
51
|
+
|
|
50
52
|
var _configCustomScriptLoadingStrategyPlugin = require("./pluginConfigs/configCustomScriptLoadingStrategyPlugin");
|
|
51
53
|
|
|
52
54
|
// import { IgnorePlugin } from 'webpack';
|
|
@@ -54,5 +56,5 @@ function plugins(options) {
|
|
|
54
56
|
const {
|
|
55
57
|
webpackPlugins
|
|
56
58
|
} = 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, _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), ...webpackPlugins].filter(Boolean);
|
|
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);
|
|
58
60
|
}
|