@pushwoosh/single-spa 1.2.0 → 1.3.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/Parcel.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/loadModule.d.ts +2 -0
- package/loadModule.js +4 -0
- package/package.json +1 -1
- package/loadByFormat.d.ts +0 -6
- package/loadByFormat.js +0 -15
package/Parcel.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { mountRootParcel } from 'single-spa';
|
|
4
4
|
import SingleSpaParcel from 'single-spa-react/parcel';
|
|
5
5
|
import { useSPAContext } from '@pushwoosh/spa-context';
|
|
6
|
-
import {
|
|
6
|
+
import { loadModule } from './loadModule';
|
|
7
7
|
export const Parcel = ({
|
|
8
8
|
className,
|
|
9
9
|
module,
|
|
@@ -15,7 +15,7 @@ export const Parcel = ({
|
|
|
15
15
|
let parcel;
|
|
16
16
|
return {
|
|
17
17
|
bootstrap(props) {
|
|
18
|
-
return
|
|
18
|
+
return loadModule(module).then(imported => {
|
|
19
19
|
// eslint-disable-next-line react/prop-types, react-hooks/immutability
|
|
20
20
|
parcel = imported[parcelFunctionName](props.domElement);
|
|
21
21
|
});
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './Parcel';
|
|
2
2
|
export { createParcelFunction } from './createParcelFunction';
|
|
3
3
|
export { createApplicationFunction } from './createApplicationFunction';
|
|
4
|
-
export {
|
|
4
|
+
export { loadModule } from './loadModule';
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './Parcel';
|
|
2
2
|
export { createParcelFunction } from './createParcelFunction';
|
|
3
3
|
export { createApplicationFunction } from './createApplicationFunction';
|
|
4
|
-
export {
|
|
4
|
+
export { loadModule } from './loadModule';
|
package/loadModule.d.ts
ADDED
package/loadModule.js
ADDED
package/package.json
CHANGED
package/loadByFormat.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** URL the merged root-config import map assigns to `name`, or `name` itself when the map has no entry. */
|
|
2
|
-
export declare function resolveModuleUrl(name: string): string;
|
|
3
|
-
/** Whether `url` points at an ES module build (`.mjs`), ignoring query and hash. */
|
|
4
|
-
export declare function isEsmUrl(url: string): boolean;
|
|
5
|
-
/** Loads a module by import-map name: `.mjs` entries through native `import()`, the rest through SystemJS. */
|
|
6
|
-
export declare function loadByFormat<T = unknown>(name: string): Promise<T>;
|
package/loadByFormat.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** URL the merged root-config import map assigns to `name`, or `name` itself when the map has no entry. */
|
|
2
|
-
export function resolveModuleUrl(name) {
|
|
3
|
-
return window.__PW_IMPORT_MAP__?.imports[name] ?? name;
|
|
4
|
-
}
|
|
5
|
-
/** Whether `url` points at an ES module build (`.mjs`), ignoring query and hash. */
|
|
6
|
-
export function isEsmUrl(url) {
|
|
7
|
-
return /\.mjs(?:[?#]|$)/.test(url);
|
|
8
|
-
}
|
|
9
|
-
/** Loads a module by import-map name: `.mjs` entries through native `import()`, the rest through SystemJS. */
|
|
10
|
-
export function loadByFormat(name) {
|
|
11
|
-
if (isEsmUrl(resolveModuleUrl(name))) {
|
|
12
|
-
return import(/* webpackIgnore: true */name);
|
|
13
|
-
}
|
|
14
|
-
return System.import(name);
|
|
15
|
-
}
|