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: backport layers feature from v3 #746

Closed
wants to merge 20 commits into from
Closed

feat: backport layers feature from v3 #746

wants to merge 20 commits into from

Conversation

AndreyYolkin
Copy link
Contributor

@AndreyYolkin AndreyYolkin commented Apr 18, 2023

πŸ”— Linked issue

#747

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR intends to optionally enable config parsing like it does in nuxt 3. It also backports nuxt/nuxt#20329

After PR merge you will be able to separate logic into layers, with components, pages, composables, etc.

Current problems:
[x] we are unable to retrieve project root which is important for c12 to start looking for configs. Latest approach works with dev/prod without any changes, but requires rootDir: dirname to be set at nuxt.config.ts during the test solved with module.parent (as far as we rely on CJS)

Main steps to achieve that:

  1. defineNuxtConfig returns async function, because c12 is asynchronous and without that defineNuxtConfig didn't awaits for config loading
  2. For some reasons in dev mode config loaded twicely, and only 2nd loaded config passed to builder. So I define counter to trigger loadC12Config function on 2nd loading in dev mode and 1st at other modes.
  3. The main problem was lack of rootDir, which was overcame with module.parent. This is working because now we have CJS module, but in ESM it became undefined. Also we need to admit that module.parent is deprecated, but Node 14-16 supports it.

πŸ“ Checklist

  • components/*
  • composables/*
  • pages/*
  • server/*
  • nuxt.config.ts
  • app.config.ts
  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@AndreyYolkin

This comment was marked as resolved.

@AndreyYolkin
Copy link
Contributor Author

I'll close the issue. Despite it was almost ready, the troubles with dev mode and polishing merged entities are too complicated to resolve. I think I agree with the decisions we made in Nuxt office hours: people should upgrade their app first to Nuxt 3, then start playing with layers.

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.

None yet

1 participant