-
Notifications
You must be signed in to change notification settings - Fork 65
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
doesn't work when bundled #79
Comments
Hi, thanks for the issue. By "bundled", do you mean you are merging the files in this library together into e.g. a single file? Can I ask why? |
Yep, when using something like rollup I can deploy my app in a single file. With this issue I'm currently needing to install this dep at runtime so I can use the version in |
Thanks. I think I still don't understand why this is desirable! Is it to make distribution easier? Just give someone a single Does e.g. rollup have docs on how to handle |
It's usually done for embedded apps and/or serverless like aws lambda. I'm honestly surprised this hasn't come up in the past. Usually with rollup the I have a feeling the new way of getting const __dirname = path.dirname(new URL(import.meta.url).pathname); |
hey, any movement on this? I am getting the same error when bundling with client = await pool.connect();
const migrationsDir = path.resolve('resources/migrations');
console.log(migrationsDir);
await migrate({ client }, migrationsDir); /usr/app/resources/migrations # result of console.log(migrationsDir). Directory exists on docker image at expected location
error: ┏ Error running db migrations ENOENT: no such file or directory, open '/usr/app/migrations/0_create-migrations-table.sql' - Offending file: '0_create-migrations-table.sql'.
error: ┃ [ 1] Error: ENOENT: no such file or directory, open '/usr/app/migrations/0_create-migrations-table.sql' - Offending file: '0_create-migrations-table.sql'. The path that the library tries to resolve is incorrect, its missing the When running locally via |
How have other libraries solved this? I expect other libraries read files in similar ways and have had the same problem. I'm open to solutions, but I don't have much time at the moment to think about, research and test this. |
Have a look through evanw/esbuild#859 |
You could try e.g. |
I would be surprised if that worked in a normal Node.js/NPM environment. Perhaps you would like to try it? I see you're also based in Bristol, hi! |
I will try and get some time
I was gonna say the same thing 😀 Wasson me babber! |
👋 Also running into this issue. As for why we want to bundle We're developing a SvelteKit application. SvelteKit is a meta framework that automates building isomorphic applications, compiled to both frontend and backend bundles using Vite. I'm then packaging the resulting bundles into a Docker image. If I can't bundle Because import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); However since
This happens at this line of code that includes the "0" migration. If only this line could be handled in a different way (for example, by inlining the initial zero migration) then this whole package should work fine even when bundling! |
I made a PR with a workaround for this issue. In short it involves copying the initial migration to your local migrations folder to skip the use of You can read more here: This will hopefully get merged but if you want to use my fork temporarily you can change your
PS. import { migrate } from 'postgres-migrations/src/index'; |
Because of this line the sql file ends up checking the relative location in this case it's
dist
instead ofnode_modules
. Maybe inline this so it can be bundled? Or allow using the one supplied by the user.postgres-migrations/src/files-loader.ts
Line 35 in bc2b0cb
The text was updated successfully, but these errors were encountered: