@equinor/fusion-framework-vite-plugin-spa 3.1.12-next.0 → 4.0.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/CHANGELOG.md CHANGED
@@ -1,17 +1,42 @@
1
1
  # @equinor/fusion-framework-vite-plugin-spa
2
2
 
3
- ## 3.1.12-next.0
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - abffa53: Major version bump for Fusion Framework React 19 release.
8
+
9
+ All packages are bumped to the next major version as part of the React 19 upgrade. This release drops support for React versions below 18 and includes breaking changes across the framework.
10
+
11
+ **Breaking changes:**
12
+ - Peer dependencies now require React 18 or 19 (`^18.0.0 || ^19.0.0`)
13
+ - React Router upgraded from v6 to v7
14
+ - Navigation module refactored with new history API
15
+ - `renderComponent` and `renderApp` now use `createRoot` API
16
+
17
+ **Migration:**
18
+ - Update your React version to 18.0.0 or higher before upgrading
19
+ - Replace `NavigationProvider.createRouter()` with `@equinor/fusion-framework-react-router`
20
+ - See individual package changelogs for package-specific migration steps
4
21
 
5
22
  ### Patch Changes
6
23
 
7
- - [#3820](https://github.com/equinor/fusion-framework/pull/3820) [`f647825`](https://github.com/equinor/fusion-framework/commit/f647825cb5712763b09dafda21fd996211c78b78) Thanks [@odinr](https://github.com/odinr)! - relase next
24
+ - 32bcf83: Bump `vite` from `7.3.1` to `8.0.0`.
25
+
26
+ Vite 8 replaces Rollup with Rolldown and esbuild with Oxc for faster builds.
27
+ No breaking API changes affect this codebase. The `dev-server` peerDependency
28
+ is widened to accept both Vite 7 and Vite 8.
8
29
 
9
- - Updated dependencies [[`f647825`](https://github.com/equinor/fusion-framework/commit/f647825cb5712763b09dafda21fd996211c78b78)]:
10
- - @equinor/fusion-framework-module-telemetry@4.6.5-next.0
11
- - @equinor/fusion-framework-module-http@7.0.9-next.0
12
- - @equinor/fusion-framework-module@5.0.7-next.0
13
- - @equinor/fusion-framework-module-msal@7.3.2-next.0
14
- - @equinor/fusion-framework-module-service-discovery@9.1.2-next.0
30
+ - Updated dependencies [abffa53]
31
+ - Updated dependencies [abffa53]
32
+ - Updated dependencies [abffa53]
33
+ - Updated dependencies [8f30948]
34
+ - Updated dependencies [abffa53]
35
+ - @equinor/fusion-framework-module@6.0.0
36
+ - @equinor/fusion-framework-module-http@8.0.0
37
+ - @equinor/fusion-framework-module-msal@8.0.0
38
+ - @equinor/fusion-framework-module-service-discovery@10.0.0
39
+ - @equinor/fusion-framework-module-telemetry@5.0.0
15
40
 
16
41
  ## 3.1.11
17
42
 
package/README.md CHANGED
@@ -1,59 +1,64 @@
1
1
  ---
2
2
  title: Fusion Framework Vite SPA Plugin
3
3
  description: >
4
- A powerful Vite plugin for building Single Page Applications (SPAs) with the Fusion Framework. It automates HTML template generation, bootstraps authentication and service discovery, and streamlines portal loading and API proxying. Designed for seamless integration with the Fusion Framework CLI, this plugin provides flexible configuration for both standard and advanced SPA scenarios.
4
+ Vite plugin for building Fusion Framework Single Page Applications.
5
+ Automates HTML template generation, MSAL authentication bootstrapping,
6
+ service discovery wiring, portal manifest loading, and authenticated
7
+ API proxying via a service worker.
5
8
  tags:
6
9
  - fusion-framework
10
+ - vite-plugin
7
11
  - cli
8
12
  - app-development
9
13
  - portal-development
10
14
  - dev-server
11
15
  - authentication
12
- - configuration
13
16
  - service-discovery
17
+ - service-worker
14
18
  - equinor
15
19
  - non-production
16
- - documentation
17
20
  keywords:
21
+ - '@equinor/fusion-framework-vite-plugin-spa'
18
22
  - fusion-framework
19
23
  - vite
20
24
  - spa
21
25
  - plugin
22
26
  - development
23
27
  - non-production
28
+ - msal
29
+ - service-worker
30
+ - portal
24
31
  ---
25
32
 
26
- # Fusion Framework Vite SPA Plugin
33
+ # @equinor/fusion-framework-vite-plugin-spa
27
34
 
28
35
  [![npm version](https://img.shields.io/npm/v/@equinor/fusion-framework-vite-plugin-spa.svg?style=flat)](https://www.npmjs.com/package/@equinor/fusion-framework-vite-plugin-spa)
29
36
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](./LICENSE)
30
37
 
31
- A powerful Vite plugin for building Single Page Applications (SPAs) with the Fusion Framework. It automates HTML template generation, bootstraps authentication and service discovery, and streamlines portal loading and API proxying. Designed for seamless integration with the Fusion Framework CLI, this plugin provides flexible configuration for both standard and advanced SPA scenarios.
38
+ Vite plugin for building Fusion Framework Single Page Applications (SPAs). It generates an HTML shell, bootstraps MSAL authentication and service discovery, loads a portal by manifest, and registers a service worker that injects Bearer tokens into outgoing API requests.
32
39
 
33
- > [!CAUTION]
34
- > This plugin is intended for use in non-production environments only.
40
+ > [!CAUTION]
41
+ > This plugin is intended for **non-production development environments** only.
35
42
 
36
43
  > [!WARNING]
37
- > This plugin is developed for usage with [`@equinor/fusion-framework-cli`](https://github.com/equinor/fusion-framework/tree/main/packages/cli) and this documentation is intended for deeper understanding of the plugin's capabilities and configuration options.
44
+ > This plugin is designed for use with [`@equinor/fusion-framework-cli`](https://github.com/equinor/fusion-framework/tree/main/packages/cli). The CLI scaffolds all required configuration automatically.
38
45
  >
39
- > **NOTE:** _Just because there are buttons available doesn't mean you need to press them 🐒_
40
- >
41
- > The plugin is written in a modular fashion, allowing for easy customization and extension __IF__ the developer has a deep understanding of the Fusion Framework and its internals.
46
+ > Standalone usage is an advanced scenario that requires deep understanding of the Fusion Framework internals. The documentation below covers the full configuration surface for those who need it.
42
47
 
43
48
  ## What It Does
44
49
 
45
- The plugin:
46
-
47
- 1. **Bootstraps the Fusion Framework** - Initializes core modules including MSAL authentication and service discovery
48
- 2. **Renders a Configured Portal** - Loads and renders any portal by ID, as long as it exports a render function
49
- 3. **Registers a Service Worker** - Enables authenticated API requests by automatically injecting auth tokens
50
- 4. **Configures Development Environment** - Works with `plugin-api-service` to intercept and proxy authenticated requests during development
50
+ | Responsibility | Description |
51
+ | --- | --- |
52
+ | **Bootstrap the Fusion Framework** | Initializes MSAL authentication, service discovery, and telemetry modules |
53
+ | **Render a configured portal** | Fetches a portal manifest by ID and loads its entry point |
54
+ | **Register a service worker** | Intercepts fetch requests, rewrites URLs, and attaches OAuth Bearer tokens |
55
+ | **Configure the dev environment** | Works with `@equinor/fusion-framework-vite-plugin-api-service` to proxy authenticated requests during development |
51
56
 
52
57
  > [!TIP]
53
- > The plugin will render the configured portal which can be sourced from:
54
- > - A local npm package (like `@equinor/fusion-framework-dev-portal`, the default used by CLI)
55
- > - The Fusion Portal Service (using a portal identifier)
56
- > - Any custom portal implementation configured in your environment
58
+ > The portal to render can be sourced from:
59
+ > - A **local npm package** (e.g. `@equinor/fusion-framework-dev-portal`, the default used by CLI)
60
+ > - The **Fusion Portal Service** (using a portal identifier)
61
+ > - Any **custom portal** implementation that exports a `render` function
57
62
 
58
63
  ## How the Plugin Works
59
64
 
@@ -86,21 +91,61 @@ flowchart
86
91
  ## Getting Started
87
92
 
88
93
  > [!WARNING]
89
- > This plugin is primarily designed to be used with the [Fusion Framework CLI](https://github.com/equinor/fusion-framework-cli). The CLI scaffolds all required configuration and wiring for you.
94
+ > This plugin is primarily designed to be used with the [Fusion Framework CLI](https://github.com/equinor/fusion-framework-cli). The CLI scaffolds all required configuration and wiring automatically.
90
95
 
91
- **Standalone usage is advanced:** If you use this plugin outside the CLI, you must provide detailed configuration for authentication, service discovery, portal loading, and more. There is no "one-line" quick start for custom setups. See the [Basic Configuration](#basic-configuration) and [Configuration Options](#configuration-options) sections below.
96
+ Standalone usage requires you to supply authentication, service discovery, portal loading, and service worker configuration yourself. See [Configuration Options](#configuration-options) below.
92
97
 
93
- > [!NOTE]
94
- > This plugin should cover most use cases for building SPAs with the Fusion Framework, but advanced configurations may require additional setup.
95
- > If for some reason you are adventurous enough to write your custom implementation of developer utilities, this guide should help you get started.
98
+ ### Installation
99
+
100
+ ```sh
101
+ pnpm add -D @equinor/fusion-framework-vite-plugin-spa
102
+ ```
103
+
104
+ ### Minimal Vite Config
105
+
106
+ ```ts
107
+ // vite.config.ts
108
+ import { defineConfig } from 'vite';
109
+ import { fusionSpaPlugin } from '@equinor/fusion-framework-vite-plugin-spa';
110
+
111
+ export default defineConfig({
112
+ plugins: [
113
+ fusionSpaPlugin({
114
+ generateTemplateEnv: () => ({
115
+ title: 'My App',
116
+ portal: { id: 'my-portal' },
117
+ serviceDiscovery: {
118
+ url: 'https://my-server.com/service-discovery',
119
+ scopes: ['api://my-app/scope'],
120
+ },
121
+ msal: {
122
+ tenantId: 'my-tenant-id',
123
+ clientId: 'my-client-id',
124
+ redirectUri: 'http://localhost:3000/auth-callback',
125
+ requiresAuth: 'true',
126
+ },
127
+ }),
128
+ }),
129
+ ],
130
+ });
131
+ ```
96
132
 
97
133
  ## Configuration Options
98
134
 
99
- The plugin accepts a variety of configuration options to tailor the SPA to your project's needs. These options control authentication flows, service discovery, and routing behaviors.
135
+ The `fusionSpaPlugin` (also exported as `plugin`) accepts a `PluginOptions` object with the following properties:
136
+
137
+ | Option | Type | Default | Description |
138
+ | --- | --- | --- | --- |
139
+ | `template` | `string` | Built-in HTML | Custom HTML template string with `%VAR%` placeholders |
140
+ | `templateEnvPrefix` | `string` | `'FUSION_SPA_'` | Prefix for environment variable names |
141
+ | `generateTemplateEnv` | `(env: ConfigEnv) => Partial<TemplateEnv>` | — | Factory producing environment values |
142
+ | `logger` | `Pick<Console, 'debug'\|'info'\|'warn'\|'error'>` | — | Optional logger for plugin diagnostics |
100
143
 
101
- ### Basic Configuration
144
+ ### Template Environment (`generateTemplateEnv`)
102
145
 
103
- Here's a comprehensive example showing all major configuration options:
146
+ The `generateTemplateEnv` callback returns an object whose shape matches `FusionTemplateEnv`. All properties are flattened to `FUSION_SPA_*` environment variables at build time.
147
+
148
+ Here's a comprehensive example:
104
149
 
105
150
  ```ts
106
151
  fusionSpaPlugin({
@@ -180,32 +225,28 @@ See [@equinor/fusion-framework-vite-plugin-api-service](https://github.com/equin
180
225
 
181
226
  ### Service Discovery
182
227
 
183
- The Service Discovery component provides a dynamic way to discover and connect to backend services. It's a crucial part of the Fusion Framework architecture that helps applications locate and communicate with various microservices.
184
-
185
- **Configuration Options:**
186
-
187
- - `url`: The endpoint URL where the service discovery configuration can be fetched from
188
- - `scopes`: Array of OAuth scopes required to authenticate service discovery requests
228
+ Configures the endpoint the Fusion Framework uses to discover backend service URLs at runtime.
189
229
 
190
- **Benefits:**
191
- - Eliminates hardcoded service endpoints in your application
192
- - Enables dynamic service routing based on environment
193
- - Centralizes service endpoint management
230
+ - `url` — Endpoint URL of the service discovery configuration
231
+ - `scopes` OAuth scopes required to authenticate requests to the service discovery endpoint
194
232
 
195
- ### MSAL
233
+ ### MSAL Authentication
196
234
 
197
- The Microsoft Authentication Library (MSAL) configuration handles user authentication with Azure Active Directory. This enables single sign-on capabilities and secure access to protected resources.
235
+ Configures Azure AD authentication via the Microsoft Authentication Library (MSAL).
198
236
 
199
- **Configuration Options:**
237
+ - `tenantId` — Azure AD tenant identifier
238
+ - `clientId` — Application (client) ID registered in Azure AD
239
+ - `redirectUri` — URL to redirect to after authentication
240
+ - `requiresAuth` _(optional, string)_ — When `'true'`, automatically prompts for login on first load
200
241
 
201
- - `tenantId`: The Azure AD tenant ID associated with your organization
202
- - `clientId`: The client/application ID registered in Azure AD
203
- - `redirectUri`: The URL where users are redirected after authentication
204
- - `requiresAuth` _(optional)_: When set to "true", the application will automatically prompt for login on initial load
242
+ - `tenantId` Azure AD tenant identifier
243
+ - `clientId` Application (client) ID registered in Azure AD
244
+ - `redirectUri` URL to redirect to after authentication
245
+ - `requiresAuth` _(optional, string)_ When `'true'`, automatically prompts for login on first load
205
246
 
206
247
  ### Service Worker
207
248
 
208
- The Service Worker component provides powerful capabilities for handling network requests, adding authentication, and enabling offline capabilities in your SPA.
249
+ The service worker intercepts outgoing fetch requests, matches them against configured `ResourceConfiguration` patterns, optionally rewrites the URL, and attaches a Bearer token.
209
250
 
210
251
  #### How It Works
211
252
 
@@ -229,19 +270,21 @@ sequenceDiagram
229
270
  end
230
271
  ```
231
272
 
232
- The Service Worker intercepts network requests made by your application and can modify them before they're sent. This is particularly useful for:
273
+ The Service Worker intercepts network requests and can:
274
+
275
+ 1. Attach OAuth Bearer tokens to matched requests
276
+ 2. Rewrite request URLs for proxying
277
+ 3. Pass unmatched requests through unmodified
233
278
 
234
- 1. Adding authentication tokens automatically to API calls
235
- 2. Rewriting request URLs for proxying purposes
236
- 3. Enabling offline functionality
237
- 4. Improving performance through caching
279
+ #### Resource Configuration
238
280
 
239
- #### Configuration Options
281
+ Each entry in the `resources` array is a `ResourceConfiguration` object:
240
282
 
241
- - `resources`: An array of resource configurations the service worker will manage
242
- - `url`: Path pattern to match incoming requests against
243
- - `rewrite` _(optional)_: Path to rewrite the matched URL to
244
- - `scopes` _(optional)_: OAuth scopes to use for authenticating this resource
283
+ | Property | Type | Description |
284
+ | --- | --- | --- |
285
+ | `url` | `string` | Path prefix to match against fetch requests |
286
+ | `rewrite` | `string?` | Replacement path prefix for matched requests |
287
+ | `scopes` | `string[]?` | OAuth scopes to acquire a Bearer token for matched requests |
245
288
 
246
289
  #### Complete Example
247
290
 
@@ -285,60 +328,37 @@ When the above `fetch` request is made, the following happens:
285
328
 
286
329
  ## Telemetry
287
330
 
288
- The Fusion Framework SPA plugin includes built-in telemetry configuration that automatically sets up console logging for development and debugging purposes. The plugin uses the `@equinor/fusion-framework-module-telemetry` module to provide structured logging with different severity levels.
331
+ The plugin configures console telemetry via `@equinor/fusion-framework-module-telemetry`. Severity levels map to integers:
289
332
 
290
- ### Telemetry Levels
333
+ | Level | Value | Description |
334
+ | --- | --- | --- |
335
+ | Debug | 0 | Detailed debugging information |
336
+ | Information | 1 | General operational information |
337
+ | Warning | 2 | Potential issues that are not critical |
338
+ | Error | 3 | Errors that do not prevent continued operation |
339
+ | Critical | 4 | Severe errors that may halt functionality |
291
340
 
292
- The telemetry system supports the following severity levels (ordered from lowest to highest):
341
+ ### Controlling Console Output
293
342
 
294
- - **Debug** (0): Debugging information useful during development
295
- - **Information** (1): General information about the system's operation
296
- - **Warning** (2): Indicates a potential issue that is not critical
297
- - **Error** (3): Represents an error that has occurred, but the system can continue running
298
- - **Critical** (4): A severe error that may cause the system to stop functioning
343
+ Set `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL` to the minimum level to display. Default is `1` (Information).
299
344
 
300
- ### Console Logging
301
-
302
- By default, the plugin enables console logging for all telemetry events. You can control the minimum log level displayed in the console using the `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL` environment variable.
303
-
304
- ```typescript
305
- // Environment variable configuration
306
- FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=2 // Only show Warning, Error, and Critical events
345
+ ```sh
346
+ FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=2 # Warning and above
307
347
  ```
308
348
 
309
- When set to a valid number, only telemetry items with a level **greater than or equal to** the specified value will be logged to the console. For example:
310
- - `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=0` → Shows all telemetry events (Debug, Information, Warning, Error, Critical)
311
- - `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=1` → Shows Information, Warning, Error, and Critical events
312
- - `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=2` → Shows Warning, Error, and Critical events
349
+ For advanced telemetry (e.g. Application Insights), provide a [custom bootstrap file](#providing-custom-bootstrap).
313
350
 
314
- If the environment variable is not set, the default is `FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=1` (Information level and above). If the environment variable contains an invalid value, all telemetry events will be logged to the console.
351
+ ## Configuring through `.env` Files
315
352
 
316
- ### Custom Telemetry Configuration
317
-
318
- For advanced telemetry setup (such as Application Insights integration), you can customize the telemetry configuration by providing a custom bootstrap file. See the [Providing Custom Bootstrap](#providing-custom-bootstrap) section for details.
319
-
320
- ## Configuring through `.env` File
321
-
322
- For greater flexibility—especially in CI/CD pipelines and deployment scenarios—the plugin supports configuration through environment variables in a `.env` file.
323
-
324
- ### How Environment Variables Work
325
-
326
- The plugin reads the `.env` file and overrides any properties defined in the `generateTemplateEnv` function with the corresponding environment variables. This approach allows you to:
327
-
328
- - Maintain different configurations for development, testing, and production
329
- - Keep sensitive information out of your source code
330
- - Override configuration values during deployment pipelines
353
+ The plugin reads environment variables from `.env` files (via Vite's `loadEnv`) and **merges them on top of** values from `generateTemplateEnv`. This lets you keep secrets and per-environment values out of source code.
331
354
 
332
355
  ### Naming Convention
333
356
 
334
- Environment variables follow a specific naming pattern:
335
- 1. All variables are prefixed with `FUSION_SPA_`
336
- 2. Object paths are converted to snake case with underscores
337
- 3. Arrays and objects are serialized as JSON strings
357
+ 1. Prefix all variables with `FUSION_SPA_` (or your custom `templateEnvPrefix`).
358
+ 2. Convert nested object paths to `UPPER_SNAKE_CASE` (e.g. `serviceDiscovery.url` → `FUSION_SPA_SERVICE_DISCOVERY_URL`).
359
+ 3. Serialize arrays and objects as JSON strings.
338
360
 
339
- ### Example Conversion
340
-
341
- Here's how JavaScript configuration objects map to environment variables:
361
+ ### Mapping Example
342
362
 
343
363
  ```ts
344
364
  // JavaScript configuration
@@ -358,45 +378,45 @@ import.meta.env.FUSION_SPA_SERVICE_WORKER_RESOURCES
358
378
  ### Complete `.env` Example
359
379
 
360
380
  ```sh
361
- # Application basics
381
+ # Page title
362
382
  FUSION_SPA_TITLE=My App
363
- FUSION_SPA_PORTAL_ID=my-portal # Can be a package name, Fusion Portal Service ID, or any configured portal ID
364
- FUSION_SPA_PORTAL_TAG=latest # (Optional) Version tag (defaults to 'latest')
365
- FUSION_SPA_PORTAL_PROXY=false # (Optional) Whether to proxy portal requests through /portal-proxy (defaults to false)
366
383
 
367
- # Service Discovery configuration
384
+ # Portal manifest
385
+ FUSION_SPA_PORTAL_ID=my-portal
386
+ FUSION_SPA_PORTAL_TAG=latest
387
+ FUSION_SPA_PORTAL_PROXY=false
388
+
389
+ # Service Discovery
368
390
  FUSION_SPA_SERVICE_DISCOVERY_URL=https://my-server.com/service-discovery
369
391
  FUSION_SPA_SERVICE_DISCOVERY_SCOPES=[api://my-app/scope]
370
392
 
371
- # MSAL Authentication configuration
393
+ # MSAL
372
394
  FUSION_SPA_MSAL_TENANT_ID=my-tenant-id
373
395
  FUSION_SPA_MSAL_CLIENT_ID=my-client-id
374
396
  FUSION_SPA_MSAL_REDIRECT_URI=https://my-app.com/auth-callback
375
397
  FUSION_SPA_MSAL_REQUIRES_AUTH=true
376
398
 
377
- # Telemetry configuration
378
- FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=2 # Only log Warning, Error, and Critical events to console
399
+ # Telemetry
400
+ FUSION_SPA_TELEMETRY_CONSOLE_LEVEL=2
379
401
 
380
- # Service Worker configuration (as JSON string)
402
+ # Service Worker (JSON string)
381
403
  FUSION_SPA_SERVICE_WORKER_RESOURCES=[{"url":"/app-proxy","rewrite":"/@fusion-api/app","scopes":["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/.default"]}]
382
404
  ```
383
405
 
384
406
  > [!TIP]
385
- > While environment variables are convenient for deployment scenarios, it's generally recommended to use the `generateTemplateEnv` function during development for better type checking and easier debugging.
407
+ > Use `generateTemplateEnv` during development for type safety and easier debugging. Use `.env` files for CI/CD and deployment overrides.
386
408
 
387
409
  > [!IMPORTANT]
388
- > The `.env` file must be placed in the root of your project. Values defined in the `.env` file will override any corresponding values from the `generateTemplateEnv` function.
410
+ > The `.env` file must be in the project root (or the directory specified by Vite's `envDir`). Values from `.env` files override matching values from `generateTemplateEnv`.
389
411
 
390
412
  ## Advanced Customization
391
413
 
392
- For advanced scenarios, the plugin provides options to customize both the HTML template and the application bootstrapping process. These customizations should be approached carefully as they may require deeper understanding of the framework.
393
-
394
414
  ### Providing a Custom Template
395
415
 
396
- You can provide a completely custom HTML template for your application. This gives you full control over the document structure while still leveraging the plugin's environment variable injection.
416
+ Override the built-in HTML template by passing a `template` string to the plugin. Placeholders use the `%VAR%` syntax from [Vite's HTML constant replacement](https://vite.dev/guide/env-and-mode.html#html-constant-replacement).
397
417
 
398
418
  > [!WARNING]
399
- > Custom templates move you closer to the edge of the framework's capabilities. Proceed with caution as you'll be responsible for ensuring proper structure and bootstrapping.
419
+ > Custom templates bypass the default structure. You are responsible for loading the bootstrap script and ensuring proper document structure.
400
420
 
401
421
  #### Example Custom Template
402
422
 
@@ -479,9 +499,7 @@ document.addEventListener('DOMContentLoaded', () => {
479
499
 
480
500
  ## Examples
481
501
 
482
- Here are some common implementation examples to help you get started quickly:
483
-
484
- ### Basic SPA Configuration
502
+ ### Basic SPA with React
485
503
 
486
504
  ```ts
487
505
  // vite.config.ts
@@ -557,24 +575,15 @@ export default defineConfig({
557
575
  ```
558
576
  See [API Service Plugin docs](https://github.com/equinor/fusion-framework/tree/main/packages/vite-plugins/api-service) for more details.
559
577
 
560
- ## Troubleshooting & FAQ
578
+ ## Troubleshooting
561
579
 
562
580
  ### Common Issues
563
581
 
564
- 1. **Authentication Failures**
565
- - Ensure your `tenantId` and `clientId` values are correct
566
- - Check that your application is properly registered in Azure AD
567
- - Verify that the required scopes are configured correctly
568
-
569
- 2. **Service Worker Not Working**
570
- - Ensure the service worker is properly registered in your bootstrap process
571
- - Check browser console for any registration errors
572
- - Verify that the URL patterns in the resources configuration match your fetch calls
573
-
574
- 3. **Environment Variables Not Applied**
575
- - Confirm your `.env` file is in the project root
576
- - Verify the naming convention follows `FUSION_SPA_*` with proper snake_casing
577
- - Restart your development server after changing environment variables
582
+ | Symptom | Likely Cause | Fix |
583
+ | --- | --- | --- |
584
+ | Authentication failures | Wrong `tenantId` or `clientId` | Verify Azure AD app registration and scope configuration |
585
+ | Service worker not intercepting | Worker not registered or not controlling | Check browser console for registration errors; ensure `registerServiceWorker` is called |
586
+ | `.env` values ignored | Wrong prefix or missing restart | Confirm `FUSION_SPA_*` naming; restart the dev server |
578
587
 
579
588
  ### Known Issues
580
589
 
@@ -582,13 +591,11 @@ See [API Service Plugin docs](https://github.com/equinor/fusion-framework/tree/m
582
591
  | ----- | ------ | ----------- |
583
592
  | [#3266](https://github.com/equinor/fusion-framework/issues/3266) | **Missing bearer token on proxy assets** | When loading remote applications that use assets or code-splitting, the service worker may fail to attach the required Bearer token to requests for these resources. This occurs because the service worker rewrites `import.url`, which can interfere with proper token injection for asset requests. As a result, protected assets may not load correctly in some scenarios.|
584
593
 
585
- ### Best Practices & FAQ
594
+ ### Best Practices
586
595
 
587
- - **Keep secrets out of source code** — use environment variables for sensitive values.
588
- - **Leverage the [API Service Plugin](https://github.com/equinor/fusion-framework/tree/main/packages/vite-plugins/api-service)** for advanced API proxying and local development.
589
- - **When customizing templates or bootloaders,** always test service worker registration and authentication flows.
590
- - **For local development:**
591
- - Use [Vite's environment variable system](https://vitejs.dev/guide/env-and-mode.html)
596
+ - Keep secrets out of source code — use `.env` files or CI/CD variables.
597
+ - Use the [API Service Plugin](https://github.com/equinor/fusion-framework/tree/main/packages/vite-plugins/api-service) for advanced proxy routing during development.
598
+ - When using custom templates or bootstrap files, always verify service worker registration and authentication flows.
592
599
 
593
600
  ## Contributing
594
601
 
@@ -1,2 +1,11 @@
1
+ /**
2
+ * Public API surface of the `@equinor/fusion-framework-vite-plugin-spa/html`
3
+ * sub-path export.
4
+ *
5
+ * @remarks
6
+ * Re-exports the {@link registerServiceWorker} function so that custom
7
+ * bootstrap files can register the SPA service worker without importing
8
+ * internal paths.
9
+ */
1
10
  export { registerServiceWorker } from './register-service-worker.js';
2
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/html/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/html/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -1,4 +1,34 @@
1
1
  import { TelemetryLevel } from '@equinor/fusion-framework-module-telemetry';
2
+ /**
3
+ * Registers the Fusion SPA service worker and wires token acquisition.
4
+ *
5
+ * @remarks
6
+ * The service worker intercepts outgoing fetch requests that match
7
+ * the configured {@link ResourceConfiguration | resource patterns},
8
+ * rewrites URLs, and injects Bearer tokens obtained from the MSAL
9
+ * module. This function:
10
+ *
11
+ * 1. Registers `/@fusion-spa-sw.js` as a module service worker.
12
+ * 2. Listens for `GET_TOKEN` messages from the worker and responds
13
+ * with MSAL access tokens.
14
+ * 3. Sends the `INIT_CONFIG` message containing resource configurations
15
+ * to the active worker once it is ready and controlling the page.
16
+ *
17
+ * @param framework - An initialized Fusion Framework instance that
18
+ * includes the {@link MsalModule} (for token acquisition) and
19
+ * {@link TelemetryModule} (for structured logging).
20
+ * @throws {Error} When service workers are not supported by the browser.
21
+ * @throws {Error} When the `FUSION_SPA_SERVICE_WORKER_RESOURCES`
22
+ * environment variable is not defined.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { registerServiceWorker } from '@equinor/fusion-framework-vite-plugin-spa/html';
27
+ *
28
+ * const framework = await configurator.initialize();
29
+ * await registerServiceWorker(framework);
30
+ * ```
31
+ */
2
32
  export async function registerServiceWorker(framework) {
3
33
  const telemetry = framework.telemetry;
4
34
  if ('serviceWorker' in navigator === false) {
@@ -1 +1 @@
1
- {"version":3,"file":"register-service-worker.js","sourceRoot":"","sources":["../../../src/html/register-service-worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAwB,MAAM,4CAA4C,CAAC;AAElG,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,SAAyD;IAEzD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;IACtC,IAAI,eAAe,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAClF,SAAS,CAAC,IAAI,GAAG,2BAA2B,CAAC;QAC7C,SAAS,CAAC,cAAc,CAAC;YACvB,IAAI,EAAE,yBAAyB,SAAS,CAAC,IAAI,EAAE;YAC/C,SAAS;SACV,CAAC,CAAC;QACH,MAAM,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,eAAe,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
1
+ {"version":3,"file":"register-service-worker.js","sourceRoot":"","sources":["../../../src/html/register-service-worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAwB,MAAM,4CAA4C,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,SAAyD;IAEzD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;IACtC,IAAI,eAAe,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAClF,SAAS,CAAC,IAAI,GAAG,2BAA2B,CAAC;QAC7C,SAAS,CAAC,cAAc,CAAC;YACvB,IAAI,EAAE,yBAAyB,SAAS,CAAC,IAAI,EAAE;YAC/C,SAAS;SACV,CAAC,CAAC;QACH,MAAM,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,mCAAmC,CAAC;IAC5E,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACrE,SAAS,CAAC,IAAI,GAAG,+BAA+B,CAAC;QACjD,SAAS,CAAC,cAAc,CAAC;YACvB,IAAI,EAAE,yBAAyB,SAAS,CAAC,IAAI,EAAE;YAC/C,SAAS;SACV,CAAC,CAAC;QACH,MAAM,SAAS,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,MAAM,yBAAyB,GAAG,CAAC,MAAqB,EAAE,EAAE;QAC1D,MAAM,CAAC,WAAW,CAAC;YACjB,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,eAAe;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,6DAA6D;QAC7D,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QAExC,2EAA2E;QAC3E,SA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AM,EAAE,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC,EACF;gBACE,IAAI,EAAE;oBACJ,IAAI,EAAE,sCAAsC;oBAC5C,KAAK,EAAE,cAAc,CAAC,KAAK;iBAC5B;aACF,CACF,CAAC;QACJ,CAAC;QAED,+CAA+C;QAC/C,yBAAyB,CAAC,YAAY,CAAC,CAAC;QAExC,wEAAwE;QACxE,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,KAAK,YAAY,EAAE,CAAC;YAC9F,yBAAyB,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,cAAc,CAAC;YACvB,IAAI,EAAE,yBAA0B,KAAe,CAAC,IAAI,EAAE;YACtD,SAAS,EAAE,KAAc;SAC1B,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,34 @@
1
+ /**
2
+ * @module @equinor/fusion-framework-vite-plugin-spa
3
+ *
4
+ * Vite plugin for building Fusion Framework Single Page Applications (SPAs).
5
+ *
6
+ * Provides HTML template generation, MSAL authentication bootstrapping,
7
+ * service discovery wiring, portal loading, and authenticated API proxying
8
+ * via a service worker.
9
+ *
10
+ * @remarks
11
+ * This plugin is intended for non-production development environments and
12
+ * is designed for use with `@equinor/fusion-framework-cli`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { fusionSpaPlugin } from '@equinor/fusion-framework-vite-plugin-spa';
17
+ *
18
+ * export default defineConfig({
19
+ * plugins: [
20
+ * fusionSpaPlugin({
21
+ * generateTemplateEnv: () => ({
22
+ * title: 'My App',
23
+ * portal: { id: 'my-portal' },
24
+ * serviceDiscovery: { url: 'https://...', scopes: ['api://...'] },
25
+ * msal: { tenantId: '...', clientId: '...', redirectUri: '...' },
26
+ * }),
27
+ * }),
28
+ * ],
29
+ * });
30
+ * ```
31
+ */
1
32
  export { default, plugin as fusionSpaPlugin } from './plugin.js';
2
33
  export * from './types.js';
3
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAsB,MAAM,aAAa,CAAC;AAErF,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAsB,MAAM,aAAa,CAAC;AAErF,cAAc,YAAY,CAAC"}