-
-
Notifications
You must be signed in to change notification settings - Fork 185
feat: add nuxt 4 support #1049
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
base: main
Are you sure you want to change the base?
feat: add nuxt 4 support #1049
Conversation
This commit addresses a warning issued by `@nuxt/module-builder` during the 'prepack' build process. The warning indicated that the top-level 'types' field in 'package.json' is no longer required for modern bundler TypeScript module resolution. By removing this redundant field, the 'package.json' now adheres to current best practices for module declaration, where type entry points are primarily defined within the 'exports' map. This ensures a cleaner and more consistent module resolution experience for consumers using modern tools and Node.js versions.
This commit finalizes the refactoring of the package's module entry points in package.json by removing the top-level "main" field. This change directly addresses a recurring warning issued by `@nuxt/module-builder` during the `prepack` build process, which indicated that this field is no longer required for Nuxt 3+ applications. The "main" field historically defined the primary entry point for packages consumed via CommonJS `require()`. However, with the adoption of the "exports" field in package.json (a Node.js feature), this field now takes precedence in defining package entry points for both CommonJS and ECMAScript Modules. For modern Nuxt applications (Nuxt 3+ and Nuxt 4), the build system and underlying Nitro server overwhelmingly prefer and resolve modules using ESM (`.mjs` files) via the `exports.import` condition. The presence of the "main" field becomes redundant in such contexts and triggers strict warnings from module builders like `@nuxt/module-builder`. This change ensures that the package.json now primarily relies on the "exports" field to define a single, modern ESM entry point (`./dist/module.mjs`). This aligns the module's declaration with the current best practices for publishing packages intended for contemporary JavaScript ecosystems, particularly those using ES Modules. The primary benefit of this change is to eliminate the persistent `ERROR Exiting with code (1)` during `pnpm run prepack`, which was directly linked to the warnings about redundant CommonJS/legacy declarations. It also contributes to a cleaner `package.json` and ensures better compatibility and predictability when consumed by modern bundlers, TypeScript, and Node.js versions that adhere to the "exports" map specification. While this change streamlines the module for ESM-first consumption, if specific legacy CommonJS environments or tools were strictly relying on the "main" field, those particular use cases would need separate evaluation. However, for the primary use case with Nuxt 4, this refined `package.json` is optimized for seamless integration.
The scule package has been removed from the project's dependencies as it was no longer being utilised within the codebase. This cleanup simplifies the dependency tree and reduces the overall installation size, contributing to better project maintenance and a leaner package. This is a non-breaking change with no impact on the module's functionality.
The `nitropack` package is only used within the module for its TypeScript type definitions (import type). It is not a true runtime dependency. Type-only imports are erased during compilation, and the module uses a local stub for `defineNitroPlugin` to avoid needing a runtime import from `nitropack`. Therefore, moving `nitropack` to devDependencies correctly declares its purpose as a tool for development-time type checking. This cleans up the production dependencies for end-users of this module.
The `knitwork` package was used for a single function, `genInterface`, to generate a TypeScript interface string for the local provider's session data. This implementation has been replaced with a concise, inline solution using `Object.entries` and `map`. This change removes an unnecessary dependency, making the module lighter and easier to maintain without sacrificing functionality.
commit: |
I've used this from the point of view of a |
@sidebase or any of the maintainers - any chance of seeing this merged? |
Hi everyone π Thanks for opening this PR! I agree that the migration to Nuxt 4 will be an important step for the future. However, I am a little hesitent to fully migrate everything over at the moment. A lot of apps still run on Nuxt 3 and it is also still getting releases. Therefore we should still support Nuxt 3 to ensure we can push fixes and security patches. Inside your linked issue and most of my tests I can see that most use-cases of NuxtAuth in Nuxt 4 are working without any issues. Did you run into issues that require a full upgrade to Nuxt 4 internals? Aside from this, you can already use the pkg.new package that was created based off this PR for now:
|
π Linked issue
#1043
β Type of change
π Description
Updates nuxt-auth to support Nuxt 4. This is a breaking change - Nuxt 3 is no longer supported.
Dependencies bumped:
@nuxt/kit: ^3.17.6 β ^4.0.0
@nuxt/schema: ^3.17.6 β ^4.0.0
@nuxt/module-builder: ^0.8.4 β ^1.0.2
nuxt: ^3.17.6 β ^4.0.0
@antfu/eslint-config: ^4.16.2 β ^5.0.0
@nuxt/eslint: ^1.7.1
(new)oxlint: ^0.16.12 β ^1.0.0
ts-essentials: ^9.4.2 β ^10.1.1
vue-tsc: ^2.2.12 β ^2.0.21
vite: ^7.0.0
(added)Dependencies removed:
knitwork
(replaced with native TS interface generation)scule
@nuxtjs/eslint-config-typescript
(replaced with@nuxt/eslint
)Code Updates:
knitwork.genInterface
with native TypeScript interface generation.d.ts
β.d.mts
)Documentation:
π Checklist