@centreon/js-config 24.5.0 → 24.5.1

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.
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const { devServer } = require('cypress-rspack-dev-server');
2
3
  const { defineConfig } = require('cypress');
3
4
  const {
4
5
  addMatchImageSnapshotPlugin
@@ -6,22 +7,22 @@ const {
6
7
  const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
7
8
 
8
9
  module.exports = ({
9
- webpackConfig,
10
+ rspackConfig,
10
11
  cypressFolder,
11
12
  specPattern,
12
13
  env,
13
- useVite = false,
14
14
  excludeSpecPattern
15
15
  }) => {
16
16
  const mainCypressFolder = cypressFolder || 'cypress';
17
17
 
18
18
  return defineConfig({
19
19
  component: {
20
- devServer: {
21
- bundler: useVite ? 'vite' : 'webpack',
22
- framework: 'react',
23
- webpackConfig
24
- },
20
+ devServer: (devServerConfig) =>
21
+ devServer({
22
+ ...devServerConfig,
23
+ framework: 'react',
24
+ rspackConfig
25
+ }),
25
26
  excludeSpecPattern,
26
27
  setupNodeEvents: (on, config) => {
27
28
  addMatchImageSnapshotPlugin(on, config);
@@ -38,7 +38,7 @@ export default ({
38
38
 
39
39
  return defineConfig({
40
40
  chromeWebSecurity: false,
41
- defaultCommandTimeout: 6000,
41
+ defaultCommandTimeout: 20000,
42
42
  downloadsFolder: `${resultsFolder}/downloads`,
43
43
  e2e: {
44
44
  excludeSpecPattern: ['*.js', '*.ts', '*.md'],
@@ -66,7 +66,7 @@ export default ({
66
66
  WEB_IMAGE_VERSION: webImageVersion
67
67
  },
68
68
  execTimeout: 60000,
69
- requestTimeout: 10000,
69
+ requestTimeout: 20000,
70
70
  retries: 0,
71
71
  screenshotsFolder: `${resultsFolder}/screenshots`,
72
72
  video: isDevelopment,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "24.5.0",
4
+ "version": "24.5.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -16,13 +16,6 @@
16
16
  "url": "https://github.com/centreon/centreon-frontend/issues"
17
17
  },
18
18
  "homepage": "https://github.com/centreon/centreon-frontend#readme",
19
- "files": [
20
- "eslint",
21
- "jest",
22
- "tsconfig",
23
- "webpack",
24
- "cypress"
25
- ],
26
19
  "peerDependencies": {
27
20
  "eslint": "^8.53.0",
28
21
  "prettier": "^3.0.0"
@@ -1,76 +1,71 @@
1
- const excludeNodeModulesExceptCentreonUi =
2
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
3
-
4
- module.exports = {
5
- cache: false,
6
- excludeNodeModulesExceptCentreonUi,
7
- getModuleConfiguration: (jscTransformConfiguration, enableCoverage) => ({
8
- rules: [
9
- {
10
- parser: { system: false },
11
- test: /\.[cm]?(j|t)sx?$/
12
- },
13
- {
14
- exclude: [excludeNodeModulesExceptCentreonUi],
15
- test: /\.[jt]sx?$/,
16
- use: {
17
- loader: 'swc-loader',
18
- options: {
19
- jsc: {
20
- experimental: {
21
- plugins: [
22
- enableCoverage && ['swc-plugin-coverage-instrument', {}]
23
- ].filter(Boolean)
24
- },
25
- parser: {
26
- syntax: 'typescript',
27
- tsx: true
28
- },
29
- transform: jscTransformConfiguration
30
- }
31
- }
32
- }
33
- },
34
- {
35
- test: /\.icon.svg$/,
36
- use: ['@svgr/webpack']
37
- },
38
- {
39
- exclude: excludeNodeModulesExceptCentreonUi,
40
- test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
41
- use: [
42
- {
43
- loader: 'url-loader',
44
- options: {
45
- limit: 10000,
46
- name: '[name].[hash:8].[ext]'
47
- }
48
- }
49
- ]
50
- },
51
- {
52
- generator: {
53
- filename: '[name][ext]'
54
- },
55
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
56
- type: 'asset/resource'
57
- },
58
- {
59
- test: /\.css$/i,
60
- use: ['style-loader', 'css-loader']
61
- }
62
- ]
63
- }),
64
- optimization: {
65
- splitChunks: {
66
- chunks: 'all',
67
- maxSize: 400 * 1024
68
- }
69
- },
70
- output: {
71
- chunkFilename: '[name].[chunkhash:8].chunk.js',
72
- filename: '[name].[chunkhash:8].js',
73
- libraryTarget: 'umd',
74
- umdNamedDefine: true
75
- }
76
- };
1
+ const isDev = process.env.NODE_ENV !== 'production';
2
+
3
+ const excludeNodeModulesExceptCentreonUi =
4
+ /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
5
+
6
+ module.exports = {
7
+ cache: false,
8
+ excludeNodeModulesExceptCentreonUi,
9
+ getModuleConfiguration: (enableCoverage) => ({
10
+ rules: [
11
+ {
12
+ exclude: [excludeNodeModulesExceptCentreonUi],
13
+ test: /\.[jt]sx?$/,
14
+ use: {
15
+ loader: 'swc-loader',
16
+ options: {
17
+ jsc: {
18
+ experimental: {
19
+ plugins: [
20
+ enableCoverage && ['swc-plugin-coverage-instrument', {}]
21
+ ].filter(Boolean)
22
+ },
23
+ parser: {
24
+ syntax: 'typescript',
25
+ tsx: true
26
+ },
27
+ transform: {
28
+ react: {
29
+ development: isDev,
30
+ refresh: isDev
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ },
37
+ {
38
+ test: /\.icon.svg$/,
39
+ use: ['@svgr/webpack']
40
+ },
41
+ {
42
+ exclude: excludeNodeModulesExceptCentreonUi,
43
+ test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
44
+ type: 'asset/inline'
45
+ },
46
+ {
47
+ generator: {
48
+ filename: '[name][ext]'
49
+ },
50
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
51
+ type: 'asset/resource'
52
+ },
53
+ {
54
+ test: /\.css$/i,
55
+ use: ['style-loader', 'css-loader']
56
+ }
57
+ ]
58
+ }),
59
+ optimization: {
60
+ splitChunks: {
61
+ chunks: 'all',
62
+ maxSize: 400 * 1024
63
+ }
64
+ },
65
+ output: {
66
+ chunkFilename: '[name].[chunkhash:8].chunk.js',
67
+ filename: '[name].[chunkhash:8].js',
68
+ libraryTarget: 'umd',
69
+ umdNamedDefine: true
70
+ }
71
+ };
@@ -1,7 +1,6 @@
1
1
  const path = require('path');
2
2
 
3
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4
- const { ModuleFederationPlugin } = require('webpack').container;
3
+ const rspack = require('@rspack/core');
5
4
 
6
5
  const {
7
6
  getModuleConfiguration,
@@ -13,21 +12,20 @@ const {
13
12
  const getBaseConfiguration = ({
14
13
  moduleName,
15
14
  moduleFederationConfig,
16
- jscTransformConfiguration,
17
15
  enableCoverage
18
16
  }) => ({
19
17
  cache,
20
- module: getModuleConfiguration(jscTransformConfiguration, enableCoverage),
18
+ module: getModuleConfiguration(enableCoverage),
21
19
  optimization,
22
20
  output: {
23
21
  ...output,
22
+ clean: true,
24
23
  library: moduleName,
25
24
  uniqueName: moduleName
26
25
  },
27
26
  plugins: [
28
- new CleanWebpackPlugin(),
29
27
  moduleName &&
30
- new ModuleFederationPlugin({
28
+ new rspack.container.ModuleFederationPlugin({
31
29
  filename: 'remoteEntry.[chunkhash:8].js',
32
30
  library: { name: moduleName, type: 'umd' },
33
31
  name: moduleName,
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ getDevConfiguration: () => ({
3
+ cache: true,
4
+ devtool: 'eval-cheap-module-source-map',
5
+ optimization: {
6
+ splitChunks: false
7
+ },
8
+ output: {
9
+ filename: '[name].js'
10
+ }
11
+ })
12
+ };
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
3
+ const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
4
4
 
5
5
  const devServerPort = 9090;
6
6
 
@@ -19,10 +19,9 @@ const devServerAddress = externalInterface
19
19
 
20
20
  const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
21
21
 
22
- const isServeMode = process.env.WEBPACK_ENV === 'serve';
23
- const isDevelopmentMode = process.env.WEBPACK_ENV === 'development';
22
+ const isDevelopmentMode = process.env.NODE_ENV !== 'production';
24
23
 
25
- const devServerPlugins = isServeMode ? [new ReactRefreshWebpackPlugin()] : [];
24
+ const devServerPlugins = isDevelopmentMode ? [new ReactRefreshPlugin()] : [];
26
25
 
27
26
  module.exports = {
28
27
  devServer: {
@@ -32,6 +31,5 @@ module.exports = {
32
31
  },
33
32
  devServerPlugins,
34
33
  isDevelopmentMode,
35
- isServeMode,
36
34
  publicPath
37
35
  };
@@ -1,5 +1,3 @@
1
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
2
-
3
1
  const WriteRemoteEntryNameToModuleFederation = require('../plugins/WriteRemoteEntryNameToModuleFederation');
4
2
  const TransformPreloadScript = require('../plugins/TransformPreloadScript');
5
3
 
@@ -9,11 +7,6 @@ module.exports = ({ outputPath, federatedComponentConfiguration }) => ({
9
7
  path: outputPath
10
8
  },
11
9
  plugins: [
12
- new CleanWebpackPlugin({
13
- cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
14
- dangerouslyAllowCleanPatternsOutsideProject: true,
15
- dry: false
16
- }),
17
10
  new WriteRemoteEntryNameToModuleFederation(federatedComponentConfiguration),
18
11
  new TransformPreloadScript(federatedComponentConfiguration)
19
12
  ]
@@ -8,7 +8,7 @@ module.exports = class TransformPreloadScript {
8
8
  }
9
9
 
10
10
  apply(compiler) {
11
- compiler.hooks.done.tap('CentreonModulePlugin', () => {
11
+ compiler.hooks.done.tap('TransformPreloadScript', () => {
12
12
  if (!fs.existsSync(compiler.options.output.path)) {
13
13
  fs.mkdirSync(compiler.options.output.path, { recursive: true });
14
14
  }
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "./tsconfig/index.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "./",
5
+ "outDir": "./dist",
6
+ "declaration": true,
7
+ "skipLibCheck": true,
8
+ "pretty": true,
9
+ "emitDeclarationOnly": true,
10
+ "types": ["cypress", "cypress-wait-until"],
11
+ "esModuleInterop": true,
12
+ "paths": {
13
+ "@badeball/cypress-cucumber-preprocessor/*": ["./node_modules/@badeball/cypress-cucumber-preprocessor/dist/subpath-entrypoints/*"]
14
+ }
15
+ },
16
+ "exclude": [
17
+ "./node_modules",
18
+ "./dist",
19
+ "../../node_modules"
20
+ ],
21
+ }
@@ -1,24 +0,0 @@
1
- module.exports = {
2
- devJscTransformConfiguration: {
3
- react: {
4
- development: true,
5
- refresh: false,
6
- },
7
- },
8
- devRefreshJscTransformConfiguration: {
9
- react: {
10
- development: true,
11
- refresh: true,
12
- },
13
- },
14
- getDevConfiguration: () => ({
15
- cache: true,
16
- devtool: 'eval-cheap-module-source-map',
17
- optimization: {
18
- splitChunks: false,
19
- },
20
- output: {
21
- filename: '[name].js',
22
- },
23
- }),
24
- };