-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add @netlify/nuxt
Nuxt module
#344
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?
Conversation
438bf97
to
46548e2
Compare
b4cde10
to
e89c2d8
Compare
@@ -0,0 +1,18 @@ | |||
// @ts-check | |||
import { createConfigForNuxt } from '@nuxt/eslint-config/flat' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole module was scaffolded by npm create nuxt -- -t module
"description": "Nuxt module providing local emulation of the Netlify environment", | ||
"type": "module", | ||
"engines": { | ||
"node": "^20.6.1 || >=22" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same range as our other new packages
"//": "Workaround to run this package's eslint in CI", | ||
"test:ci": "npm run lint && npm run test:types && npm run test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current CI workflows make very specific assumptions about all packages, so I just squeezed this into test:ci
"@nuxt/schema": "^3.17.6", | ||
"@nuxt/test-utils": "^3.19.2", | ||
"@types/node": "latest", | ||
"changelogen": "^0.6.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"changelogen": "^0.6.2", |
"@nuxt/module-builder": "^1.0.1", | ||
"@nuxt/schema": "^3.17.6", | ||
"@nuxt/test-utils": "^3.19.2", | ||
"@types/node": "latest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting choice from the scaffold... we should update this
@@ -0,0 +1,110 @@ | |||
import process from 'node:process' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is very similar to the vite plugin implementation. it was copied and adjusted to use nitro hooks.
import * as vite from 'vite' | ||
|
||
import { createLoggerFromViteLogger } from './lib/logger.js' | ||
import { fromWebResponse } from './lib/reqres.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to @netlify/dev-utils
so I could use it in the nuxt module too
I imagine the failing node 20.6.1 test is because nuxt (3) requires 20.9.0? I'll take a look on Monday |
|
||
export type NetlifyModuleOptions = Features | ||
|
||
const createPrefixedLogger = (prefix: string, logger: Logger) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could move somewhere centralised at some point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the vite plugin uses the passed vite logger which is configured with a similar-ish thing in a more first-class way. This was my half-assed equivalent with our own console
-based logger, so I don't see us reusing it any time soon.
@serhalp @eduardoboucas sent a DM. |
(collab with @danielroe!)
This is basically the same thing as
@netlify/vite-plugin
, but as a Nuxt module.Nuxt developers expect to extend Nuxt with Nuxt modules, not Vite plugins.
This is effectively the same thing as
@netlify/vite-plugin
(which is a thin wrapper over@netlify/dev
), but wrapped as a Nuxt module so that it can use Nitro hooks to register the server start/stop and hook up its middleware to the Nitro server.Because Nuxt's Vite and Nitro servers are separate and Nitro runs first anyway, it isn't possible to simply use a Vite plugin for this. (However, there is work underway in Nitro that is coming very very soon that would make this possible in Nitro v3!)
Co-authored-by: Daniel Roe [email protected]