@open-xchange/vite-plugin-project-meta 0.0.2 → 0.0.3

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3] - 2024-07-30
4
+
5
+ - changed: e-tag hash depends on build date instead of package version
6
+
3
7
  ## [0.0.2] - 2024-07-30
4
8
 
5
9
  - added: generate `<meta name="etag-fix" ...>` for HTML entry files
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { join } from "node:path";
8
8
  import { readFileSync } from "node:fs";
9
+ import { createHash } from "node:crypto";
9
10
  // constants ==================================================================
10
11
  export const PROJECT_NAME = "@open-xchange/vite-plugin-project-meta";
11
12
  // plugin =====================================================================
@@ -49,11 +50,10 @@ export default function vitePluginProjectMeta(options) {
49
50
  if (!context.bundle) {
50
51
  return;
51
52
  }
52
- const len = Number.parseInt(metadata.version.replaceAll(".", ""), 10) % 42 + 42;
53
- let content = "";
54
- for (let i = 0; i < len; i += 1) {
55
- content += String.fromCharCode(97 + Math.floor(Math.random() * 26));
56
- }
53
+ const hash = createHash("md5").update(metadata.builddate).digest("hex");
54
+ const len = Number.parseInt(hash.slice(0, 4), 16) % 99 + 42;
55
+ const count = Math.ceil(len / hash.length);
56
+ const content = hash.repeat(count).slice(0, len);
57
57
  return [{
58
58
  tag: "meta",
59
59
  attrs: { name: "etag-fix", content },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/vite-plugin-project-meta",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Vite plugin providing a virtual import for project metadata",
5
5
  "repository": {
6
6
  "url": "https://gitlab.open-xchange.com/fspd/npm-packages/vite-plugin-project-meta"