Skip to content

Commit

Permalink
(feat) Attempt to shift performance (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Jul 22, 2024
1 parent 6bad1ba commit f9491ff
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/apps/esm-devtools-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"access": "public"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-help-menu-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"access": "public"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-implementer-tools-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-login-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-offline-tools-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"swr": "^2.2.2"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-primary-navigation-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "*",
"react": "18.x",
"react-dom": "18.x",
Expand Down
1 change: 1 addition & 0 deletions packages/shell/esm-app-shell/dependencies.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"@carbon/react",
"i18next",
"dayjs",
"react",
Expand Down
1 change: 0 additions & 1 deletion packages/shell/esm-app-shell/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@openmrs/esm-styleguide/dist/openmrs-esm-styleguide.css';
import 'import-map-overrides';
import '@openmrs/esm-framework';
import type { SpaConfig } from '@openmrs/esm-framework/src/internal';

function _createSpaBase(baseUrl: string) {
Expand Down
19 changes: 17 additions & 2 deletions packages/shell/esm-app-shell/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ module.exports = (env, argv = {}) => {
],
static: ['src/assets'],
},
watchOptions: {
ignored: ['.git', 'test-results'],
},
mode,
devtool: isProd ? 'hidden-nosources-source-map' : 'eval-source-map',
module: {
Expand Down Expand Up @@ -260,6 +263,12 @@ module.exports = (env, argv = {}) => {
},
],
},
optimization: {
splitChunks: {
maxAsyncRequests: 3,
maxInitialRequests: 1,
},
},
resolve: {
mainFields: ['module', 'main'],
extensions: ['.ts', '.tsx', '.js', '.jsx', '.css', '.scss'],
Expand All @@ -271,7 +280,11 @@ module.exports = (env, argv = {}) => {
url: false,
},
alias: {
'lodash.debounce': 'lodash-es/debounce',
'lodash.findlast': 'lodash-es/findLast',
'lodash.isequal': 'lodash-es/isEqual',
'lodash.omit': 'lodash-es/omit',
'lodash.throttle': 'lodash-es/throttle',
},
},
plugins: [
Expand Down Expand Up @@ -332,14 +345,16 @@ module.exports = (env, argv = {}) => {
}
}

const eager = depName === 'dayjs';

if (depName === 'swr') {
// SWR is annoying with Module Federation
// See: https://github.com/webpack/webpack/issues/16125 and https://github.com/vercel/swr/issues/2356
obj['swr/'] = {
requiredVersion: version,
strictVersion: false,
singleton: true,
eager: true,
eager: false,
import: 'swr/',
shareKey: 'swr/',
shareScope: 'default',
Expand All @@ -350,7 +365,7 @@ module.exports = (env, argv = {}) => {
requiredVersion: version ?? false,
strictVersion: false,
singleton: true,
eager: true,
eager: eager,
import: depName,
shareKey: depName,
shareScope: 'default',
Expand Down
2 changes: 2 additions & 0 deletions packages/tooling/openmrs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"glob": "^7.1.3",
"html-webpack-plugin": "^5.5.0",
"inquirer": "^7.3.3",
"lodash-es": "^4.17.21",
"mini-css-extract-plugin": "^2.4.5",
"node-watch": "^0.7.4",
"npm-registry-fetch": "^14.0.3",
Expand All @@ -70,6 +71,7 @@
"@types/express": "^4.11.1",
"@types/glob": "^7.1.1",
"@types/inquirer": "^6.5.0",
"@types/lodash-es": "^4.17.5",
"@types/node": "^18.11.11",
"@types/pacote": "^11.1.5",
"@types/react": "^18.0.9",
Expand Down
2 changes: 2 additions & 0 deletions packages/tooling/webpack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"css-loader": "^5.2.4",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"sass": ">=1.45.0 <1.65.0",
"sass-loader": "^12.3.0",
"style-loader": "^3.3.1",
Expand All @@ -49,6 +50,7 @@
"webpack": "5.x"
},
"devDependencies": {
"@types/lodash-es": "^4.17.5",
"typescript": "^4.6.4"
}
}
10 changes: 7 additions & 3 deletions packages/tooling/webpack-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@ export default (env: Record<string, string>, argv: Record<string, string> = {})
merge(
{
test: /\.css$/,
use: [require.resolve('style-loader'), cssLoader],
use: ['style-loader', cssLoader],
},
cssRuleConfig,
),
merge(
{
test: /\.s[ac]ss$/i,
use: [
require.resolve('style-loader'),
'style-loader',
cssLoader,
{
loader: require.resolve('sass-loader'),
loader: 'sass-loader',
options: { sassOptions: { quietDeps: true } },
},
],
Expand Down Expand Up @@ -335,7 +335,11 @@ export default (env: Record<string, string>, argv: Record<string, string> = {})
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
alias: {
'@openmrs/esm-framework': '@openmrs/esm-framework/src/internal',
'lodash.debounce': 'lodash-es/debounce',
'lodash.findlast': 'lodash-es/findLast',
'lodash.isequal': 'lodash-es/isEqual',
'lodash.omit': 'lodash-es/omit',
'lodash.throttle': 'lodash-es/throttle',
},
},
...overrides,
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,7 @@ __metadata:
react-i18next: "npm:^11.18.6"
webpack: "npm:^5.88.0"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand Down Expand Up @@ -3199,6 +3200,7 @@ __metadata:
react-i18next: "npm:^11.18.6"
webpack: "npm:^5.88.0"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand All @@ -3224,6 +3226,7 @@ __metadata:
swr: "npm:^2.2.2"
webpack: "npm:^5.88.0"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand All @@ -3250,6 +3253,7 @@ __metadata:
swr: "npm:^2.2.2"
webpack: "npm:^5.88.0"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand Down Expand Up @@ -3290,6 +3294,7 @@ __metadata:
rxjs: "npm:^6.5.3"
swr: "npm:^2.2.2"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand Down Expand Up @@ -3337,6 +3342,7 @@ __metadata:
rxjs: "npm:^6.5.3"
webpack: "npm:^5.88.0"
peerDependencies:
"@carbon/react": 1.x
"@openmrs/esm-framework": "*"
react: 18.x
react-dom: 18.x
Expand Down Expand Up @@ -3494,11 +3500,13 @@ __metadata:
resolution: "@openmrs/webpack-config@workspace:packages/tooling/webpack-config"
dependencies:
"@swc/core": "npm:^1.3.58"
"@types/lodash-es": "npm:^4.17.5"
clean-webpack-plugin: "npm:^4.0.0"
copy-webpack-plugin: "npm:^11.0.0"
css-loader: "npm:^5.2.4"
fork-ts-checker-webpack-plugin: "npm:^6.5.0"
lodash: "npm:^4.17.21"
lodash-es: "npm:^4.17.21"
sass: "npm:>=1.45.0 <1.65.0"
sass-loader: "npm:^12.3.0"
style-loader: "npm:^3.3.1"
Expand Down Expand Up @@ -14250,6 +14258,7 @@ __metadata:
"@types/express": "npm:^4.11.1"
"@types/glob": "npm:^7.1.1"
"@types/inquirer": "npm:^6.5.0"
"@types/lodash-es": "npm:^4.17.5"
"@types/node": "npm:^18.11.11"
"@types/pacote": "npm:^11.1.5"
"@types/react": "npm:^18.0.9"
Expand All @@ -14267,6 +14276,7 @@ __metadata:
glob: "npm:^7.1.3"
html-webpack-plugin: "npm:^5.5.0"
inquirer: "npm:^7.3.3"
lodash-es: "npm:^4.17.21"
mini-css-extract-plugin: "npm:^2.4.5"
node-watch: "npm:^0.7.4"
npm-registry-fetch: "npm:^14.0.3"
Expand Down

0 comments on commit f9491ff

Please sign in to comment.