Comments (9)
I don't have time to look into it now, but I suspect it has something to do with the fact that you reference the source from @repo/sftp directly without building/bundling. I didn't test this method extensively, because my own projects use bundling on all packages.
What you could try as a workaround maybe is to add "ssh2-sftp-client" as a dependency to the firebase service that uses @repo/sftp, or add bundling to @repo/sftp.
from isolate-package.
I think there must be something wrong with the way you configured things. Please read the section on prerequisites
If you then still can't make it work, please share some additional info about how you declared it as a dependency, and share your package manifest.
from isolate-package.
In addition, you can follow the troubleshooting instructions and inspect the output in the isolate directory.
from isolate-package.
Thanks for the quick reply, I'm pretty sure its all set up right. I've tried with the firebase-tools-with-isolate package too, and same result.
It works fine so long as my @repo/sftp method doesn't reference the dependent package (ssh2-sftp-client) but as soon as it does firebase won't deploy.
Firebase manifest
{
"name": "functions",
"version": "0.0.0",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"files": [
"dist",
".env.*"
],
"scripts": {
"type:check": "tsc --noEmit",
"build": "tsup-node",
"build:watch": "tsup-node --watch",
"emulate": "firebase emulators:start --only functions",
"dev": "run-p build:watch emulate",
"lint": "eslint . --max-warnings 0",
"deploy": "firebase deploy --only functions"
},
"engines": {
"node": "20"
},
"dependencies": {
"@google-cloud/functions-framework": "^3.3.0",
"@repo/sftp": "workspace:*",
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/node": "^20.11.17",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"firebase-functions-test": "^3.1.0",
"firebase-tools": "^13.3.0",
"isolate-package": "^1.9.4",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
"private": true
}
@repo/sftp
{
"name": "@repo/sftp",
"version": "0.0.0",
"type": "module",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts"
},
"files": [
"src"
],
"scripts": {
"?build": "This package is links directly to its source files",
"type-check": "tsc --noEmit",
"test": "vitest",
"coverage": "vitest run --coverage ",
"lint": "eslint . --max-warnings 0"
},
"license": "MIT",
"dependencies": {
"firebase-admin": "12.0.0",
"ssh2-sftp-client": "^10.0.3"
},
"devDependencies": {
"@types/node": "^20.11.16",
"@types/ssh2-sftp-client": "^9.0.3",
"dotenv": "^16.4.1",
"npm-run-all": "^4.1.5",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
packages/sftp/src/index.ts
export const echo = (what: string) =>
you said ${what};
works and deploys fine
adding import Client from "ssh2-sftp-client";
causes the ERR_MODULE_NOT_FOUND during firebase deploy
from isolate-package.
apologies, that has confused things.
In my fns firebase project, I import like this:
import {
type ConnectionInfo,
echo,
fetchSftpFiles,
} from "@repo/sftp";
export const helloWorld = onRequest((request, response) => {
const connectionInfo: ConnectionInfo = {...};
fetchSftpFiles(connectionInfo);
response.send(echo("Hello from Firebase!"));
});
adding import Client from "ssh2-sftp-client";
and a method to call it to my packages/sftp/src/index.ts causes the ERR_MODULE_NOT_FOUND during firebase deploy
from isolate-package.
Weird. I don't see the problem yet. But isolate deals with internal dependencies and not external, so I don't know yet how it can be related.
Did you inspect the output of the isolate directory? Is the package.json file there (in ./package/sftp listing the "ssh2-sftp-client" dependency?
from isolate-package.
Yes, it's showing that dependency in the isolate
directory.
from isolate-package.
I managed to recreate a working and non-working example in your mono-ts. I think it's to do with the build that backend does but common doesnt because it's linked directly.
So, adding the following code to @repo/backend results in a working deployable firebase functions:
modify packages/backend/src/utils/index.ts
import Client from "ssh2-sftp-client";
export function getClient() {
return new Client();
}
and import it into the services/api/src/server.ts
import { getClient } from "@repo/backend";
const test = getClient();
Works...
But modify,
packages/common/src/index.ts
import Client from "ssh2-sftp-client";
export const getClient = () => new Client();
and import it into the services/api/src/server.ts
import { getClient } from "@repo/common";
const test = getClient();
Does NOT work....
It's re-createable with any external package like dayjs
for example.
from isolate-package.
@1jmj I was able to reproduce the problem, and it seems the internal packages strategy is mainly interesting if your consuming app is something like Next.js which has a transpilePackages setting that will transpile the source and bundle its dependencies .
If the consuming app is using TSUP like services/api, then the import is merely treated as a folder of source files, and dependencies from common also need to be installed there, which makes the strategy a lot less attractive I think.
I've updated the code and the readme. See 0x80/mono-ts@d0186fe
from isolate-package.
Related Issues (20)
- Add support for Rush monorepos HOT 17
- Add support for passing CLI arguments HOT 6
- pnpm overrides are breaking gcp deployments HOT 7
- Failing to pack with PNPM HOT 4
- There are types at 'isolate-package/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". HOT 7
- Isolate seem to be not copying the `.env` file HOT 2
- Remove excess packages from the list in pnpm lockfile
- Fix package registry logic for non-rush repositories
- Strip forceNpm option for sake of simplicity
- Reintroduce excludeLockfile
- Add support for pnpm v9 HOT 4
- trouble shooting some problems HOT 3
- Consistently use pnpm pack if suitable
- Adopt packageManager field from root manifest
- Add flag to omit packageManager field
- Define config using a typed function
- Option to prevent move of node_modules for NPM HOT 3
- Will fail if pnpm-workspace.yaml is empty HOT 2
- Handle non-monorepo setups
- Isolated pnpm lockfile is missing overrides HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isolate-package.