Howdy!
First off—great work here. This project feels like a game changer. I'm so excited to be a part of it's evolution however possible.
I've been experimenting with using Photon in a monorepo, and using parcel to bundle certain pages for deployment out to lambdas. As such, there are some path changes and other things that get moved around a bit in the process.
When testing the package independently, Photon works as expected, however after the package contents get bundled into a singular file, it is no longer able to connect.
My entry point for the package consuming Photon returns a promise with the connected photon
object:
index.ts
import Photon from '@generated/photon'
import { inspect } from 'util';
function initPhoton(photonConfig: any = {}) {
const photon = new Photon(photonConfig);
return photon.connect()
.then(() => {
console.log('photon connected');
return photon;
})
.catch(error => {
console.error('photon connection error', error);
console.log(inspect(photon, { depth: 3, colors: true }));
return false;
});
}
export default initPhoton;
export { default as Photon } from '@generated/photon';
The file above is compiled via tsc
and consumed by other packages within the project. I wrote a small test file within the same package to validate that it behaves as expected. This file simple imports the module as it is exported from the compiled artifact of the file above.
test.js
const initPhoton = require('./dist/index').default;
initPhoton()
.then(photon => photon && photon.organizations.create({
data: {
access_token: '126', scope: '126', team_id: '126', team_name: '126', user_id: '126',
},
}))
.then(console.log)
.catch(console.error)
.then(() => process.exit());
When I run the file above, via node test.js
, it appears to execute as expected. Returning the entry as it is written to the database.
However, if I bundle the the test.js
file using the command below, invoking the same file no longer works.
npx parcel build test.js --target node --bundle-node-modules -d testDist
node testDist/test.js
I've been having trouble determining an actual source of the connection error. The connect()
promise usually rejects with a value of 1
however if I copy the prisma
folder into the testDist
directory, the connectionPromise
rejects with:
{ Error: spawn EACCES
at ChildProcess.spawn (internal/child_process.js:313:11)
at Object.exports.spawn (child_process.js:508:9)
at t.default.start (/Users/eschoellhorn/Repos/praisely-slackbot/packages/praisely-data/testDist/test.js:50:110668)
at y.start (/Users/eschoellhorn/Repos/praisely-slackbot/packages/praisely-data/testDist/test.js:50:21187)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3 errno: 'EACCES', code: 'EACCES', syscall: 'spawn' }
I have experimented with trying to alter the cwd
prop for the engine to point to an existing prisma
folder but haven't been able to affect much meaningful change. Happy to keep trying, but could use some pointers...
Thanks and, again, awesome work!!