@hiscovega/vundle 0.0.16 → 0.1.0
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/CHANGELOG.md +9 -0
- package/README.md +4 -0
- package/package.json +1 -1
- package/plugins/index.mjs +66 -0
- package/vite.config.mjs +100 -90
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# [0.1.0](https://github.com/griddo/vundle/compare/v0.0.17...v0.1.0) (2026-01-29)
|
|
4
|
+
|
|
5
|
+
## [0.0.17](https://github.com/griddo/vundle/compare/v0.0.16...v0.0.17) (2026-01-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add griddoDeployHashPlugin to include Git commit hash in build output ([d0dbe0e](https://github.com/griddo/vundle/commit/d0dbe0ee57bb19fd199e0fdd7e4036311d3c67fd))
|
|
11
|
+
|
|
3
12
|
## [0.0.16](https://github.com/griddo/vundle/compare/v0.0.15...v0.0.16) (2026-01-21)
|
|
4
13
|
|
|
5
14
|
## [0.0.15](https://github.com/griddo/griddo-bundler/compare/v0.0.14...v0.0.15) (2026-01-21)
|
package/README.md
CHANGED
package/package.json
CHANGED
package/plugins/index.mjs
CHANGED
|
@@ -1,8 +1,72 @@
|
|
|
1
1
|
import react from "@vitejs/plugin-react";
|
|
2
2
|
// import dts from "vite-plugin-dts";
|
|
3
3
|
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
5
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
4
7
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
5
8
|
|
|
9
|
+
const griddoDeployHashPlugin = () => {
|
|
10
|
+
/** @type {import("vite").ResolvedConfig | undefined} */
|
|
11
|
+
let resolvedConfig;
|
|
12
|
+
|
|
13
|
+
const getOutputDirs = () => {
|
|
14
|
+
/** @type {string[]} */
|
|
15
|
+
const dirs = [];
|
|
16
|
+
|
|
17
|
+
const output = resolvedConfig?.build?.rollupOptions?.output;
|
|
18
|
+
const outputs = Array.isArray(output) ? output : output ? [output] : [];
|
|
19
|
+
|
|
20
|
+
for (const o of outputs) {
|
|
21
|
+
if (typeof o?.dir === "string" && o.dir) dirs.push(o.dir);
|
|
22
|
+
if (typeof o?.file === "string" && o.file) dirs.push(path.dirname(o.file));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (dirs.length === 0) {
|
|
26
|
+
const outDir = resolvedConfig?.build?.outDir || "dist";
|
|
27
|
+
dirs.push(outDir);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return [...new Set(dirs)];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getGitHash = () => {
|
|
34
|
+
try {
|
|
35
|
+
return execSync("git rev-parse HEAD", {
|
|
36
|
+
cwd: resolvedConfig?.root || process.cwd(),
|
|
37
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
38
|
+
})
|
|
39
|
+
.toString()
|
|
40
|
+
.trim();
|
|
41
|
+
} catch {
|
|
42
|
+
// Fallbacks típicos en CI
|
|
43
|
+
return (
|
|
44
|
+
process.env.GITHUB_SHA || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CF_PAGES_COMMIT_SHA || "unknown"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
name: "griddo-deploy-hash",
|
|
51
|
+
apply: "build",
|
|
52
|
+
configResolved(config) {
|
|
53
|
+
resolvedConfig = config;
|
|
54
|
+
},
|
|
55
|
+
async closeBundle() {
|
|
56
|
+
const hash = getGitHash();
|
|
57
|
+
const outputDirs = getOutputDirs();
|
|
58
|
+
|
|
59
|
+
await Promise.all(
|
|
60
|
+
outputDirs.map(async (dir) => {
|
|
61
|
+
const absoluteDir = path.isAbsolute(dir) ? dir : path.join(resolvedConfig?.root || process.cwd(), dir);
|
|
62
|
+
await mkdir(absoluteDir, { recursive: true });
|
|
63
|
+
await writeFile(path.join(absoluteDir, "_griddo-ds-deploy-hash"), `${hash}\n`, "utf8");
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
6
70
|
export const plugins = [
|
|
7
71
|
react(),
|
|
8
72
|
|
|
@@ -26,4 +90,6 @@ export const plugins = [
|
|
|
26
90
|
{ src: "thumbnails", dest: "" },
|
|
27
91
|
],
|
|
28
92
|
}),
|
|
93
|
+
|
|
94
|
+
griddoDeployHashPlugin(),
|
|
29
95
|
];
|
package/vite.config.mjs
CHANGED
|
@@ -1,106 +1,127 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { defineConfig, loadConfigFromFile, mergeConfig } from "vite";
|
|
3
4
|
import { plugins as masterPlugins } from "./plugins/index.mjs";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
let clientConfig = {};
|
|
6
|
+
// --- Constantes y Configuración Estática ---
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const CWD = process.cwd();
|
|
9
|
+
|
|
10
|
+
const MASTER_EXTERNAL_RULES = [
|
|
11
|
+
"@griddo/core",
|
|
12
|
+
"react",
|
|
13
|
+
"react-dom",
|
|
14
|
+
"react/jsx-runtime",
|
|
15
|
+
"react/jsx-dev-runtime",
|
|
16
|
+
"prop-types",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// --- Helpers y Utilidades ---
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Busca un archivo de entrada probando múltiples extensiones.
|
|
23
|
+
* Prioridad: TypeScript/JSX > JavaScript
|
|
24
|
+
* * @param {string} name - El nombre base del archivo (ej: 'index', 'builder')
|
|
25
|
+
* @returns {string} La ruta absoluta al archivo encontrado o el fallback .js
|
|
26
|
+
*/
|
|
27
|
+
const resolveEntry = (name) => {
|
|
28
|
+
// Definimos el orden de prioridad.
|
|
29
|
+
// Primero busca versiones TS/React, luego JS puro.
|
|
30
|
+
const extensions = [".tsx", ".ts", ".jsx", ".js"];
|
|
31
|
+
|
|
32
|
+
for (const ext of extensions) {
|
|
33
|
+
const filePath = path.resolve(CWD, "src", `${name}${ext}`);
|
|
34
|
+
if (fs.existsSync(filePath)) {
|
|
35
|
+
console.log("filePath ->", filePath);
|
|
36
|
+
return filePath;
|
|
14
37
|
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Si no encuentra ninguno, devuelve la ruta .js por defecto
|
|
41
|
+
// (Vite lanzará error después si este tampoco existe, lo cual es correcto)
|
|
42
|
+
return path.resolve(CWD, "src", `${name}.js`);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getAssetFileName = (assetInfo) => {
|
|
46
|
+
if (assetInfo.name?.endsWith(".css")) return "builder.css";
|
|
47
|
+
if (assetInfo.name?.match(/\.(png|jpe?g|gif|webp)$/)) {
|
|
15
48
|
return "assets/[name]-[hash][extname]";
|
|
16
|
-
}
|
|
49
|
+
}
|
|
50
|
+
return "assets/[name]-[hash][extname]";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const normalizeExternalParam = (externalParam) => {
|
|
54
|
+
if (!externalParam) return () => false;
|
|
55
|
+
if (typeof externalParam === "function") return externalParam;
|
|
56
|
+
|
|
57
|
+
const externals = Array.isArray(externalParam) ? externalParam : [externalParam];
|
|
17
58
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
for (const ext of externals) {
|
|
25
|
-
if (typeof ext === "string" && (id === ext || id.startsWith(`${ext}/`))) return true;
|
|
26
|
-
if (ext instanceof RegExp && ext.test(id)) return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
59
|
+
return (id) => {
|
|
60
|
+
for (const ext of externals) {
|
|
61
|
+
if (typeof ext === "string" && (id === ext || id.startsWith(`${ext}/`))) return true;
|
|
62
|
+
if (ext instanceof RegExp && ext.test(id)) return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
30
65
|
};
|
|
66
|
+
};
|
|
31
67
|
|
|
32
|
-
|
|
33
|
-
// la configuración del cliente, soportando .ts, .js, .mjs, etc.
|
|
68
|
+
const loadClientConfig = async (command, mode) => {
|
|
34
69
|
try {
|
|
35
|
-
console.log(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
undefined,
|
|
42
|
-
// Especificamos la ruta raíz donde se encuentra el proyecto del cliente
|
|
43
|
-
process.cwd(),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (clientConfigResult) {
|
|
47
|
-
clientConfig = clientConfigResult.config;
|
|
48
|
-
console.log(`Client configuration loaded from: ${clientConfigResult.path}`);
|
|
49
|
-
} else {
|
|
50
|
-
console.log("No client configuration found, using master base configuration.");
|
|
70
|
+
console.log("Looking for instance configuration...");
|
|
71
|
+
const result = await loadConfigFromFile({ command, mode }, undefined, CWD);
|
|
72
|
+
|
|
73
|
+
if (result) {
|
|
74
|
+
console.log(`Instance configuration loaded from: ${result.path}`);
|
|
75
|
+
return result.config;
|
|
51
76
|
}
|
|
77
|
+
console.log("No instance configuration found, using Griddo base configuration.");
|
|
52
78
|
} catch (e) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(`Error loading client configuration: ${e.message}`);
|
|
56
|
-
console.log("Using master base configuration.");
|
|
79
|
+
console.warn(`Error loading instance configuration: ${e.message}`);
|
|
80
|
+
console.warn("Using Griddo base configuration.");
|
|
57
81
|
}
|
|
82
|
+
return {};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// --- Configuración Principal ---
|
|
86
|
+
|
|
87
|
+
export default defineConfig(async ({ command, mode }) => {
|
|
88
|
+
const clientConfig = await loadClientConfig(command, mode);
|
|
89
|
+
|
|
90
|
+
const checkClientStandardExternal = normalizeExternalParam(clientConfig.build?.rollupOptions?.external);
|
|
91
|
+
const clientCustomExternals = clientConfig.griddoOptions?.customExternals || [];
|
|
92
|
+
|
|
93
|
+
const unifiedExternalHandler = (id, importer, isResolved) => {
|
|
94
|
+
if (MASTER_EXTERNAL_RULES.some((pkg) => id === pkg || id.startsWith(`${pkg}/`))) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
for (const ext of clientCustomExternals) {
|
|
98
|
+
if (typeof ext === "string" && id === ext) return true;
|
|
99
|
+
if (ext instanceof RegExp && ext.test(id)) return true;
|
|
100
|
+
}
|
|
101
|
+
return checkClientStandardExternal(id, importer, isResolved);
|
|
102
|
+
};
|
|
58
103
|
|
|
59
|
-
// --- Configuración Base del Master ---
|
|
60
104
|
const masterConfig = {
|
|
61
105
|
logLevel: "warn",
|
|
62
|
-
// El copiado de assets lo gestiona `vite-plugin-static-copy` y además
|
|
63
|
-
// `copyPublicDir` está desactivado; evitamos confusiones deshabilitando
|
|
64
|
-
// `publicDir` explícitamente.
|
|
65
106
|
publicDir: false,
|
|
66
107
|
define: { global: "globalThis" },
|
|
67
108
|
plugins: masterPlugins,
|
|
68
109
|
build: {
|
|
69
110
|
reportCompressedSize: false,
|
|
111
|
+
sourcemap: true,
|
|
112
|
+
copyPublicDir: false,
|
|
113
|
+
cssCodeSplit: false,
|
|
70
114
|
lib: {
|
|
115
|
+
name: "GriddoInstance",
|
|
71
116
|
entry: {
|
|
72
|
-
index:
|
|
73
|
-
builder:
|
|
74
|
-
"griddo.config":
|
|
117
|
+
index: resolveEntry("index"),
|
|
118
|
+
builder: resolveEntry("builder"),
|
|
119
|
+
"griddo.config": resolveEntry("griddo.config"),
|
|
75
120
|
},
|
|
76
|
-
name: "GriddoInstance",
|
|
77
121
|
},
|
|
78
122
|
rollupOptions: {
|
|
79
123
|
preserveEntrySignatures: "strict",
|
|
80
|
-
external:
|
|
81
|
-
// 1. Reglas 'external' del master (no se pueden sobreescribir)
|
|
82
|
-
const masterRules = [
|
|
83
|
-
"@griddo/core",
|
|
84
|
-
"react",
|
|
85
|
-
"react-dom",
|
|
86
|
-
"react/jsx-runtime",
|
|
87
|
-
"react/jsx-dev-runtime",
|
|
88
|
-
"prop-types",
|
|
89
|
-
];
|
|
90
|
-
if (masterRules.some((pkg) => id === pkg || id.startsWith(`${pkg}/`))) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// 2. Comprobar las reglas personalizadas definidas por el cliente.
|
|
95
|
-
// Esta es la nueva API declarativa.
|
|
96
|
-
const clientCustomExternals = clientConfig.griddoOptions?.customExternals || [];
|
|
97
|
-
for (const ext of clientCustomExternals) {
|
|
98
|
-
if (typeof ext === "string" && id === ext) return true;
|
|
99
|
-
if (ext instanceof RegExp && ext.test(id)) return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return false;
|
|
103
|
-
},
|
|
124
|
+
external: unifiedExternalHandler,
|
|
104
125
|
onwarn(warning, warn) {
|
|
105
126
|
if (warning.code === "DYNAMIC_IMPORT_ASSERTIONS" && warning.message.includes("moment")) {
|
|
106
127
|
return;
|
|
@@ -112,36 +133,25 @@ export default defineConfig(async ({ command, mode }) => {
|
|
|
112
133
|
dir: "dist",
|
|
113
134
|
format: "es",
|
|
114
135
|
entryFileNames: "[name].js",
|
|
115
|
-
assetFileNames:
|
|
136
|
+
assetFileNames: getAssetFileName,
|
|
116
137
|
},
|
|
117
138
|
{
|
|
118
139
|
dir: "dist",
|
|
119
140
|
format: "cjs",
|
|
120
141
|
entryFileNames: "[name].cjs",
|
|
121
142
|
exports: "named",
|
|
122
|
-
assetFileNames:
|
|
143
|
+
assetFileNames: getAssetFileName,
|
|
123
144
|
},
|
|
124
145
|
],
|
|
125
146
|
},
|
|
126
|
-
sourcemap: true,
|
|
127
|
-
copyPublicDir: false,
|
|
128
|
-
cssCodeSplit: false,
|
|
129
147
|
},
|
|
130
148
|
};
|
|
131
149
|
|
|
132
|
-
// --- Fusión Final ---
|
|
133
150
|
const merged = mergeConfig(masterConfig, clientConfig);
|
|
134
151
|
|
|
135
|
-
// Componemos externals: reglas del master (React/@griddo/core, etc.) + API declarativa
|
|
136
|
-
// `griddoOptions.customExternals` + `build.rollupOptions.external` estándar del cliente.
|
|
137
|
-
// Esto mantiene compatibilidad con Vite/Rollup sin permitir que el cliente "rebundee" React.
|
|
138
|
-
const clientExternal = toExternalFn(clientConfig.build?.rollupOptions?.external);
|
|
139
|
-
const masterExternal = toExternalFn(masterConfig.build?.rollupOptions?.external);
|
|
140
|
-
|
|
141
152
|
if (!merged.build) merged.build = {};
|
|
142
153
|
if (!merged.build.rollupOptions) merged.build.rollupOptions = {};
|
|
143
|
-
|
|
144
|
-
merged.build.rollupOptions.external = (id, ...args) => masterExternal(id, ...args) || clientExternal(id, ...args);
|
|
154
|
+
merged.build.rollupOptions.external = unifiedExternalHandler;
|
|
145
155
|
|
|
146
156
|
return merged;
|
|
147
157
|
});
|