Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
refactor: remove all module container code
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 15, 2022
1 parent 48a0fcd commit a9c1d04
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 152 deletions.
1 change: 0 additions & 1 deletion docs/content/3.api/4.advanced/2.kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ description: Nuxt Kit provides composable utilities to help interacting with Nux
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/module)

- `installModule(module, inlineOptions)`
- `wrapLegacyModule(module)`

### Programmatic Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/content/7.migration/20.module-authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ By using [vue-demi](https://github.com/vueuse/vue-demi) they should be compatibl

## Module Migration

When Nuxt 3 users add your module, a compatible module container layer from `@nuxt/kit` is **automatically injected**, so as long as your code is following the guidelines below, it should continue working as-is.
When Nuxt 3 users add your module, you will not have access to the module container (`this.*`) so you will need to use utilities from `@nuxt/kit` to access the container functionality.

### Test with `@nuxt/bridge`

Expand Down
1 change: 0 additions & 1 deletion packages/kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Module
export * from './module/container'
export * from './module/define'
export * from './module/install'

Expand Down
107 changes: 0 additions & 107 deletions packages/kit/src/module/container.ts

This file was deleted.

43 changes: 1 addition & 42 deletions packages/schema/src/types/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NuxtHooks } from './hooks'
import type { Nuxt, NuxtPluginTemplate, NuxtTemplate } from "./nuxt"
import type { Nuxt } from "./nuxt"
import type { NuxtCompatibility } from './compatibility'

export interface ModuleMeta {
Expand Down Expand Up @@ -41,44 +41,3 @@ export interface NuxtModule<T extends ModuleOptions = ModuleOptions> {
getOptions?: (inlineOptions?: T, nuxt?: Nuxt) => Promise<T>
getMeta?: () => Promise<ModuleMeta>
}

/**
* Legacy ModuleContainer for backwards compatibility with Nuxt 2 module format.
*/
export interface ModuleContainer {
nuxt: Nuxt
options: Nuxt['options']

/** @deprecated */
ready(): Promise<any>

/** @deprecated */
addVendor(): void

/** Renders given template using lodash template during build into the project buildDir (`.nuxt`).*/
addTemplate(template: string | NuxtTemplate): NuxtTemplate

/** Registers a custom plugin. */
addPlugin(template: NuxtPluginTemplate): NuxtPluginTemplate

/** Registers a custom layout. If its name is 'error' it will override the default error layout. */
addLayout(tmpl: NuxtTemplate, name: string): any

/** Sets the layout that will render Nuxt errors. It should already have been added via addLayout or addTemplate. */
addErrorLayout(dst: string): void

/** Adds a new server middleware to the end of the server middleware array. */
addServerMiddleware(arg1: any): void

/** Allows extending webpack build config by chaining `options.build.extend` function. */
extendBuild(fn: Function): void

/** Allows extending routes by chaining `options.router.extendRoutes` function. */
extendRoutes(fn: Function): void

/** Registers a module. */
requireModule(installOptions: any, opts: any): Promise<void>

/** Registers a module. */
addModule(installOptions: any, opts: any): Promise<void>
}

0 comments on commit a9c1d04

Please sign in to comment.