@bluealba/pae-ui-react-core 4.6.0-integration-css.403 → 4.6.0-integration-css.408
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/dist/index.cjs.js +42 -42
- package/dist/index.esm.js +2253 -2233
- package/dist/index.systemjs.js +40 -40
- package/dist/index.umd.js +40 -40
- package/dist/src/styles/moduleStyleLifecycle.d.ts +34 -0
- package/dist/src/utils/initializeMicroFrontend.d.ts +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suspend/restore a micro-frontend module's global styles across single-spa
|
|
3
|
+
* mount/unmount.
|
|
4
|
+
*
|
|
5
|
+
* style-loader injects a module's CSS into document.head when the bundle is
|
|
6
|
+
* LOADED, and single-spa unmount never removes it (SystemJS keeps the module
|
|
7
|
+
* cached). A module that imports a global stylesheet (a CSS framework reset,
|
|
8
|
+
* preflight, etc.) therefore permanently contaminates every app visited
|
|
9
|
+
* afterwards in the same session.
|
|
10
|
+
*
|
|
11
|
+
* The UI SDK tags every <style> it emits with data-pae-module="<name>"
|
|
12
|
+
* (see pae-ui-react-sdk getBaseConfig). initializeMicroFrontend calls
|
|
13
|
+
* suspendModuleStyles on unmount — detaching those elements from the
|
|
14
|
+
* document while keeping them in memory — and restoreModuleStyles on mount,
|
|
15
|
+
* so re-entering the app is instant (no re-parse, CSSOM preserved).
|
|
16
|
+
*
|
|
17
|
+
* NOTE: this only covers CSS that goes through style-loader. Runtime
|
|
18
|
+
* CSS-in-JS (e.g. Emotion/MUI) injects its own tags and is not affected.
|
|
19
|
+
*
|
|
20
|
+
* pae-ui-react-core is a shared singleton (one instance via the import map),
|
|
21
|
+
* so this module-scoped store is global across all micro-frontends.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Detach the module's style elements from the document, keeping them in
|
|
25
|
+
* memory for a later restoreModuleStyles call. Safe to call when the module
|
|
26
|
+
* has no tagged styles (no-op).
|
|
27
|
+
*/
|
|
28
|
+
export declare const suspendModuleStyles: (moduleName: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Re-attach any previously suspended style elements for the module. Safe to
|
|
31
|
+
* call when nothing was suspended (no-op — e.g. the very first mount, where
|
|
32
|
+
* style-loader already injected the styles at load time).
|
|
33
|
+
*/
|
|
34
|
+
export declare const restoreModuleStyles: (moduleName: string) => void;
|
|
@@ -12,6 +12,11 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
|
|
|
12
12
|
*
|
|
13
13
|
* All PAE micro-frontends are wrapped in PAE components that provides react context later used
|
|
14
14
|
* by the provided hooks.
|
|
15
|
+
*
|
|
16
|
+
* On top of the single-spa lifecycles, the module's global styles (tagged
|
|
17
|
+
* with data-pae-module by the UI SDK) are suspended on unmount and restored
|
|
18
|
+
* on mount, so CSS frameworks imported by one module don't leak into other
|
|
19
|
+
* modules across navigation (see styles/moduleStyleLifecycle).
|
|
15
20
|
*/
|
|
16
21
|
declare const initializeMicroFrontend: <T extends RootComponentProps>({ rootComponent, ...opts }: MicroFrontendOptions<T>) => ReactAppOrParcel<T>;
|
|
17
22
|
export default initializeMicroFrontend;
|