@blocklet/pages-kit 0.4.94 → 0.4.96

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.
@@ -1 +1,2 @@
1
1
  export const BuiltinModulesGlobalVariableName = '__PAGES_KIT_BUILTIN_MODULES__';
2
+ export const ChunksMountPointGlobalVariableName = '__PAGES_KIT_CHUNKS_MOUNT_POINT__';
@@ -26,8 +26,9 @@ import * as utils from '../builtin/utils';
26
26
  import * as zustand from '../builtin/zustand';
27
27
  import * as zustandMiddlewareImmer from '../builtin/zustand/middleware/immer';
28
28
  import CustomComponentRenderer from '../components/CustomComponentRenderer';
29
- import { BuiltinModulesGlobalVariableName } from '../types/builtin';
29
+ import { BuiltinModulesGlobalVariableName, ChunksMountPointGlobalVariableName } from '../types/builtin';
30
30
  import { isRelativeModule } from './typescript/builtin-module-transformer';
31
+ const { getComponentMountPoint } = utils;
31
32
  // Initialize ES Module Shims before any imports
32
33
  export function injectGlobalComponents() {
33
34
  const win = window || {};
@@ -91,7 +92,18 @@ export function injectGlobalComponents() {
91
92
  // handle relative path import
92
93
  if (isRelativeModule(module)) {
93
94
  const fileName = module.split('/').pop();
94
- const fullUrl = joinURL(window.location.origin, window?.blocklet?.prefix || '/', 'chunks', fileName);
95
+ // real chunks mount point
96
+ // 1. from window global variable ChunksMountPointGlobalVariableName
97
+ // 2. from pages kit blocklet component mount point
98
+ // 3. from window.blocklet.prefix
99
+ // 4. from default /
100
+ const relativeChunksMountPoint =
101
+ // @ts-ignore
102
+ window[ChunksMountPointGlobalVariableName] ||
103
+ getComponentMountPoint('pages-kit') ||
104
+ window?.blocklet?.prefix ||
105
+ '/';
106
+ const fullUrl = joinURL(window.location.origin, relativeChunksMountPoint, 'chunks', fileName);
95
107
  if (enableShim) {
96
108
  const mod = window.importShim(/* @vite-ignore */ fullUrl);
97
109
  return mod;