houdini-react 2.0.0-go.5 → 2.0.0-go.6

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 +8 -8
  2. package/postInstall.js +38 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "2.0.0-go.5",
3
+ "version": "2.0.0-go.6",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -35,7 +35,7 @@
35
35
  "express": "^4.18.2",
36
36
  "graphql": "^15.8.0",
37
37
  "graphql-yoga": "^4.0.4",
38
- "houdini": "^2.0.0-go.5",
38
+ "houdini": "^2.0.0-go.6",
39
39
  "react": "^19.0.0",
40
40
  "react-dom": "^19.0.0",
41
41
  "react-streaming-compat": "^0.3.18",
@@ -80,12 +80,12 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "houdini-react-darwin-x64": "2.0.0-go.5",
84
- "houdini-react-darwin-arm64": "2.0.0-go.5",
85
- "houdini-react-linux-x64": "2.0.0-go.5",
86
- "houdini-react-linux-arm64": "2.0.0-go.5",
87
- "houdini-react-win32-x64": "2.0.0-go.5",
88
- "houdini-react-win32-arm64": "2.0.0-go.5"
83
+ "houdini-react-darwin-x64": "2.0.0-go.6",
84
+ "houdini-react-darwin-arm64": "2.0.0-go.6",
85
+ "houdini-react-linux-x64": "2.0.0-go.6",
86
+ "houdini-react-linux-arm64": "2.0.0-go.6",
87
+ "houdini-react-win32-x64": "2.0.0-go.6",
88
+ "houdini-react-win32-arm64": "2.0.0-go.6"
89
89
  },
90
90
  "bin": "./shim.cjs",
91
91
  "scripts": {
package/postInstall.js CHANGED
@@ -4,7 +4,7 @@ const zlib = require('zlib')
4
4
  const https = require('https')
5
5
 
6
6
  // Adjust the version you want to install. You can also make this dynamic.
7
- const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.5'
7
+ const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.6'
8
8
 
9
9
  // Windows binaries end with .exe so we need to special case them.
10
10
  const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
@@ -87,11 +87,14 @@ async function downloadBinaryFromNpm() {
87
87
 
88
88
  function isPlatformSpecificPackageInstalled() {
89
89
  try {
90
- // Resolving will fail if the optionalDependency was not installed
91
- require.resolve(`${platformSpecificPackageName}/bin/${binaryName}`)
90
+ // Try to resolve the platform package itself
91
+ require.resolve(`${platformSpecificPackageName}/package.json`)
92
92
  return true
93
93
  } catch (e) {
94
- return false
94
+ // Also check if it exists as a sibling directory
95
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
96
+ const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
97
+ return fs.existsSync(siblingBinaryPath)
95
98
  }
96
99
  }
97
100
 
@@ -100,17 +103,44 @@ if (!platformSpecificPackageName) {
100
103
  }
101
104
 
102
105
  // once we've confirmed the required package is installed we want to overwrite the bin entry of our package.json
103
- // to point to the correct binary
106
+ // to point to the correct binary for optimal performance (skip Node.js overhead)
104
107
  function overwriteBinary() {
105
108
  const packageJsonPath = path.join(__dirname, 'package.json')
106
109
  const packageJson = require(packageJsonPath)
107
- packageJson.bin = path.join('..', platformSpecificPackageName, 'bin', binaryName)
108
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
110
+
111
+ let binaryPath = null
112
+
113
+ try {
114
+ // Method 1: Use require.resolve to find the actual path to the platform-specific package
115
+ // This works with pnpm and other package managers that use symlinks
116
+ const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`)
117
+ const platformPackageDir = path.dirname(platformPackagePath)
118
+ binaryPath = path.join(platformPackageDir, 'bin', binaryName)
119
+ } catch (error) {
120
+ // Method 2: Check if platform package is installed as a sibling directory
121
+ // This works with npm and local installs
122
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
123
+ const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
124
+
125
+ if (fs.existsSync(siblingBinaryPath)) {
126
+ binaryPath = siblingBinaryPath
127
+ } else {
128
+ // Use shim as fallback
129
+ return
130
+ }
131
+ }
132
+
133
+ if (binaryPath) {
134
+ // Make the path relative to the main package directory
135
+ const relativeBinaryPath = path.relative(__dirname, binaryPath)
136
+ packageJson.bin = relativeBinaryPath
137
+
138
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
139
+ }
109
140
  }
110
141
 
111
142
  // Skip downloading the binary if it was already installed via optionalDependencies
112
143
  if (!isPlatformSpecificPackageInstalled()) {
113
- console.log('Platform specific package not found. Will manually download binary.')
114
144
  downloadBinaryFromNpm().then(overwriteBinary)
115
145
  } else {
116
146
  overwriteBinary()