Support the Nuxt 4 app directory and custom Storyblok plugins - #152
Merged
Merged
Conversation
|
👋 @marcospassos
☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in 50 characters or less using the imperative mood. |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CLI treated the project root as the Nuxt source directory. Nuxt 4 uses
app/, and so does Nuxt 3 withfuture.compatibilityVersion: 4. Socroct initwroteplugins/croct-storyblok.tswhere Nuxt ignores it, silently disabling the Storyblok integration. It also recordedcomponentsandexamplespaths incroct.jsonthat point at root directories Nuxt never loads, socroct add slotwould scaffold files that are never picked up.Separately, apps that set
usePlugin: falseand install Storyblok from their own plugin, like Storyblok's demo frontend, crashed on startup on both Nuxt 3 and 4. Nuxt runs application plugins in filename order, socroct-storyblok.tsran beforestoryblok.tsanduseStoryblokApi()threw.Changes:
PlugNuxtSdk.getPaths()resolvessourcewith Nuxt's ownsrcDirrules. An explicitsrcDirwins. Otherwise Nuxt 4, and Nuxt 3 on compatibility version 4, useapp/, unlessapp/only holds files Nuxt 3 already kept there and the root still follows the previous layout. Components, utilities and examples derive from it.NuxtConfigParserstatically readssrcDirandfuture.compatibilityVersionfromnuxt.config, evaluating constants and template literals. It reuses the config lookup ofNuxtConfigModuleCodemod.NuxtStoryblokPluginscaffolds the plugin under the source directory.name: 'croct-storyblok'andenforce: 'post', so it runs after every regular plugin, whatever that plugin is named.dependsOncan't do this because the@storyblok/nuxtplugin is unnamed.croct.jsonstays at the project root; only the paths it records change.Both the parser and the codemod are covered at 100% by fixtures.
Validated by running
croct initwith this build on four fresh apps, then loading each in a headless browser and building for production:paths.source.plugins/appapp/plugins/appapp/plugins/appapp/plugins/Known limits: a config passed as a variable (
defineNuxtConfig(options)) isn't resolved, same as in the module codemod, and a customdir.pluginsisn't honored.