@git-snitch/renderer 0.0.8 → 0.0.10

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/vite.config.ts +25 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-snitch/renderer",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,8 +35,8 @@
35
35
  "react-dom": "^19.2.5",
36
36
  "recharts": "3.8.0",
37
37
  "vite": "^8.0.8",
38
- "@git-snitch/core": "0.0.8",
39
- "@git-snitch/ui": "0.0.8"
38
+ "@git-snitch/core": "0.0.10",
39
+ "@git-snitch/ui": "0.0.10"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@testing-library/dom": "^10.4.1",
package/vite.config.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import tailwindcss from "@tailwindcss/vite";
2
2
  import viteReact from "@vitejs/plugin-react";
3
+ import { createRequire } from "node:module";
4
+ import { basename, dirname, resolve } from "node:path";
3
5
  import { fileURLToPath } from "node:url";
4
6
  import { defineConfig } from "vite";
5
7
 
@@ -7,9 +9,27 @@ import { createInlineHtmlPlugin } from "./src/inline-plugin";
7
9
 
8
10
  const packageDirectory = fileURLToPath(new URL(".", import.meta.url));
9
11
  const defaultTemplateModule = fileURLToPath(new URL("./src/custom-templates.ts", import.meta.url));
10
- const packageNodeModules = fileURLToPath(new URL("./node_modules/", import.meta.url));
11
12
  const customTemplateModule = process.env.GIT_SNITCH_TEMPLATE_MODULE;
12
13
 
14
+ const require = createRequire(import.meta.url);
15
+
16
+ function resolvePackageModule(specifier: string): string {
17
+ const entry = require.resolve(specifier);
18
+ return entry;
19
+ }
20
+
21
+ function resolvePackageRoot(pkgName: string): string {
22
+ const entry = require.resolve(pkgName);
23
+ let dir = dirname(entry);
24
+ while (basename(dir) !== pkgName && dirname(dir) !== dir) {
25
+ dir = dirname(dir);
26
+ }
27
+ return dir;
28
+ }
29
+
30
+ const reactRoot = resolvePackageRoot("react");
31
+ const reactDomRoot = resolvePackageRoot("react-dom");
32
+
13
33
  export default defineConfig({
14
34
  base: "./",
15
35
  build: {
@@ -30,9 +50,10 @@ export default defineConfig({
30
50
  resolve: {
31
51
  alias: {
32
52
  "@git-snitch/renderer": fileURLToPath(new URL("./src", import.meta.url)),
33
- react: `${packageNodeModules}react`,
34
- "react/jsx-dev-runtime": `${packageNodeModules}react/jsx-dev-runtime.js`,
35
- "react/jsx-runtime": `${packageNodeModules}react/jsx-runtime.js`,
53
+ react: resolve(reactRoot),
54
+ "react/jsx-dev-runtime": resolvePackageModule("react/jsx-dev-runtime"),
55
+ "react/jsx-runtime": resolvePackageModule("react/jsx-runtime"),
56
+ "react-dom": resolve(reactDomRoot),
36
57
  "virtual:git-snitch-custom-templates": customTemplateModule ?? defaultTemplateModule,
37
58
  },
38
59
  tsconfigPaths: true,