-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for yarn workspaces #31
Comments
I just bumped into this as well. As a workaround, you can use the ConnectionOptionsReader directly to get options from any folder/file you like. My connection stuff is still a bit messy, but I'll post it here as an example. Note that I apply the name "default" to my config so the import * as fs from 'fs';
import * as path from 'path';
import { createConnection, Connection, ConnectionOptionsReader } from "typeorm";
const connectionOptionsReader = new ConnectionOptionsReader({
// TODO: Maybe look in every folder up from CWD
root: process.cwd()
});
let connectionOptions;
let connection;
export default async function connect (): Promise<Connection> {
if (!connection) {
connectionOptions = {
...(await connectionOptionsReader.get(process.env.TYPEORM_CONNECTION || 'default')),
entities: [__dirname + "/entity/**/*.js"],
migrations: [__dirname + "/migration/**/*.js"],
subscribers: [__dirname + "/subscriber/**/*.js"]
};
connection = createConnection(connectionOptions);
}
return connection;
} Checking in I also found it convenient to set the Hope that's helpful |
I figure out another workaround. You can use yarn's If you put this in your subproject/package.json and re-install packages (I usually do
|
I recently ran into this issue with Typeorm specifically as well. @sgronblo's solution was great for Yarn v1, but if you're using Yarn v2–v3, you will likely need a nodeLinker: node-modules
nmHoistingLimits: workspaces Now run (You can now safely remove the deprecated
This article also explains more about Yarn's decision to change away from P.S. if you're switching from Yarn v1 to v2+, I recommend reading their step-by-step upgrade guide. |
Does anyone have any recommendations on how to handle workspaces? |
I suppose we could read the |
@inxilpro This is my goto package and just realised it's not bulletproof under yarn workspaces! Would be keen to help with this. regarding looking for
Do you have any other ideas of how we could solve this? |
Oof, that seems like a nightmare to resolve. I think the first step is to try to enumerate all the different cases that we need to account for and the expected behavior. Maybe you could start there and see if anyone has comments? |
It should be safe to just check the And if not, we keep traversing up the tree until we find a |
Hey,
Currently the package is not compatible with yarn workspaces/lerna.
Example of issue you can find here: typeorm/typeorm#2805
Is there any way to support yarn workspaces/lerna for monorepo solutions?
Regards,
TheAifam5
The text was updated successfully, but these errors were encountered: