@shellui/cli 0.0.17 → 0.0.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellui/cli",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "ShellUI CLI - Command-line tool for ShellUI",
5
5
  "main": "src/cli.js",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "tsx": "^4.21.0",
31
31
  "vite": "7.3.1",
32
32
  "workbox-build": "^7.1.0",
33
- "@shellui/core": "0.0.17"
33
+ "@shellui/core": "0.0.19"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -10,6 +10,7 @@ import {
10
10
  createResolveAlias,
11
11
  createPostCSSConfig,
12
12
  createViteDefine,
13
+ createViteResolveConfig,
13
14
  resolvePackagePath,
14
15
  } from '../utils/index.js';
15
16
 
@@ -76,6 +77,7 @@ export async function buildCommand(root = '.') {
76
77
  // Get core package paths
77
78
  const corePackagePath = resolvePackagePath('@shellui/core');
78
79
  const coreSrcPath = getCoreSrcPath();
80
+ const resolveConfig = createViteResolveConfig();
79
81
  const resolveAlias = createResolveAlias();
80
82
  const postcssConfig = createPostCSSConfig();
81
83
 
@@ -86,10 +88,8 @@ export async function buildCommand(root = '.') {
86
88
  plugins: [react()],
87
89
  define: createViteDefine(config),
88
90
  resolve: {
91
+ ...resolveConfig,
89
92
  alias: resolveAlias,
90
- // Dedupe React and core package to prevent duplicate module instances
91
- // This is critical for React Context to work correctly in micro-frontends
92
- dedupe: ['react', 'react-dom', '@shellui/core'],
93
93
  },
94
94
  css: {
95
95
  postcss: postcssConfig,
@@ -127,9 +127,8 @@ export async function buildCommand(root = '.') {
127
127
  root: coreSrcPath,
128
128
  define: createViteDefine(config),
129
129
  resolve: {
130
+ ...resolveConfig,
130
131
  alias: resolveAlias,
131
- // Dedupe React and core package to prevent duplicate module instances
132
- dedupe: ['react', 'react-dom', '@shellui/core'],
133
132
  },
134
133
  build: {
135
134
  outDir: distPath,
@@ -9,6 +9,8 @@ import {
9
9
  createResolveAlias,
10
10
  createPostCSSConfig,
11
11
  createViteDefine,
12
+ createViteResolveConfig,
13
+ createViteOptimizeDepsConfig,
12
14
  resolvePackagePath,
13
15
  } from '../utils/index.js';
14
16
  import { serviceWorkerDevPlugin } from '../utils/service-worker-plugin.js';
@@ -37,17 +39,18 @@ async function startServer(root, cwd, shouldOpen = false) {
37
39
  const staticPath = path.resolve(cwd, root, 'static');
38
40
  const publicDir = fs.existsSync(staticPath) ? staticPath : false;
39
41
 
42
+ const resolveConfig = createViteResolveConfig();
43
+ const resolveAlias = createResolveAlias();
44
+
40
45
  const server = await createServer({
41
46
  root: coreSrcPath,
42
47
  plugins: [react(), serviceWorkerDevPlugin(corePackagePath, coreSrcPath)],
43
48
  define: createViteDefine(config),
44
49
  resolve: {
45
- alias: createResolveAlias(),
46
- // Dedupe React and core package to prevent duplicate module instances
47
- // This is critical for React Context to work correctly in micro-frontends
48
- // When React is a peer dependency, dedupe ensures Vite uses a single instance
49
- dedupe: ['react', 'react-dom', '@shellui/core'],
50
+ ...resolveConfig,
51
+ alias: resolveAlias,
50
52
  },
53
+ optimizeDeps: createViteOptimizeDepsConfig(),
51
54
  css: {
52
55
  postcss: createPostCSSConfig(),
53
56
  },
@@ -12,4 +12,6 @@ export {
12
12
  createResolveAlias,
13
13
  createPostCSSConfig,
14
14
  createViteDefine,
15
+ createViteResolveConfig,
16
+ createViteOptimizeDepsConfig,
15
17
  } from './vite.js';
@@ -35,8 +35,6 @@ export function serviceWorkerDevPlugin(corePackagePath, coreSrcPath) {
35
35
  plugins: [react()],
36
36
  resolve: {
37
37
  alias: createResolveAlias(),
38
- // Dedupe React and core package to prevent duplicate module instances
39
- dedupe: ['react', 'react-dom', '@shellui/core'],
40
38
  },
41
39
  build: {
42
40
  write: false,
package/src/utils/vite.js CHANGED
@@ -101,3 +101,30 @@ export function createViteDefine(config) {
101
101
  __SHELLUI_SENTRY_RELEASE__: sentry?.release ? JSON.stringify(sentry.release) : 'undefined',
102
102
  };
103
103
  }
104
+
105
+ /**
106
+ * Create Vite resolve configuration with deduplication.
107
+ * Prevents duplicate React instances and @shellui/core modules when running
108
+ * from node_modules, which can cause context provider issues in microfrontends.
109
+ * @returns {Object} Vite resolve configuration with dedupe
110
+ */
111
+ export function createViteResolveConfig() {
112
+ return {
113
+ dedupe: ['react', 'react-dom', '@shellui/core'],
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Create Vite optimizeDeps configuration to exclude @shellui/core from pre-bundling.
119
+ * This prevents Vite from creating duplicate module instances during dependency optimization,
120
+ * which is critical for React Context to work correctly in microfrontend iframe scenarios.
121
+ *
122
+ * Note: We do NOT exclude React/ReactDOM here because Vite needs to optimize them.
123
+ * The resolve.dedupe configuration handles ensuring only one React instance is used.
124
+ * @returns {Object} Vite optimizeDeps configuration
125
+ */
126
+ export function createViteOptimizeDepsConfig() {
127
+ return {
128
+ exclude: ['@shellui/core'],
129
+ };
130
+ }