@sigx/vite 0.1.11 → 0.1.13

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.
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Library build utilities for SignalX packages using Vite 8's built-in Rolldown bundler.
3
+ *
4
+ * This module provides a `defineLibConfig` helper that simplifies creating library builds
5
+ * with consistent configuration across all @sigx/* packages.
6
+ */
7
+ import { defineConfig } from 'vite';
8
+ import path from 'path';
9
+ import { fileURLToPath } from 'url';
10
+ // ============================================================================
11
+ // Helpers
12
+ // ============================================================================
13
+ function normalizeEntries(entry) {
14
+ if (typeof entry === 'string') {
15
+ return { index: entry };
16
+ }
17
+ if (Array.isArray(entry)) {
18
+ return Object.fromEntries(entry.map(e => [e.name, e.entry]));
19
+ }
20
+ return entry;
21
+ }
22
+ function resolveAliases(alias, root) {
23
+ if (!alias)
24
+ return {};
25
+ const resolved = {};
26
+ for (const [key, value] of Object.entries(alias)) {
27
+ resolved[key] = path.resolve(root, value);
28
+ }
29
+ return resolved;
30
+ }
31
+ // ============================================================================
32
+ // Main Export
33
+ // ============================================================================
34
+ /**
35
+ * Define a Vite library build configuration for SignalX packages.
36
+ *
37
+ * @example Basic single-entry library:
38
+ * ```ts
39
+ * import { defineLibConfig } from '@sigx/vite/lib';
40
+ *
41
+ * export default defineLibConfig({
42
+ * entry: 'src/index.ts'
43
+ * });
44
+ * ```
45
+ *
46
+ * @example Multi-entry library with subpath exports:
47
+ * ```ts
48
+ * import { defineLibConfig } from '@sigx/vite/lib';
49
+ *
50
+ * export default defineLibConfig({
51
+ * entry: {
52
+ * 'index': 'src/index.ts',
53
+ * 'server/index': 'src/server/index.ts',
54
+ * 'client/index': 'src/client/index.ts'
55
+ * },
56
+ * external: ['sigx', /@sigx\/.* /]
57
+ * });
58
+ * ```
59
+ *
60
+ * @example Bundling with aliases (like sigx main package):
61
+ * ```ts
62
+ * import { defineLibConfig } from '@sigx/vite/lib';
63
+ *
64
+ * export default defineLibConfig({
65
+ * entry: {
66
+ * 'sigx': 'src/index.ts',
67
+ * 'hydration': 'src/hydration.ts'
68
+ * },
69
+ * alias: {
70
+ * '@sigx/reactivity': '../reactivity/src/index.ts',
71
+ * '@sigx/runtime-core': '../runtime-core/src/index.ts',
72
+ * '@sigx/runtime-dom': '../runtime-dom/src/index.ts'
73
+ * },
74
+ * minify: true, // Also produce sigx.min.js
75
+ * root: import.meta.url
76
+ * });
77
+ * ```
78
+ */
79
+ export function defineLibConfig(options) {
80
+ const { entry, outDir = 'dist', sourcemap = true, external = [/@sigx\/.*/], alias, minify = false, banner, jsx = false, platform = 'browser', root = process.cwd(), } = options;
81
+ // Resolve root directory from import.meta.url if provided
82
+ const rootDir = root.startsWith('file://')
83
+ ? path.dirname(fileURLToPath(root))
84
+ : root;
85
+ const entries = normalizeEntries(entry);
86
+ const resolvedAliases = resolveAliases(alias, rootDir);
87
+ // Convert external patterns for Vite 8's rolldownOptions
88
+ const externalPatterns = external.map(ext => {
89
+ if (ext instanceof RegExp) {
90
+ return ext;
91
+ }
92
+ return ext;
93
+ });
94
+ const config = {
95
+ root: rootDir,
96
+ resolve: {
97
+ alias: resolvedAliases
98
+ },
99
+ build: {
100
+ outDir,
101
+ sourcemap,
102
+ emptyOutDir: true,
103
+ lib: {
104
+ entry: entries,
105
+ formats: ['es'],
106
+ fileName: (_format, entryName) => `${entryName}.js`
107
+ },
108
+ // Vite 8 uses rolldownOptions instead of rollupOptions
109
+ rolldownOptions: {
110
+ external: externalPatterns,
111
+ ...(banner && {
112
+ output: {
113
+ banner
114
+ }
115
+ })
116
+ },
117
+ // Platform-specific settings
118
+ ...(platform === 'node' && {
119
+ target: 'node18'
120
+ }),
121
+ // Minification handled by Vite 8's Oxc minifier
122
+ minify: minify ? 'oxc' : false
123
+ },
124
+ // JSX configuration for Vite 8 using Oxc
125
+ ...(jsx && {
126
+ oxc: {
127
+ jsx: {
128
+ runtime: 'automatic',
129
+ importSource: 'sigx'
130
+ }
131
+ }
132
+ })
133
+ };
134
+ return defineConfig(config);
135
+ }
136
+ /**
137
+ * Create multiple build configurations for packages that need separate builds
138
+ * (e.g., minified + non-minified, or different platform targets).
139
+ *
140
+ * Note: Vite doesn't support array configs like Rolldown did directly.
141
+ * Use this with a build script that runs vite build multiple times with different configs.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * // In vite.config.ts
146
+ * import { defineLibConfig } from '@sigx/vite/lib';
147
+ *
148
+ * const config = process.env.MINIFY === 'true'
149
+ * ? defineLibConfig({ entry: 'src/index.ts', minify: true })
150
+ * : defineLibConfig({ entry: 'src/index.ts' });
151
+ *
152
+ * export default config;
153
+ * ```
154
+ */
155
+ export { defineConfig };
156
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAiD,MAAM,MAAM,CAAC;AACnF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AA2EpC,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,gBAAgB,CAAC,KAA+B,EAA0B;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CAChB;AAED,SAAS,cAAc,CACnB,KAAyC,EACzC,IAAY,EACU;IACtB,IAAI,CAAC,KAAK;QAAE,OA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EH,MAAM,MAAM,GAAe;QACvB,IAAI,EAAE,OAAO;QAEb,OAAO,EAAE;YACL,KAAK,EAAE,eAAe;SACzB;QAED,KAAK,EAAE;YACH,MAAM;YACN,SAAS;YACT,WAAW,EAAE,IAAI;YAEjB,GAAG,EAAE;gBACD,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,CAAC,IAAI,CAAC;gBACf,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK;aACtD;YAED,uDAAuD;YACvD,eAAe,EAAE;gBACb,QAAQ,EAAE,gBAAgB;gBAC1B,GAAG,CAAC,MAAM,IAAI;oBACV,MAAM,EAAE;wBACJ,MAAM;qBACT;iBACJ,CAAC;aACL;YAED,6BAA6B;YAC7B,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI;gBACvB,MAAM,EAAE,QAAQ;aACnB,CAAC;YAEF,gDAAgD;YAChD,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;SACjC;QAED,yCAAyC;QACzC,GAAG,CAAC,GAAG,IAAI;YACP,GAAG,EAAE;gBACD,GAAG,EAAE;oBACD,OAAO,EAAE,WAAW;oBACpB,YAAY,EAAE,MAAM;iBACvB;aACJ;SACJ,CAAC;KACL,CAAC;IAEF,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAAA,CAC/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigx/vite",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Vite plugin for SignalX Framework with HMR, library builds, and automatic type generation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@types/node": "^22.19.1",
37
37
  "vite": "^8.0.0-beta.9",
38
- "sigx": "^0.1.11"
38
+ "sigx": "^0.1.13"
39
39
  },
40
40
  "keywords": [
41
41
  "SignalX"
@@ -52,7 +52,7 @@
52
52
  "url": "https://github.com/signalxjs/core/issues"
53
53
  },
54
54
  "scripts": {
55
- "build": "tsc",
55
+ "build": "tsgo",
56
56
  "dev": "tsc --watch"
57
57
  }
58
58
  }