Skip to content

Commit 0fbbe7a

Browse files
authored
feat: integrate the frontend shared libraries (#552)
Signed-off-by: Guilherme Caponetto <[email protected]>
1 parent d5652e6 commit 0fbbe7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3183
-2613
lines changed

workspaces/frontend/.env

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
LOGO=logo-light-theme.svg
2-
LOGO_DARK=logo-dark-theme.svg
1+
IS_PROJECT_ROOT_DIR=false
2+
PORT=${FRONTEND_PORT}
3+
4+
########## Change the following variables to customize the Dashboard ##########
35
FAVICON=favicon.ico
46
PRODUCT_NAME="Notebooks"
7+
KUBEFLOW_USERNAME=[email protected]
8+
COMPANY_URI=oci://kubeflow.io

workspaces/frontend/.env.cypress.mock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ BASE_URL=http://localhost:9001
33
DEPLOYMENT_MODE=standalone
44
POLL_INTERVAL=9999999
55
DIST_DIR=./dist
6-
URL_PREFIX=/
6+
URL_PREFIX=
77
PUBLIC_PATH=/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
APP_ENV=development
22
DEPLOYMENT_MODE=standalone
33
MOCK_API_ENABLED=true
4+
MANDATORY_NAMESPACE=workspace-test-1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { ModuleFederationPlugin } = require('@module-federation/enhanced/webpack');
2+
3+
const deps = require('../package.json').dependencies;
4+
5+
const moduleFederationConfig = {
6+
name: 'notebooks',
7+
filename: 'remoteEntry.js',
8+
9+
shared: {
10+
react: { singleton: true, eager: true, requiredVersion: deps.react },
11+
'react-dom': { singleton: true, eager: true, requiredVersion: deps['react-dom'] },
12+
'react-router': { singleton: true, eager: true, requiredVersion: deps['react-router'] },
13+
'react-router-dom': { singleton: true, eager: true, requiredVersion: deps['react-router-dom'] },
14+
},
15+
exposes: {
16+
// TODO expose api. eg:
17+
// './index': './src/plugin/index.tsx',
18+
// './plugin': './src/plugin/index.tsx',
19+
},
20+
// For module federation to work when optimization.runtimeChunk="single":
21+
// See https://github.com/webpack/webpack/issues/18810
22+
runtime: false,
23+
// TODO generate types when exposing api
24+
dts: false,
25+
};
26+
27+
module.exports = {
28+
moduleFederationPlugins: [new ModuleFederationPlugin(moduleFederationConfig)],
29+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
process(_src, filename) {
5+
const assetFilename = JSON.stringify(path.basename(filename));
6+
return `module.exports = ${assetFilename};`;
7+
},
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

workspaces/frontend/config/webpack.common.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const CopyPlugin = require('copy-webpack-plugin');
44
const { setupWebpackDotenvFilesForEnv } = require('./dotenv');
55
const { name } = require('../package.json');
66

7+
const { moduleFederationPlugins } = require('./moduleFederation');
8+
79
const RELATIVE_DIRNAME = process.env._RELATIVE_DIRNAME;
810
const IS_PROJECT_ROOT_DIR = process.env._IS_PROJECT_ROOT_DIR;
911
const IMAGES_DIRNAME = process.env._IMAGES_DIRNAME;
@@ -180,6 +182,7 @@ module.exports = (env) => ({
180182
uniqueName: name,
181183
},
182184
plugins: [
185+
...moduleFederationPlugins,
183186
...setupWebpackDotenvFilesForEnv({
184187
directory: RELATIVE_DIRNAME,
185188
isRoot: IS_PROJECT_ROOT_DIR,

workspaces/frontend/config/webpack.dev.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ module.exports = smp.wrap(
100100
],
101101
devMiddleware: {
102102
stats: 'errors-only',
103+
publicPath: BASE_PATH,
103104
},
104105
client: {
105106
overlay: false,
@@ -127,6 +128,10 @@ module.exports = smp.wrap(
127128
SRC_DIR,
128129
COMMON_DIR,
129130
path.resolve(RELATIVE_DIRNAME, 'node_modules/@patternfly'),
131+
path.resolve(
132+
RELATIVE_DIRNAME,
133+
'node_modules/mod-arch-shared/node_modules/@patternfly',
134+
),
130135
],
131136
use: ['style-loader', 'css-loader'],
132137
},

workspaces/frontend/config/webpack.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = merge(
5252
SRC_DIR,
5353
COMMON_DIR,
5454
path.resolve(RELATIVE_DIRNAME, 'node_modules/@patternfly'),
55+
path.resolve(RELATIVE_DIRNAME, 'node_modules/mod-arch-shared/node_modules/@patternfly'),
5556
],
5657
use: [MiniCssExtractPlugin.loader, 'css-loader'],
5758
},

workspaces/frontend/jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ module.exports = {
2626
testEnvironment: 'jest-environment-jsdom',
2727

2828
// include projects from node_modules as required
29-
transformIgnorePatterns: ['node_modules/(?!yaml|lodash-es|uuid|@patternfly|delaunator)'],
29+
transformIgnorePatterns: [
30+
'node_modules/(?!yaml|lodash-es|uuid|@patternfly|delaunator|mod-arch-shared|mod-arch-core|mod-arch-kubeflow)',
31+
],
3032

3133
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
3234
snapshotSerializers: [],
3335

3436
setupFilesAfterEnv: ['<rootDir>/src/__tests__/unit/jest.setup.ts'],
3537

36-
preset: 'ts-jest',
37-
3838
coverageDirectory: 'jest-coverage',
3939

4040
collectCoverageFrom: [

0 commit comments

Comments
 (0)