Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nuxt/module-builder

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/module-builder

Complete solution to build Nuxt Modules

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-52.4%
Maintainers
5
Weekly downloads
 
Created
Source

📦 Nuxt Module Builder

Complete solution to build Nuxt Modules.

🧪 This tool is still under heavy development for Nuxt3. Feedback is more than welcome!

Features

  • Unified build with unjs/unbuild
  • Compatible with Nuxt 3 and Nuxt Kit
  • Automated build config using last module spec
  • Typescript and ESM support
  • Auto generated CommonJS stubs
  • Auto generated types and shims for @nuxt/schema

Project structure

Using module builder, requires a special project setup. You can check a full example here.

src/module.ts

This is the entrypoint for module definition.

A default export using defineNuxtModule and ModuleOptions type export is expected.

import { defineNuxtModule } from '@nuxt/kit'

export interface ModuleOptions {
  apiKey: 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": {
    ".": {
      "import": "./dist/module.mjs",
      "require": "./dist/module.cjs"
    }
  },
  "main": "./dist/module.cjs",
  "types": "./dist/types.d.ts",
  "files": [
    "dist"
  ],
  "scripts": {
    "prepack": "nuxt-module-build"
  },
  "dependencies": {
    "@nuxt/kit": "npm:@nuxt/kit-edge@latest"
  },
  "devDependencies": {
    "@nuxt/module-builder": "latest"
  }
}

💻 Development

  • Clone repository
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Install dependencies using yarn install
  • Try building example module using yarn example:build

License

MIT - Made with 💚

FAQs

Package last updated on 23 Dec 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc