
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@nuxt/module-builder
Advanced tools
The complete solution to build and ship Nuxt modules.
@nuxt/schemaWe recommend to checkout the Nuxt modules author guide before starting with the module-builder.
For a user to use a module generated from module-builder, it's recommended they have:
Get started with our module starter:
npx nuxi init -t module my-module
The module builder requires a special project structure. You can check out the module template.
src/module.tsThe entrypoint for module definition.
A default export using defineNuxtModule and ModuleOptions type export is expected.
You could also optionally export ModuleHooks or ModuleRuntimeHooks to annotate any custom hooks the module uses.
import { defineNuxtModule } from '@nuxt/kit'
export interface ModuleOptions {
apiKey: string
}
export interface ModuleHooks {
'my-module:init': any
}
export interface ModuleRuntimeHooks {
'my-module:runtime-hook': any
}
export interface ModuleRuntimeConfig {
PRIVATE_NAME: string
}
export interface ModulePublicRuntimeConfig {
NAME: string
}
export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'my-module',
configKey: 'myModule'
},
defaults: {
apiKey: 'test'
},
async setup (moduleOptions, nuxt) {
// Write module logic in setup function
}
})
src/runtime/Any runtime file and code that we need to provide by module including plugins, composables and server api, should be in this directory.
Each file will be transformed individually using unjs/mkdist to dist/runtime/.
package.json:A minimum package.json should look like this:
{
"name": "my-module",
"license": "MIT",
"version": "1.0.0",
"exports": {
".": {
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"prepack": "nuxt-module-build build"
},
"dependencies": {
"@nuxt/kit": "npm:@nuxt/kit-edge@latest"
},
"devDependencies": {
"@nuxt/module-builder": "latest"
}
}
build.config.ts (optional)Module builder is essentially a preset for unjs/unbuild, check out the build command for reference.
To customize/extend the unbuild configuration you can add a build.config.ts in the root of your project:
import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
// set additional configuration or customize using hooks
})
Module builder generates dist files in dist/ directory:
module.mjs: Module entrypoint build from src/modulemodule.json: Module meta extracted from module.mjs + package.jsonmodule.cjs: ESM proxy to allow require module in CommonJS contexttypes.d.ts: Exported types in addition to shims for nuxt.config auto completion.runtime/*: Individually transformed files using unjs/mkdist
.ts files will be transformed to .js with extracted types on .d.ts file with same name.vue files will be transformed with extracted .d.ts filecorepack enablepnpm installpnpm example:buildMIT - Made with 💚
FAQs
Complete solution for building Nuxt modules
The npm package @nuxt/module-builder receives a total of 36,960 weekly downloads. As such, @nuxt/module-builder popularity was classified as popular.
We found that @nuxt/module-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.