ezfw-core 1.0.95 → 1.0.97

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.
@@ -4,26 +4,72 @@
4
4
  * Generates index.js and hydrate.js entry points with user config inlined.
5
5
  * This allows users to only modify ez.config.js while keeping all framework
6
6
  * internals hidden.
7
+ *
8
+ * Supports two modes:
9
+ * - Local: when ./ez folder exists (main ez repo)
10
+ * - NPM: when using ezfw-core from node_modules
7
11
  */
8
12
  import * as fs from 'fs';
9
13
  import * as path from 'path';
10
14
 
15
+ /**
16
+ * Detect if project uses local ./ez folder or ezfw-core from npm
17
+ */
18
+ function detectFrameworkMode(root) {
19
+ const localEzPath = path.resolve(root, 'ez/core/ez.js');
20
+ const localEzTsPath = path.resolve(root, 'ez/core/ez.ts');
21
+ if (fs.existsSync(localEzPath) || fs.existsSync(localEzTsPath)) {
22
+ return 'local';
23
+ }
24
+ return 'npm';
25
+ }
26
+
11
27
  /**
12
28
  * Generate the SPA entry point code (index.js)
13
29
  */
14
- function generateIndexCode(config) {
30
+ function generateIndexCode(config, mode) {
15
31
  const theme = config.theme || 'slate-dark';
16
32
  const i18nCode = config.i18n
17
33
  ? `ez.setLanguages(${JSON.stringify(config.i18n.languages)}, { default: '${config.i18n.default}', debug: ${config.i18n.debug || false} });`
18
34
  : '';
19
35
 
36
+ // Framework imports differ based on mode
37
+ const fwImports = mode === 'local'
38
+ ? `import './ez/core/ez.js';
39
+ import './ez-base.css';
40
+ import './ez/themes/ez-theme.scss';
41
+ import './ez/themes/ez-theme-slate.scss';`
42
+ : `import 'ezfw-core';
43
+ import 'ezfw-core/ez-base.css';
44
+ import 'ezfw-core/themes/ez-theme.scss';
45
+ import 'ezfw-core/themes/ez-theme-slate.scss';`;
46
+
47
+ // Framework module globs differ based on mode
48
+ const fwModulesGlob = mode === 'local'
49
+ ? `const frameworkModules = import.meta.glob([
50
+ './ez/**/*.{js,jsx,ts,tsx}',
51
+ '!./ez/islands/**',
52
+ '!./ez/**/*.test.{js,ts}',
53
+ '!./ez/**/*.example.{js,ts}',
54
+ '!./ez/**/*Plugin.{js,ts}'
55
+ ]);`
56
+ : `const frameworkModules = import.meta.glob([
57
+ './node_modules/ezfw-core/**/*.{js,jsx,ts,tsx}',
58
+ '!./node_modules/ezfw-core/islands/**',
59
+ '!./node_modules/ezfw-core/**/*.test.{js,ts}',
60
+ '!./node_modules/ezfw-core/**/*.example.{js,ts}',
61
+ '!./node_modules/ezfw-core/**/*Plugin.{js,ts}'
62
+ ]);`;
63
+
64
+ const fwStylesGlob = mode === 'local'
65
+ ? `const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');`
66
+ : `const frameworkStyles = import.meta.glob('./node_modules/ezfw-core/**/*.module.scss');`;
67
+
20
68
  return `// Generated by Ez Framework - DO NOT EDIT
21
69
  // Configuration: ez.config.js
70
+ // Mode: ${mode}
22
71
 
23
- import './ez/core/ez.js';
24
- import './ez-base.css';
25
- import './ez/themes/ez-theme.scss';
26
- import './ez/themes/ez-theme-slate.scss';
72
+ ${fwImports}
27
73
  import { fetchConfigResolver } from './app/fetchConfig.js';
28
74
  import { routeResolver } from './app/routes.js';
29
75
  import stylesConfig from './ez.styles.config.js';
@@ -42,13 +88,7 @@ ${i18nCode}
42
88
  // Framework internals
43
89
  ez.defineStyles(stylesConfig);
44
90
 
45
- const frameworkModules = import.meta.glob([
46
- './ez/**/*.{js,jsx,ts,tsx}',
47
- '!./ez/islands/**',
48
- '!./ez/**/*.test.{js,ts}',
49
- '!./ez/**/*.example.{js,ts}',
50
- '!./ez/**/*Plugin.{js,ts}'
51
- ]);
91
+ ${fwModulesGlob}
52
92
 
53
93
  const desktopModules = import.meta.glob([
54
94
  './app/**/*.{js,jsx,ts,tsx}',
@@ -61,7 +101,7 @@ const desktopModules = import.meta.glob([
61
101
  const mobileModules = import.meta.glob('./app/**/*.mobile.{js,jsx,ts,tsx}');
62
102
  const tabletModules = import.meta.glob('./app/**/*.tablet.{js,jsx,ts,tsx}');
63
103
 
64
- const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');
104
+ ${fwStylesGlob}
65
105
  const appStyles = import.meta.glob('./app/**/*.module.scss');
66
106
 
67
107
  ez.installModules({
@@ -100,19 +140,49 @@ if (!window.__EZ_SSR_MODE__) {
100
140
  /**
101
141
  * Generate the SSR hydration entry point code (hydrate.js)
102
142
  */
103
- function generateHydrateCode(config) {
143
+ function generateHydrateCode(config, mode) {
104
144
  const theme = config.theme || 'slate-dark';
105
145
  const i18nCode = config.i18n
106
146
  ? `ez.setLanguages(${JSON.stringify(config.i18n.languages)}, { default: '${config.i18n.default}', debug: ${config.i18n.debug || false} });`
107
147
  : '';
108
148
 
149
+ // Framework imports differ based on mode
150
+ const fwImports = mode === 'local'
151
+ ? `import './ez/core/ez.js';
152
+ import './ez-base.css';
153
+ import './ez/themes/ez-theme.scss';
154
+ import './ez/themes/ez-theme-slate.scss';`
155
+ : `import 'ezfw-core';
156
+ import 'ezfw-core/ez-base.css';
157
+ import 'ezfw-core/themes/ez-theme.scss';
158
+ import 'ezfw-core/themes/ez-theme-slate.scss';`;
159
+
160
+ // Framework module globs differ based on mode
161
+ const fwModulesGlob = mode === 'local'
162
+ ? `const frameworkModules = import.meta.glob([
163
+ './ez/**/*.{js,jsx,ts,tsx}',
164
+ '!./ez/islands/**',
165
+ '!./ez/**/*.test.{js,ts}',
166
+ '!./ez/**/*.example.{js,ts}',
167
+ '!./ez/**/*Plugin.{js,ts}'
168
+ ]);`
169
+ : `const frameworkModules = import.meta.glob([
170
+ './node_modules/ezfw-core/**/*.{js,jsx,ts,tsx}',
171
+ '!./node_modules/ezfw-core/islands/**',
172
+ '!./node_modules/ezfw-core/**/*.test.{js,ts}',
173
+ '!./node_modules/ezfw-core/**/*.example.{js,ts}',
174
+ '!./node_modules/ezfw-core/**/*Plugin.{js,ts}'
175
+ ]);`;
176
+
177
+ const fwStylesGlob = mode === 'local'
178
+ ? `const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');`
179
+ : `const frameworkStyles = import.meta.glob('./node_modules/ezfw-core/**/*.module.scss');`;
180
+
109
181
  return `// Generated by Ez Framework - DO NOT EDIT
110
182
  // Configuration: ez.config.js
183
+ // Mode: ${mode}
111
184
 
112
- import './ez/core/ez.js';
113
- import './ez-base.css';
114
- import './ez/themes/ez-theme.scss';
115
- import './ez/themes/ez-theme-slate.scss';
185
+ ${fwImports}
116
186
  import { fetchConfigResolver } from './app/fetchConfig.js';
117
187
  import { routeResolver } from './app/routes.js';
118
188
  import stylesConfig from './ez.styles.config.js';
@@ -131,13 +201,7 @@ ${i18nCode}
131
201
  // Framework internals
132
202
  ez.defineStyles(stylesConfig);
133
203
 
134
- const frameworkModules = import.meta.glob([
135
- './ez/**/*.{js,jsx,ts,tsx}',
136
- '!./ez/islands/**',
137
- '!./ez/**/*.test.{js,ts}',
138
- '!./ez/**/*.example.{js,ts}',
139
- '!./ez/**/*Plugin.{js,ts}'
140
- ]);
204
+ ${fwModulesGlob}
141
205
 
142
206
  const desktopModules = import.meta.glob([
143
207
  './app/**/*.{js,jsx,ts,tsx}',
@@ -150,7 +214,7 @@ const desktopModules = import.meta.glob([
150
214
  const mobileModules = import.meta.glob('./app/**/*.mobile.{js,jsx,ts,tsx}');
151
215
  const tabletModules = import.meta.glob('./app/**/*.tablet.{js,jsx,ts,tsx}');
152
216
 
153
- const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');
217
+ ${fwStylesGlob}
154
218
  const appStyles = import.meta.glob('./app/**/*.module.scss');
155
219
 
156
220
  ez.installModules({
@@ -237,10 +301,14 @@ export function ezEntry() {
237
301
  // Reload config on each transform (for HMR support)
238
302
  config = await loadConfig(root);
239
303
 
304
+ // Detect if using local ./ez folder or ezfw-core from npm
305
+ const mode = detectFrameworkMode(root);
306
+ console.log('[Ez Entry] Framework mode:', mode);
307
+
240
308
  if (fileName === 'index.js') {
241
309
  console.log('[Ez Entry] Generating index.js');
242
310
  return {
243
- code: generateIndexCode(config),
311
+ code: generateIndexCode(config, mode),
244
312
  map: null
245
313
  };
246
314
  }
@@ -248,7 +316,7 @@ export function ezEntry() {
248
316
  if (fileName === 'hydrate.js') {
249
317
  console.log('[Ez Entry] Generating hydrate.js');
250
318
  return {
251
- code: generateHydrateCode(config),
319
+ code: generateHydrateCode(config, mode),
252
320
  map: null
253
321
  };
254
322
  }
@@ -905,4 +905,8 @@ function generateSitemap(pages, siteUrl) {
905
905
  ${urls}
906
906
  </urlset>`;
907
907
  }
908
+ // Re-export other Vite plugins for unified import
909
+ export { ezEntry } from '../core/ezEntryPlugin.js';
910
+ export { ezJsx } from '../jsx/vite-plugin-ez-jsx.js';
911
+
908
912
  export default ezIslands;
@@ -401,4 +401,8 @@ export function ezIslands(options: EzIslandsOptions = {}): Plugin {
401
401
  // Re-export types for consumers
402
402
  export type { EzIslandsOptions, PageInfo, IslandInfo, BuildManifest, StaticPathParams, GetStaticPaths } from './types.js';
403
403
 
404
+ // Re-export other Vite plugins for unified import
405
+ export { ezEntry } from '../core/ezEntryPlugin.js';
406
+ export { ezJsx } from '../jsx/vite-plugin-ez-jsx.js';
407
+
404
408
  export default ezIslands;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezfw-core",
3
- "version": "1.0.95",
3
+ "version": "1.0.97",
4
4
  "description": "Ez Framework - A declarative component framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "./core/ez.ts",