@hiscovega/vundle 0.0.5

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/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # @griddo/bundler
2
+
3
+ Master bundler configuration for Griddo Instance projects as an ESModules npm package.
4
+
5
+ ## 📦 Installation
6
+
7
+ ```bash
8
+ npm install @griddo/bundler
9
+ ```
10
+
11
+ ## 🚀 Publishing
12
+
13
+ ### Automated Releases with release-it
14
+
15
+ This package uses [release-it](https://github.com/release-it/release-it) for automated versioning and publishing.
16
+
17
+ #### Prerequisites
18
+
19
+ 1. **NPM Token**: Ensure you have an NPM token with publish permissions
20
+ 2. **GitHub Token**: For automatic GitHub releases (optional)
21
+ 3. **Clean working directory**: All changes should be committed
22
+
23
+ #### Release Commands
24
+
25
+ ```bash
26
+ # Dry run (recommended first)
27
+ npm run release:dry
28
+
29
+ # Release patch version (1.0.0 -> 1.0.1)
30
+ npm run release:patch
31
+
32
+ # Release minor version (1.0.0 -> 1.1.0)
33
+ npm run release:minor
34
+
35
+ # Release major version (1.0.0 -> 2.0.0)
36
+ npm run release:major
37
+
38
+ # Interactive release (recommended)
39
+ npm run release
40
+ ```
41
+
42
+ #### What happens during release:
43
+
44
+ 1. ✅ **Pre-release checks**: Lint and format verification
45
+ 2. 📝 **Version bump**: Automatic version increment
46
+ 3. 📝 **Changelog generation**: Conventional commits to CHANGELOG.md
47
+ 4. 🔖 **Git operations**: Commit, tag, and push
48
+ 5. 📦 **NPM publish**: Publish to npm registry
49
+ 6. 🐙 **GitHub release**: Create GitHub release (if configured)
50
+
51
+ #### Conventional Commits
52
+
53
+ Use conventional commit format for automatic changelog generation:
54
+
55
+ ```bash
56
+ feat: add new feature
57
+ fix: bug fix
58
+ docs: documentation update
59
+ style: code style changes
60
+ refactor: code refactoring
61
+ test: add tests
62
+ chore: maintenance tasks
63
+ ```
64
+
65
+ ## 🚀 Usage
66
+
67
+ ### Configuración Automática (Recomendada)
68
+
69
+ ```javascript
70
+ // vite.config.js
71
+ import { defineConfig } from "vite";
72
+ import react from "@vitejs/plugin-react";
73
+ import { plugins } from "@griddo/bundler/plugins";
74
+
75
+ export default defineConfig({
76
+ plugins: [react(), ...plugins],
77
+ build: {
78
+ // Tu configuración se mergeará automáticamente desde vite.config.mjs
79
+ },
80
+ });
81
+ ```
82
+
83
+ ### Client Configuration (vite.config.mjs)
84
+
85
+ The bundler automatically looks for a `vite.config.mjs` file in your project root. Create this file to customize the build configuration.
86
+
87
+ #### Quick Start Template
88
+
89
+ Copy the `vite.config.mjs.example` file from this repository as a starting point:
90
+
91
+ ```bash
92
+ cp node_modules/@griddo/bundler/vite.config.mjs.example ./vite.config.mjs
93
+ ```
94
+
95
+ Or create it manually:
96
+
97
+ ```javascript
98
+ // vite.config.mjs (in your project root)
99
+ export default {
100
+ build: {
101
+ rollupOptions: {
102
+ external: (id) => {
103
+ // Custom external dependencies
104
+ if (id === "your-heavy-dependency") return true;
105
+ return false;
106
+ },
107
+ },
108
+ },
109
+ plugins: [
110
+ // Additional Vite plugins for your project
111
+ ],
112
+ };
113
+ ```
114
+
115
+ ### Advanced Configuration
116
+
117
+ ```javascript
118
+ // If you need more complex configuration, you can also do:
119
+ import { defineConfig } from 'vite';
120
+ import { plugins } from "@griddo/bundler/plugins";
121
+
122
+ // Your project's main vite.config.js
123
+ export default defineConfig({
124
+ plugins: [
125
+ ...plugins,
126
+ // Your additional plugins
127
+ ],
128
+ build: {
129
+ // Your custom build config
130
+ },
131
+ });
132
+ ```
133
+
134
+ ### TypeScript Support
135
+
136
+ ```typescript
137
+ // vite.config.ts
138
+ import { defineConfig } from "vite";
139
+ import type { ClientConfig } from "@griddo/bundler/types";
140
+ import { plugins } from "@griddo/bundler/plugins";
141
+
142
+ const clientConfig: ClientConfig = {
143
+ build: {
144
+ rollupOptions: {
145
+ external: (id) => id.startsWith("client-dependency"),
146
+ },
147
+ },
148
+ };
149
+
150
+ export default defineConfig({
151
+ ...clientConfig,
152
+ plugins: [...plugins],
153
+ });
154
+ ```
155
+
156
+ ## 📁 Package Structure
157
+
158
+ ```
159
+ @griddo/bundler/
160
+ ├── vite.config.ts # 📦 Main configuration file
161
+ ├── plugins/
162
+ │ ├── index.mjs # ESModule plugins
163
+ │ └── index.d.ts # TypeScript definitions
164
+ ├── types/
165
+ │ └── client-config.d.ts # TypeScript types
166
+ ├── package.json # 📦 Package definition
167
+ └── README.md # 📖 Documentation
168
+ ```
169
+
170
+ ### Exports
171
+
172
+ The package provides the following exports:
173
+
174
+ - **Default config**: `import config from '@griddo/bundler'` - Configuración automática
175
+ - **Vite config**: `import config from '@griddo/bundler/vite.config'`
176
+ - **Plugins**: `import { plugins } from '@griddo/bundler/plugins'`
177
+ - **Types**: `import type { ClientConfig } from '@griddo/bundler/types'`
178
+
179
+ ## 🚀 Uso
180
+
181
+ ### 1. "Instalar" el master bundler
182
+
183
+ ```bash
184
+ npm run install:master
185
+ ```
186
+
187
+ Esto crea un symlink desde `node_modules/@griddo/bundler/` hacia `external/config/`
188
+
189
+ ### 2. Ejecutar el build
190
+
191
+ ```bash
192
+ npm run build
193
+ ```
194
+
195
+ El build ahora usa la configuración desde `node_modules/@griddo/bundler/vite.config.ts`
196
+
197
+ ### 3. Limpiar la instalación simulada
198
+
199
+ ```bash
200
+ npm run uninstall:master
201
+ ```
202
+
203
+ ## 🔄 Flujo de trabajo
204
+
205
+ 1. **Desarrollo**: Usa `npm run build:local` para trabajar con la config local
206
+ 2. **Validación**: Usa `npm run install:master` + `npm run build` para validar el flujo simulado
207
+ 3. **Producción**: Los clientes reales usarán `npm install @griddo/master-bundler`
208
+
209
+ ## 📋 Comandos disponibles
210
+
211
+ - `npm run install:master` - Instala el bundler simulado
212
+ - `npm run uninstall:master` - Remueve la instalación simulada
213
+ - `npm run build` - Build usando configuración simulada
214
+ - `npm run build:local` - Build usando configuración local
215
+
216
+ ## 🎯 Beneficios
217
+
218
+ - ✅ **Simulación realista** del paquete NPM
219
+ - ✅ **Sin cambios en el workflow** de desarrollo
220
+ - ✅ **Validación completa** antes de publicar
221
+ - ✅ **Transición suave** al paquete real
222
+ - ✅ **Mantenimiento fácil** del código
223
+
224
+ ## 🔧 Configuración del cliente
225
+
226
+ Los clientes pueden mantener su `vite.config.ts` local con configuración específica:
227
+
228
+ ```typescript
229
+ // vite.config.ts del cliente
230
+ import type { ClientConfig } from "@griddo/bundler/types";
231
+
232
+ const config: ClientConfig = {
233
+ plugins: [
234
+ // Plugins específicos del cliente
235
+ ],
236
+ build: {
237
+ rollupOptions: {
238
+ external: (id) => {
239
+ // Dependencias externas específicas
240
+ if (id === "cliente-paquete-pesado") return true;
241
+ return false;
242
+ },
243
+ },
244
+ },
245
+ };
246
+
247
+ export default config;
248
+ ```
249
+
250
+ El master bundler combinará esta configuración con la suya propia.
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@hiscovega/vundle",
3
+ "version": "0.0.5",
4
+ "description": "Master bundler configuration for Griddo Instance projects",
5
+ "main": "vite.config.mjs",
6
+ "module": "vite.config.mjs",
7
+ "types": "types/client-config.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./vite.config.mjs",
12
+ "import": "./vite.config.mjs"
13
+ },
14
+ "./vite.config": {
15
+ "types": "./vite.config.mjs",
16
+ "import": "./vite.config.mjs"
17
+ },
18
+ "./plugins": {
19
+ "types": "./plugins/index.d.ts",
20
+ "import": "./plugins/index.mjs"
21
+ },
22
+ "./types": {
23
+ "types": "./types/client-config.d.ts"
24
+ },
25
+ "./types/client-config": {
26
+ "types": "./types/client-config.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "vite.config.mjs",
31
+ "plugins/",
32
+ "types/",
33
+ "README.md"
34
+ ],
35
+ "scripts": {
36
+ "remote:build": "vite build --config ./vite.config.mjs",
37
+ "lint": "biome check .",
38
+ "lint:fix": "biome check --write .",
39
+ "format": "biome format --write .",
40
+ "format:check": "biome format .",
41
+ "prepublishOnly": "npm run lint && npm run format:check",
42
+ "prepare": "npm run lint",
43
+ "release": "release-it",
44
+ "release:dry": "release-it --dry-run",
45
+ "release:minor": "release-it minor",
46
+ "release:major": "release-it major",
47
+ "release:patch": "release-it patch"
48
+ },
49
+ "dependencies": {
50
+ "@vitejs/plugin-react": "^5.0.2",
51
+ "vite": "^6.0.0",
52
+ "vite-plugin-dts": "^5.0.0-beta.6",
53
+ "vite-plugin-static-copy": "^3.1.2"
54
+ },
55
+ "peerDependencies": {
56
+ "@griddo/core": "^11.0.0",
57
+ "react": "^18.2.0",
58
+ "react-dom": "^18.2.0"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@griddo/core": {
62
+ "optional": false
63
+ },
64
+ "react": {
65
+ "optional": false
66
+ },
67
+ "react-dom": {
68
+ "optional": false
69
+ }
70
+ },
71
+ "repository": {
72
+ "type": "git",
73
+ "url": "https://github.com/griddo/griddo-bundler.git"
74
+ },
75
+ "homepage": "https://github.com/griddo/griddo-bundler#readme",
76
+ "bugs": {
77
+ "url": "https://github.com/griddo/griddo-bundler/issues"
78
+ },
79
+ "keywords": [
80
+ "griddo",
81
+ "bundler",
82
+ "vite",
83
+ "build",
84
+ "configuration",
85
+ "esm",
86
+ "esmodules",
87
+ "release-it",
88
+ "conventional-changelog"
89
+ ],
90
+ "author": "Griddo",
91
+ "license": "MIT",
92
+ "engines": {
93
+ "node": ">=18.0.0"
94
+ },
95
+ "devDependencies": {
96
+ "@biomejs/biome": "^2.2.2",
97
+ "@release-it/conventional-changelog": "^10.0.1",
98
+ "release-it": "^19.0.4"
99
+ }
100
+ }
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "vite";
2
+
3
+ export declare const plugins: Plugin[];
@@ -0,0 +1,26 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import dts from "vite-plugin-dts";
3
+
4
+ import { viteStaticCopy } from "vite-plugin-static-copy";
5
+
6
+ export const plugins = [
7
+ react(),
8
+
9
+ dts({
10
+ insertTypesEntry: true,
11
+ include: ["src"],
12
+ exclude: ["src/**/*.test.*", "src/**/*.spec.*", "src/builder/**/*.jsx"],
13
+ entryRoot: "src",
14
+ compilerOptions: {
15
+ declaration: true,
16
+ emitDeclarationOnly: false,
17
+ },
18
+ }),
19
+
20
+ viteStaticCopy({
21
+ targets: [
22
+ { src: "static", dest: "" },
23
+ { src: "thumbnails", dest: "" },
24
+ ],
25
+ }),
26
+ ];
@@ -0,0 +1,25 @@
1
+ import type { UserConfig } from "vite";
2
+
3
+ /**
4
+ * Configuración del cliente.
5
+ * Extiende la configuración de usuario de Vite (`UserConfig`) con opciones
6
+ * específicas para el ecosistema de Griddo.
7
+ */
8
+ export interface ClientConfig extends UserConfig {
9
+ /**
10
+ * Opciones específicas para la integración con el bundler de Griddo.
11
+ */
12
+ griddoOptions?: {
13
+ /**
14
+ * Proporciona un array de dependencias para marcar como externas durante el build.
15
+ * Puedes usar strings para coincidencias exactas o RegExp para patrones.
16
+ *
17
+ * @example
18
+ * customExternals: [
19
+ * 'moment', // Marcar 'moment' como externo
20
+ * /^@my-scope\// // Marcar cualquier paquete bajo '@my-scope/' como externo
21
+ * ]
22
+ */
23
+ customExternals?: (string | RegExp)[];
24
+ };
25
+ }
@@ -0,0 +1,114 @@
1
+ import { resolve } from "node:path";
2
+ import { defineConfig, loadConfigFromFile, mergeConfig } from "vite";
3
+
4
+ import { plugins as masterPlugins } from "./plugins/index";
5
+
6
+ export default defineConfig(async ({ command, mode }) => {
7
+ let clientConfig = {};
8
+
9
+ // --- Lógica de Carga de Configuración del Cliente Mejorada ---
10
+ // Usamos la función nativa de Vite para encontrar, cargar y transpilar
11
+ // la configuración del cliente, soportando .ts, .js, .mjs, etc.
12
+ try {
13
+ const clientConfigResult = await loadConfigFromFile(
14
+ { command, mode },
15
+ // Dejamos el segundo argumento como undefined para que Vite busque el nombre por defecto
16
+ // (vite.config.ts, vite.config.js, etc.)
17
+ undefined,
18
+ // Especificamos la ruta raíz donde se encuentra el proyecto del cliente
19
+ resolve(__dirname, "../../"),
20
+ );
21
+
22
+ if (clientConfigResult) {
23
+ clientConfig = clientConfigResult.config;
24
+ console.log(`Configuración del cliente cargada desde: ${clientConfigResult.path}`);
25
+ } else {
26
+ console.log("No se encontró configuración del cliente, usando configuración base del master.");
27
+ }
28
+ // biome-ignore lint/correctness/noUnusedVariables: No error, only byass with a console.log
29
+ } catch (e) {
30
+ // Si 'loadConfigFromFile' no encuentra el archivo, devuelve null en lugar de lanzar un error.
31
+ // Este catch es para errores de sintaxis dentro del archivo de config del cliente u otros problemas.
32
+ console.log(
33
+ "No se pudo cargar la configuración del cliente (posible error de sintaxis), usando configuración base del master.",
34
+ );
35
+ }
36
+ // --- Fin de la Lógica de Carga ---
37
+
38
+ // --- Configuración Base del Master ---
39
+ // (El resto del archivo no cambia)
40
+ const masterConfig = {
41
+ logLevel: "warn",
42
+ publicDir: "static",
43
+ define: { global: "globalThis" },
44
+ plugins: masterPlugins,
45
+ build: {
46
+ reportCompressedSize: false,
47
+ lib: {
48
+ entry: {
49
+ index: resolve(__dirname, "../../src/index.tsx"),
50
+ builder: resolve(__dirname, "../../src/builder.jsx"),
51
+ },
52
+ formats: ["es"],
53
+ name: "GriddoInstance",
54
+ },
55
+ rollupOptions: {
56
+ preserveEntrySignatures: "strict",
57
+ external: (id) => {
58
+ // 1. Reglas 'external' del master (no se pueden sobreescribir)
59
+ const masterRules = ["@griddo/core", "react", "react-dom", "react/jsx-runtime", "prop-types"];
60
+ if (masterRules.some((pkg) => id === pkg || id.startsWith(`${pkg}/`))) {
61
+ return true;
62
+ }
63
+
64
+ // 2. Comprobar las reglas personalizadas definidas por el cliente.
65
+ // Esta es la nueva API declarativa.
66
+ const clientCustomExternals = clientConfig.griddoOptions?.customExternals || [];
67
+ for (const ext of clientCustomExternals) {
68
+ if (typeof ext === "string" && id === ext) return true;
69
+ if (ext instanceof RegExp && ext.test(id)) return true;
70
+ }
71
+
72
+ return false;
73
+ },
74
+ onwarn(warning, warn) {
75
+ if (warning.code === "DYNAMIC_IMPORT_ASSERTIONS" && warning.message.includes("moment")) {
76
+ return;
77
+ }
78
+ warn(warning);
79
+ },
80
+ output: {
81
+ dir: "dist",
82
+ format: "es",
83
+ entryFileNames: "[name].js",
84
+ assetFileNames: (assetInfo) => {
85
+ if (assetInfo.name?.endsWith(".css")) {
86
+ return "builder.css";
87
+ }
88
+ if (assetInfo.name?.match(/\.(png|jpe?g|gif|webp)$/)) {
89
+ return "assets/[name]-[hash][extname]";
90
+ }
91
+ return "assets/[name]-[hash][extname]";
92
+ },
93
+ },
94
+ },
95
+ sourcemap: true,
96
+ copyPublicDir: false,
97
+ cssCodeSplit: false,
98
+ },
99
+ };
100
+
101
+ // --- Fusión Final ---
102
+ // Antes de fusionar, nos aseguramos de que la configuración `external` del
103
+ // master nunca sea sobreescrita por el cliente. Esta es la clave para
104
+ // evitar la duplicación de React.
105
+ if (clientConfig.build?.rollupOptions?.external) {
106
+ console.log(
107
+ "WARN: The client-defined 'build.rollupOptions.external' property will be ignored. Use 'griddoOptions.customExternals' instead.",
108
+ );
109
+ delete clientConfig.build.rollupOptions.external;
110
+ }
111
+
112
+ // Una única llamada a mergeConfig fusiona de forma inteligente ambas configuraciones.
113
+ return mergeConfig(masterConfig, clientConfig);
114
+ });