@centreon/js-config 24.4.30 → 24.4.32
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/package.json
CHANGED
package/webpack/patch/module.js
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
1
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
7
|
-
}
|
|
3
|
+
const WriteRemoteEntryNameToModuleFederation = require('../plugins/WriteRemoteEntryNameToModuleFederation');
|
|
4
|
+
const TransformPreloadScript = require('../plugins/TransformPreloadScript');
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
|
|
11
|
-
const newFederatedComponentConfiguration = {
|
|
12
|
-
...this.federatedComponentConfiguration,
|
|
13
|
-
remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
|
|
14
|
-
assetName.match(/(^remoteEntry)\S+.js$/),
|
|
15
|
-
),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
if (!fs.existsSync(compiler.options.output.path)) {
|
|
19
|
-
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(
|
|
23
|
-
`${compiler.options.output.path}/moduleFederation.json`,
|
|
24
|
-
JSON.stringify(newFederatedComponentConfiguration, null, 2),
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = ({
|
|
31
|
-
outputPath,
|
|
32
|
-
federatedComponentConfiguration,
|
|
33
|
-
}) => ({
|
|
6
|
+
module.exports = ({ outputPath, federatedComponentConfiguration }) => ({
|
|
34
7
|
output: {
|
|
35
8
|
library: '[chunkhash:8]',
|
|
36
|
-
path: outputPath
|
|
9
|
+
path: outputPath
|
|
37
10
|
},
|
|
38
11
|
plugins: [
|
|
39
12
|
new CleanWebpackPlugin({
|
|
40
13
|
cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
|
|
41
14
|
dangerouslyAllowCleanPatternsOutsideProject: true,
|
|
42
|
-
dry: false
|
|
15
|
+
dry: false
|
|
43
16
|
}),
|
|
44
|
-
new
|
|
45
|
-
|
|
17
|
+
new WriteRemoteEntryNameToModuleFederation(federatedComponentConfiguration),
|
|
18
|
+
new TransformPreloadScript(federatedComponentConfiguration)
|
|
19
|
+
]
|
|
46
20
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const swc = require('@swc/core');
|
|
4
|
+
|
|
5
|
+
module.exports = class TransformPreloadScript {
|
|
6
|
+
constructor(federatedComponentConfiguration) {
|
|
7
|
+
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
compiler.hooks.done.tap('CentreonModulePlugin', () => {
|
|
12
|
+
if (!fs.existsSync(compiler.options.output.path)) {
|
|
13
|
+
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (this.federatedComponentConfiguration.preloadScript) {
|
|
17
|
+
const { code } = swc.transformFileSync(
|
|
18
|
+
`./${this.federatedComponentConfiguration.preloadScript}.ts`,
|
|
19
|
+
{
|
|
20
|
+
filename: `${this.federatedComponentConfiguration.preloadScript}.ts`,
|
|
21
|
+
jsc: {
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: 'typescript'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
minify: true
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
`${compiler.options.output.path}/${this.federatedComponentConfiguration.preloadScript}.js`,
|
|
32
|
+
code
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
module.exports = class WriteRemoteEntryNameToModuleFederation {
|
|
4
|
+
constructor(federatedComponentConfiguration) {
|
|
5
|
+
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
compiler.hooks.done.tap(
|
|
10
|
+
'WriteRemoteEntryNameToModuleFederation',
|
|
11
|
+
(stats) => {
|
|
12
|
+
const newFederatedComponentConfiguration = {
|
|
13
|
+
...this.federatedComponentConfiguration,
|
|
14
|
+
remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
|
|
15
|
+
assetName.match(/(^remoteEntry)\S+.js$/)
|
|
16
|
+
)
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(compiler.options.output.path)) {
|
|
20
|
+
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
`${compiler.options.output.path}/moduleFederation.json`,
|
|
25
|
+
JSON.stringify(newFederatedComponentConfiguration, null, 2)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
};
|