odoro 0.1.3 → 0.1.4
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/dist/{build-SQAC7ORR.js → build-J2J3NBV5.js} +1 -1
- package/dist/{chunk-FTMPTVGL.js → chunk-JGXJBVI7.js} +38 -5
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/{package-AHYI62K6.js → package-VRJRDQY3.js} +1 -1
- package/package.json +1 -1
- package/templates/react-ts/README.md +5 -6
|
@@ -5,6 +5,8 @@ import { existsSync } from 'fs';
|
|
|
5
5
|
import { readFile, rm, mkdir, writeFile, cp, stat } from 'fs/promises';
|
|
6
6
|
import { join, basename, resolve, relative, sep } from 'path';
|
|
7
7
|
import { build } from 'esbuild';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
import { pathToFileURL } from 'url';
|
|
8
10
|
|
|
9
11
|
// src/build/elaguer.ts
|
|
10
12
|
var GROUPES = /* @__PURE__ */ new Set(["media", "supports", "layer", "container", "scope"]);
|
|
@@ -185,6 +187,18 @@ function decouperSelecteurs(selecteur) {
|
|
|
185
187
|
parts.push(selecteur.slice(debut).trim());
|
|
186
188
|
return parts.filter((p) => p.length > 0);
|
|
187
189
|
}
|
|
190
|
+
var FOURNISSEUR = "@odoro-cli/libs/generateur";
|
|
191
|
+
async function fournisseurDe(root) {
|
|
192
|
+
try {
|
|
193
|
+
const exiger = createRequire(join(root, "package.json"));
|
|
194
|
+
const chemin = exiger.resolve(FOURNISSEUR);
|
|
195
|
+
const module_ = await import(pathToFileURL(chemin).href);
|
|
196
|
+
if (typeof module_.renderUtilitairesPour !== "function") return void 0;
|
|
197
|
+
return { renderUtilitairesPour: module_.renderUtilitairesPour };
|
|
198
|
+
} catch {
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
188
202
|
|
|
189
203
|
// src/build/build.ts
|
|
190
204
|
function toPosix(path) {
|
|
@@ -215,7 +229,7 @@ function outputsForEntry(result, entry, outDir, root) {
|
|
|
215
229
|
}
|
|
216
230
|
return { script: void 0, styles: [] };
|
|
217
231
|
}
|
|
218
|
-
async function
|
|
232
|
+
async function taillerFeuilles(result, config, html) {
|
|
219
233
|
const produits = Object.keys(result.metafile.outputs).map((f) => resolve(config.root, f));
|
|
220
234
|
const feuilles = produits.filter((f) => f.endsWith(".css"));
|
|
221
235
|
if (feuilles.length === 0) return;
|
|
@@ -223,12 +237,31 @@ async function elaguerFeuilles(result, config, html) {
|
|
|
223
237
|
for (const fichier of produits) {
|
|
224
238
|
if (fichier.endsWith(".js")) sources.push(await readFile(fichier, "utf8"));
|
|
225
239
|
}
|
|
240
|
+
const fournisseur = await fournisseurDe(config.root);
|
|
241
|
+
const employes = /* @__PURE__ */ new Set();
|
|
242
|
+
if (fournisseur !== void 0) {
|
|
243
|
+
for (const source of sources) for (const mot of motsDe(source)) employes.add(mot);
|
|
244
|
+
for (const garde of config.build.safelist) {
|
|
245
|
+
if (typeof garde === "string") employes.add(garde);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
226
248
|
for (const feuille of feuilles) {
|
|
227
249
|
const avant = await readFile(feuille, "utf8");
|
|
228
|
-
|
|
229
|
-
|
|
250
|
+
if (fournisseur === void 0) {
|
|
251
|
+
const rapport = elaguer(avant, sources, { sauvegarde: config.build.safelist });
|
|
252
|
+
await writeFile(feuille, rapport.css, "utf8");
|
|
253
|
+
info(
|
|
254
|
+
` ${colors.dim("elagage")} ${basename(feuille)} ${size(rapport.octetsAvant)} \u2192 ${size(rapport.octetsApres)} ${colors.dim(`${String(rapport.gardees)} classes gardees`)}`
|
|
255
|
+
);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const socle = elaguer(avant, [], {}).css;
|
|
259
|
+
const utilitaires = fournisseur.renderUtilitairesPour(employes);
|
|
260
|
+
const apres = `${socle}
|
|
261
|
+
${utilitaires}`;
|
|
262
|
+
await writeFile(feuille, apres, "utf8");
|
|
230
263
|
info(
|
|
231
|
-
` ${colors.dim("
|
|
264
|
+
` ${colors.dim("generation")} ${basename(feuille)} ${size(Buffer.byteLength(avant))} \u2192 ${size(Buffer.byteLength(apres))}`
|
|
232
265
|
);
|
|
233
266
|
}
|
|
234
267
|
}
|
|
@@ -305,7 +338,7 @@ async function buildProject(config) {
|
|
|
305
338
|
}
|
|
306
339
|
]
|
|
307
340
|
});
|
|
308
|
-
if (config.build.elaguer) await
|
|
341
|
+
if (config.build.elaguer) await taillerFeuilles(result, config, html);
|
|
309
342
|
let output = html;
|
|
310
343
|
for (const entry of entries) {
|
|
311
344
|
const { script, styles } = outputsForEntry(
|
package/dist/cli.js
CHANGED
|
@@ -130,7 +130,7 @@ function rootFrom(flags, positional) {
|
|
|
130
130
|
async function run(argv) {
|
|
131
131
|
const { command, positional, flags } = parseArgs(argv);
|
|
132
132
|
if (flags["version"] === true) {
|
|
133
|
-
const manifest = await import('./package-
|
|
133
|
+
const manifest = await import('./package-VRJRDQY3.js');
|
|
134
134
|
console.log(manifest.default.version);
|
|
135
135
|
return 0;
|
|
136
136
|
}
|
|
@@ -160,7 +160,7 @@ async function run(argv) {
|
|
|
160
160
|
return new Promise(() => void 0);
|
|
161
161
|
}
|
|
162
162
|
case "build": {
|
|
163
|
-
const { buildProject, reportBuild } = await import('./build-
|
|
163
|
+
const { buildProject, reportBuild } = await import('./build-J2J3NBV5.js');
|
|
164
164
|
const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
|
|
165
165
|
const output = await buildProject(config);
|
|
166
166
|
reportBuild(output, process.cwd());
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
export { defineConfig, loadConfig } from './chunk-Q35CGY2Z.js';
|
|
3
3
|
import './chunk-T6RLHSCW.js';
|
|
4
|
-
export { buildProject, reportBuild } from './chunk-
|
|
4
|
+
export { buildProject, reportBuild } from './chunk-JGXJBVI7.js';
|
|
5
5
|
export { ModuleGraph, depFileName, detectSelfAccepting, optimizeDeps, scanDependencies, startDevServer } from './chunk-G5QXVBYT.js';
|
|
6
6
|
export { startPreviewServer } from './chunk-2YDI5NKV.js';
|
|
7
7
|
import './chunk-JMEHF3KN.js';
|
package/package.json
CHANGED
|
@@ -34,13 +34,12 @@ Toutes les valeurs visuelles passent par des variables CSS. Surcharger
|
|
|
34
34
|
`--o-palette-brand-600` dans `src/styles.css` retheme l'application **et** les
|
|
35
35
|
composants de la librairie, sans toucher a leur code.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Une seule feuille de style : `@odoro-cli/libs/styles.css`, a importer une fois
|
|
38
|
+
a la racine de l'application.
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Importer l'une **ou** l'autre, jamais les deux.
|
|
40
|
+
Elle pese 1,7 Mo sur le disque, mais ce n'est pas ce que vos visiteurs
|
|
41
|
+
telechargent : la compilation n'en garde que les classes que votre code
|
|
42
|
+
emploie reellement — quelques dizaines de kilooctets en pratique.
|
|
44
43
|
|
|
45
44
|
## Rechargement a chaud
|
|
46
45
|
|