Skip to content
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

Errors loading CLI dependencies in nextjs project but they are not needed #677

Open
rduque1 opened this issue Jun 28, 2024 · 4 comments
Open

Comments

@rduque1
Copy link

rduque1 commented Jun 28, 2024

Hi I am using umzug "umzug": "^3.8.1 in a nextjs project and run the migration programmatically.
I was wondering if the dependencies for the CLI can be loaded dynamically as I have the impression they generate errors and are not needed.

This is what the error trace I have:

Import trace for requested module:
./node_modules/umzug/lib/umzug.js
./node_modules/umzug/lib/index.js
./app/lib/server/mongodb.ts
./app/[lang]/layout.tsx
 ⚠ ./node_modules/@rushstack/node-core-library/lib/FileWriter.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/@rushstack/node-core-library/lib/FileWriter.js
./node_modules/@rushstack/node-core-library/lib/index.js
./node_modules/@rushstack/terminal/lib/NormalizeNewlinesTextRewriter.js
./node_modules/@rushstack/terminal/lib/index.js
./node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js
./node_modules/@rushstack/ts-command-line/lib/index.js
./node_modules/umzug/lib/cli.js
./node_modules/umzug/lib/index.js
./app/lib/server/mongodb.ts
./app/[lang]/layout.tsx

I am using the MongoDBStorage in my Umzug configuration.

@Baldinof
Copy link

Also the CLI dependencies has a big impact on loading time. On an app deployed on Google Cloud Run requiring Umzug takes ~700ms, ~650 of them are the require of @rushstack/ts-command-line.

Would you accept a PR that removes the cli from the default index.ts, and add a new one to be imported as umzug/cli?

That would be a BC and would require a v4, but it would speed up bootstrap of all apps that use Umzug only through it's node API.

@mmkal
Copy link
Contributor

mmkal commented Aug 31, 2024

I'm looking into moving to https://github.com/mmkal/trpc-cli instead. It has dependencies too, but none big. Hopefully that will be enough.

@Baldinof
Copy link

Baldinof commented Sep 2, 2024

👍
TBH it feels right to allow to import only what's needed for a programmatic usage only, it could also be a new umzuk/api export so it would not need a major release

@mikiher
Copy link

mikiher commented Sep 5, 2024

👍 TBH it feels right to allow to import only what's needed for a programmatic usage only, it could also be a new umzuk/api export so it would not need a major release

+1

I am working on adding umzug to Audiobookshelf and had an issue pkging the app because of some unsupported dependency type of @rushstack/ts-command-line on @rushstack/terminal (see package.json.

Please consider separating the CLI from the main umzug package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants