Skip to content

New option to install packages #574

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

Merged
merged 4 commits into from
Oct 24, 2024
Merged

Conversation

conico974
Copy link
Contributor

This PR fix #571

How to use

In any of the function in open-next.config.ts you can now add a new option that will install dependencies that may not be included (For example sharp):

install : {
  packages: ["[email protected]"],
  arch: "x64", // or arm64
  nodeVersion: "18", // or 20 or 22
  libc: "glibc" // or musl
}

Install itself is optional, and everything in it is optional besides packages

Copy link

changeset-bot bot commented Oct 18, 2024

🦋 Changeset detected

Latest commit: e6a8556

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Minor
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Oct 18, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/@opennextjs/aws@574

commit: e6a8556

logger.info(`Installing dependencies for ${name}...`);
// We then need to run install in the tempDir
// We don't install in the output dir directly because it could contain a package.json, and npm would then try to reinstall not complete deps from tracing the files
const installCommand = `npm install --arch=${installOptions.arch ?? "arm64"} --platform=linux --target=${installOptions.nodeVersion ?? "18"} --libc=${installOptions.libc ?? "glibc"} ${installOptions.packages.join(" ")}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use whatever packager was used for Next as it has been retrieved anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but we'll need to figure out how to pass all these options.
I don't think they support all of them, or there is no docs. If some other package manager support it we could use them and fallback to npm when not possible

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could pass the buildOptions and the function name to installDeps.
It would mean adding the outputPath and the packager there.
But that's probably a nice to have for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about using buildOptions and name, but i think it would just overcomplicate things.
It could be a splitted functions (which are under functions in the config) and server functions are inside a different folder than the rest.
We could still pass buildOptions to get the packager

@conico974 conico974 mentioned this pull request Oct 22, 2024
conico974 and others added 2 commits October 24, 2024 19:19
@conico974 conico974 merged commit 216e05c into opennextjs:main Oct 24, 2024
3 checks passed
@conico974 conico974 deleted the feat/install branch October 29, 2024 10:42
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

Successfully merging this pull request may close these issues.

[Feature] Add an install option in config
2 participants