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

feat(module): allow adding module to Nuxt config within layer #380

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DamianGlowala
Copy link
Member

resolves #361

This allows for adding a module entry to a Nuxt config file within a layer using --layer <layer_name>.

@@ -88,7 +92,9 @@ export default defineCommand({

// Update nuxt.config.ts
if (!ctx.args.skipConfig) {
await updateNuxtConfig(cwd, (config) => {
const rootDir = ctx.args.layer ? resolve(cwd, ctx.args.layer) : cwd
Copy link
Member

Choose a reason for hiding this comment

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

Without considering layer names, isn’t it same as —cwd ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think setting --cwd pointing to the layer dir would affect other places as well, e.g. where module add looks for package.json or where it adds a dependency using nypm util. Correct me if I'm wrong though.

(There might be a better way to achieve it as well, let me know if you have any idea.)

Copy link
Member

@pi0 pi0 Mar 30, 2024

Choose a reason for hiding this comment

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

I think what is expected is that the module is added to the closest package.json and nuxt.config files found to the specified cwd. (ie: We need a look-up search for both). nypm should do this via package managers by default.

I think it would probably be best first action to resolve any issues that prevents this.

—-

In next steps, —layer would be also good idea but i expect that it loads nuxt.config, and tries to match a layer by its name (which used in extends key) basically as a convenient shortcut and also it should implement safety check that we don’t write to readonly (remote or dependency) layers but instead ask to directly add to the root.

@DamianGlowala DamianGlowala marked this pull request as draft March 30, 2024 11:46
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.

nuxt module add -> select the nuxt.config.ts to install when working with layers
2 participants