@salesforce/webapp-template-feature-micro-frontend 1.30.0
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/LICENSE.txt +82 -0
- package/README.md +32 -0
- package/dist/.a4drules/build-validation.md +81 -0
- package/dist/.a4drules/code-quality.md +150 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +227 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +212 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +185 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +205 -0
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +1150 -0
- package/dist/.a4drules/graphql.md +408 -0
- package/dist/.a4drules/images.md +13 -0
- package/dist/.a4drules/react.md +361 -0
- package/dist/.a4drules/react_image_processing.md +45 -0
- package/dist/.a4drules/skills/install-feature/SKILL.md +67 -0
- package/dist/.a4drules/skills/install-feature/scripts/copy-feature-assets.sh +36 -0
- package/dist/.a4drules/typescript.md +224 -0
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +383 -0
- package/dist/README.md +18 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/build/vite.config.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/build/vite.config.js +74 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/e2e/app.spec.ts +24 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/eslint.config.js +113 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/feature-micro-frontend.webapplication-meta.xml +11 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/index.html +13 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/package-lock.json +7157 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/package.json +45 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/playwright.config.ts +24 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/api/graphql-operations-types.ts +127 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/app.tsx +13 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/appLayout.tsx +9 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/pages/About.tsx +12 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/pages/Home.tsx +12 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/routes.tsx +28 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/styles/global.css +13 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/vite.config.ts +83 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-micro-frontend/webapplication.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package.json +38 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +32 -0
- package/skills/micro-frontend/SKILL.md +137 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function Home() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
4
|
+
<div className="text-center">
|
|
5
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Home</h1>
|
|
6
|
+
<p className="text-lg text-gray-600 mb-8">
|
|
7
|
+
Welcome to your React application.
|
|
8
|
+
</p>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
package/dist/force-app/main/default/webapplications/feature-micro-frontend/src/pages/NotFound.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Link } from 'react-router';
|
|
2
|
+
|
|
3
|
+
export default function NotFound() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
6
|
+
<div className="text-center">
|
|
7
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">404</h1>
|
|
8
|
+
<p className="text-lg text-gray-600 mb-8">Page not found</p>
|
|
9
|
+
<Link
|
|
10
|
+
to="/"
|
|
11
|
+
className="inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
|
12
|
+
>
|
|
13
|
+
Go to Home
|
|
14
|
+
</Link>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RouteObject } from 'react-router';
|
|
2
|
+
import AppLayout from '@/appLayout';
|
|
3
|
+
import Home from '@/pages/Home';
|
|
4
|
+
import About from './pages/About';
|
|
5
|
+
import NotFound from './pages/NotFound';
|
|
6
|
+
|
|
7
|
+
export const routes: RouteObject[] = [
|
|
8
|
+
{
|
|
9
|
+
path: '/',
|
|
10
|
+
element: <AppLayout />,
|
|
11
|
+
children: [
|
|
12
|
+
{
|
|
13
|
+
index: true,
|
|
14
|
+
element: <Home />,
|
|
15
|
+
handle: { showInNavigation: true, label: 'Home' },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: 'about',
|
|
19
|
+
element: <About />,
|
|
20
|
+
handle: { showInNavigation: true, label: 'About' },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: '*',
|
|
24
|
+
element: <NotFound />,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
|
|
23
|
+
/* Path mapping */
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": ["./src/*"],
|
|
27
|
+
"@api/*": ["./src/api/*"],
|
|
28
|
+
"@components/*": ["./src/components/*"],
|
|
29
|
+
"@utils/*": ["./src/utils/*"],
|
|
30
|
+
"@styles/*": ["./src/styles/*"],
|
|
31
|
+
"@assets/*": ["./src/assets/*"]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"include": ["src", "vite-env.d.ts", "vitest-env.d.ts"],
|
|
35
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"outDir": "./build"
|
|
11
|
+
},
|
|
12
|
+
"include": ["vite.config.ts"]
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
6
|
+
import salesforce from '@salesforce/vite-plugin-webapp-experimental';
|
|
7
|
+
|
|
8
|
+
export default defineConfig(({ mode }) => {
|
|
9
|
+
return {
|
|
10
|
+
plugins: [tailwindcss(), react(), salesforce()],
|
|
11
|
+
|
|
12
|
+
// Build configuration for MPA
|
|
13
|
+
build: {
|
|
14
|
+
outDir: resolve(__dirname, 'dist'),
|
|
15
|
+
assetsDir: 'assets',
|
|
16
|
+
sourcemap: false,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Resolve aliases (shared between build and test)
|
|
20
|
+
resolve: {
|
|
21
|
+
dedupe: ['react', 'react-dom'],
|
|
22
|
+
alias: {
|
|
23
|
+
'@': path.resolve(__dirname, './src'),
|
|
24
|
+
'@api': path.resolve(__dirname, './src/api'),
|
|
25
|
+
'@components': path.resolve(__dirname, './src/components'),
|
|
26
|
+
'@utils': path.resolve(__dirname, './src/utils'),
|
|
27
|
+
'@styles': path.resolve(__dirname, './src/styles'),
|
|
28
|
+
'@assets': path.resolve(__dirname, './src/assets'),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
// Vitest configuration
|
|
33
|
+
test: {
|
|
34
|
+
// Override root for tests (build uses src/pages as root)
|
|
35
|
+
root: resolve(__dirname),
|
|
36
|
+
|
|
37
|
+
// Use jsdom environment for React component testing
|
|
38
|
+
environment: 'jsdom',
|
|
39
|
+
|
|
40
|
+
// Setup files to run before each test
|
|
41
|
+
setupFiles: ['./src/test/setup.ts'],
|
|
42
|
+
|
|
43
|
+
// Global test patterns
|
|
44
|
+
include: [
|
|
45
|
+
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
46
|
+
'src/**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// Coverage configuration
|
|
50
|
+
coverage: {
|
|
51
|
+
provider: 'v8',
|
|
52
|
+
reporter: ['text', 'html', 'clover', 'json'],
|
|
53
|
+
exclude: [
|
|
54
|
+
'node_modules/',
|
|
55
|
+
'src/test/',
|
|
56
|
+
'src/**/*.d.ts',
|
|
57
|
+
'src/main.tsx',
|
|
58
|
+
'src/vite-env.d.ts',
|
|
59
|
+
'src/components/**/index.ts',
|
|
60
|
+
'**/*.config.ts',
|
|
61
|
+
'build/',
|
|
62
|
+
'dist/',
|
|
63
|
+
'coverage/',
|
|
64
|
+
'eslint.config.js',
|
|
65
|
+
],
|
|
66
|
+
thresholds: {
|
|
67
|
+
global: {
|
|
68
|
+
branches: 85,
|
|
69
|
+
functions: 85,
|
|
70
|
+
lines: 85,
|
|
71
|
+
statements: 85,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
// Test timeout
|
|
77
|
+
testTimeout: 10000,
|
|
78
|
+
|
|
79
|
+
// Globals for easier testing
|
|
80
|
+
globals: true,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/webapp-template-base-sfdx-project-experimental",
|
|
3
|
+
"version": "1.30.0",
|
|
4
|
+
"description": "Base SFDX project template",
|
|
5
|
+
"private": true,
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "echo 'No build required for base-sfdx-project'",
|
|
11
|
+
"clean": "echo 'No clean required for base-sfdx-project'",
|
|
12
|
+
"lint": "eslint **/{aura,lwc}/**/*.js",
|
|
13
|
+
"test": "npm run test:unit",
|
|
14
|
+
"test:unit": "sfdx-lwc-jest -- --passWithNoTests",
|
|
15
|
+
"test:unit:watch": "sfdx-lwc-jest --watch",
|
|
16
|
+
"test:unit:debug": "sfdx-lwc-jest --debug",
|
|
17
|
+
"test:unit:coverage": "sfdx-lwc-jest --coverage",
|
|
18
|
+
"prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
|
|
19
|
+
"prettier:verify": "prettier --check \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
|
|
20
|
+
"precommit": "lint-staged",
|
|
21
|
+
"generate": "node ../../../../micro-frontends/dist/cli.js generate-micro-frontend feature-micro-frontend"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@lwc/eslint-plugin-lwc": "^2.0.0",
|
|
25
|
+
"@prettier/plugin-xml": "^3.2.2",
|
|
26
|
+
"@salesforce/eslint-config-lwc": "^3.2.3",
|
|
27
|
+
"@salesforce/eslint-plugin-aura": "^2.0.0",
|
|
28
|
+
"@salesforce/eslint-plugin-lightning": "^1.0.0",
|
|
29
|
+
"@salesforce/sfdx-lwc-jest": "^7.0.1",
|
|
30
|
+
"eslint": "8.57.1",
|
|
31
|
+
"eslint-plugin-import": "^2.25.4",
|
|
32
|
+
"eslint-plugin-jest": "^28.8.1",
|
|
33
|
+
"husky": "^9.1.5",
|
|
34
|
+
"lint-staged": "^15.1.0",
|
|
35
|
+
"prettier": "^3.1.0",
|
|
36
|
+
"prettier-plugin-apex": "^2.0.1"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Use .apex files to store anonymous Apex.
|
|
2
|
+
// You can execute anonymous Apex in VS Code by selecting the
|
|
3
|
+
// apex text and running the command:
|
|
4
|
+
// SFDX: Execute Anonymous Apex with Currently Selected Text
|
|
5
|
+
// You can also execute the entire file by running the command:
|
|
6
|
+
// SFDX: Execute Anonymous Apex with Editor Contents
|
|
7
|
+
|
|
8
|
+
string tempvar = 'Enter_your_name_here';
|
|
9
|
+
System.debug('Hello World!');
|
|
10
|
+
System.debug('My name is ' + tempvar);
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/webapp-template-feature-micro-frontend",
|
|
3
|
+
"version": "1.30.0",
|
|
4
|
+
"description": "Micro Frontend generation feature for Web Applications",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"skills"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npx tsx ../../cli/src/index.ts apply-patches packages/template/feature/feature-micro-frontend packages/template/base-app/base-react-app packages/template/feature/feature-micro-frontend/dist --reset",
|
|
18
|
+
"postbuild": "node -e \"const fs=require('fs');const p='dist/package.json';const pkg=JSON.parse(fs.readFileSync(p));pkg.scripts.generate='node ../../../../micro-frontends/dist/cli.js generate-micro-frontend feature-micro-frontend';fs.writeFileSync(p,JSON.stringify(pkg,null,2)+'\\n')\"",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"dev": "cd dist/force-app/main/default/webapplications/feature-micro-frontend && npm install && npm run dev",
|
|
21
|
+
"watch": "npx tsx ../../cli/src/index.ts watch-patches packages/template/feature/feature-micro-frontend packages/template/base-app/base-react-app packages/template/feature/feature-micro-frontend/dist"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@salesforce/micro-frontends-experimental": "^1.30.0",
|
|
25
|
+
"@salesforce/webapp-experimental": "^1.30.0",
|
|
26
|
+
"@types/react": "^19.2.7",
|
|
27
|
+
"@types/react-dom": "^19.2.3",
|
|
28
|
+
"react-dom": "^19.2.1",
|
|
29
|
+
"vite": "^7.3.1"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "544598e5263d2ea42f968854afb609359f5053b4"
|
|
32
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: micro-frontends
|
|
3
|
+
description: Generate a Micro Frontend LWC component for a Web Application.
|
|
4
|
+
license: Proprietary. LICENSE.txt has complete terms
|
|
5
|
+
metadata:
|
|
6
|
+
author: salesforce-experience-platform-emu/lwc-admins
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Micro Frontend generation (workflow)
|
|
10
|
+
|
|
11
|
+
When the user wants a Micro Frontend for a Web Application, follow this workflow.
|
|
12
|
+
|
|
13
|
+
## 1. Install the dependency
|
|
14
|
+
|
|
15
|
+
Micro Frontends are generated using the `generate-micro-frontend` CLI command from the `@salesforce/micro-frontends-experimental` package.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @salesforce/micro-frontends-experimental
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The dependency should be added to the project's `package.json` dependencies.
|
|
22
|
+
|
|
23
|
+
## 2. Identify the Web Application
|
|
24
|
+
|
|
25
|
+
- Verify the Web Application exists in `force-app/main/default/webapplications/<web-app-name>/`.
|
|
26
|
+
- Confirm the Web Application has a `lightningOut` target in its `webapplication-meta.xml` file.
|
|
27
|
+
- If no Web Application exists, the user must create one first using the Web Apps template system.
|
|
28
|
+
|
|
29
|
+
## 3. Generate the Micro Frontend component
|
|
30
|
+
|
|
31
|
+
Run the `generate-micro-frontend` command with the Web Application name from the root of an SFDX project:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx generate-micro-frontend <web-app-name>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This creates:
|
|
38
|
+
|
|
39
|
+
- A custom wrapper LWC component in `force-app/main/default/lwc/<webAppName>/`. This is the "Micro Frontend component".
|
|
40
|
+
- The static `microFrontendShell` component that handles iframe communication.
|
|
41
|
+
|
|
42
|
+
Notes:
|
|
43
|
+
|
|
44
|
+
- The command may be added to the project's `package.json` scripts for convenience.
|
|
45
|
+
- The Micro Frontend component uses the Web Application name (e.g. `my-web-app/`) in camelCase for its folder and file names (e.g. `myWebApp/myWebApp.js`, `myWebApp/myWebApp.html`).
|
|
46
|
+
|
|
47
|
+
## 4. Customize the Micro Frontend component metadata
|
|
48
|
+
|
|
49
|
+
Edit the `<webAppName>.js-meta.xml` file to:
|
|
50
|
+
|
|
51
|
+
- Set appropriate `targets` (e.g. `lightning__HomePage`, `lightning__AppPage`, `lightning__RecordPage`, `lightningCommunity__Page`)
|
|
52
|
+
- Add `targetConfigs` for page-specific properties
|
|
53
|
+
- Optionally update the `masterLabel` and `description`
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
|
|
57
|
+
```xml
|
|
58
|
+
<targetConfigs>
|
|
59
|
+
<targetConfig targets="lightning__HomePage">
|
|
60
|
+
<property name="height" type="Integer" min="0" max="600" default="300" />
|
|
61
|
+
</targetConfig>
|
|
62
|
+
</targetConfigs>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 5. Pass properties to the Micro Frontend component
|
|
66
|
+
|
|
67
|
+
Edit the `<webAppName>.js` file to customize the `properties` getter:
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
@api height;
|
|
71
|
+
|
|
72
|
+
@api get properties() {
|
|
73
|
+
return {
|
|
74
|
+
height: this.height,
|
|
75
|
+
// Add any other data your Web Application needs
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
All properties are passed to the embedded Web Application via `postMessage` and can be accessed in the app's code.
|
|
81
|
+
|
|
82
|
+
## 6. Deploy and test
|
|
83
|
+
|
|
84
|
+
Deploy the Micro Frontend component using standard SF CLI commands:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
sf project deploy start --source-dir force-app/main/default
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Add the component to a page using Lightning App Builder or Experience Builder and verify it loads correctly.
|
|
91
|
+
|
|
92
|
+
# Micro Frontend component customization examples
|
|
93
|
+
|
|
94
|
+
## Record page example
|
|
95
|
+
|
|
96
|
+
Command to generate a Micro Frontend component for the `my-site` Web Application:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npx generate-micro-frontend my-site
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`mySite.js-meta.xml` file with a `lightning__RecordPage` target:
|
|
103
|
+
|
|
104
|
+
```xml
|
|
105
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
106
|
+
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
107
|
+
<apiVersion>66.0</apiVersion>
|
|
108
|
+
<isExposed>true</isExposed>
|
|
109
|
+
<masterLabel>Micro Frontend for "My Site"</masterLabel>
|
|
110
|
+
<targets>
|
|
111
|
+
<target>lightning__RecordPage</target>
|
|
112
|
+
</targets>
|
|
113
|
+
<targetConfigs>
|
|
114
|
+
<targetConfig targets="lightning__RecordPage">
|
|
115
|
+
<property name="mode" type="String" default="dark" />
|
|
116
|
+
</targetConfig>
|
|
117
|
+
</targetConfigs>
|
|
118
|
+
</LightningComponentBundle>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`mySite.js` file with public properties and `properties` getter:
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
// Micro Frontend component
|
|
125
|
+
export default class mySite extends LightningElement {
|
|
126
|
+
@api recordId;
|
|
127
|
+
@api mode;
|
|
128
|
+
|
|
129
|
+
@api get properties() {
|
|
130
|
+
// This data is passed to the Micro Frontend
|
|
131
|
+
return {
|
|
132
|
+
recordId: this.recordId, // automatically populated for lightning__RecordPage target
|
|
133
|
+
mode: this.mode, // matches the mode targetConfig
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|