mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
refactor: flatten nuxt3 src
some packages yet to be externalized
This commit is contained in:
parent
547b8ec2a7
commit
636d1e38bb
@ -32,7 +32,7 @@ export class Builder {
|
||||
}
|
||||
|
||||
build () {
|
||||
return build(this)
|
||||
return _build(this)
|
||||
}
|
||||
|
||||
close () {
|
||||
@ -41,7 +41,7 @@ export class Builder {
|
||||
}
|
||||
|
||||
// Extends VueRouter
|
||||
async function build (builder: Builder) {
|
||||
async function _build (builder: Builder) {
|
||||
const { nuxt } = builder
|
||||
|
||||
await fsExtra.emptyDir(nuxt.options.buildDir)
|
||||
@ -107,3 +107,11 @@ async function bundle ({ nuxt }: Builder) {
|
||||
.then(p => p.bundle)
|
||||
return bundle(nuxt)
|
||||
}
|
||||
|
||||
export function getBuilder (nuxt: Nuxt) {
|
||||
return new Builder(nuxt)
|
||||
}
|
||||
|
||||
export function build (nuxt: Nuxt) {
|
||||
return getBuilder(nuxt).build()
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import type { Nuxt } from '../core'
|
||||
import { Builder } from './builder'
|
||||
|
||||
export { Builder } from './builder'
|
||||
|
||||
export function getBuilder (nuxt: Nuxt) {
|
||||
return new Builder(nuxt)
|
||||
}
|
||||
|
||||
export function build (nuxt: Nuxt) {
|
||||
return getBuilder(nuxt).build()
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
export { default as Module } from './module'
|
||||
export { default as Nuxt } from './nuxt'
|
||||
export { default as Resolver } from './resolver'
|
||||
export { loadNuxt } from './load'
|
@ -1,17 +0,0 @@
|
||||
import { dirname } from 'path'
|
||||
import { loadNuxtConfig } from '@nuxt/kit'
|
||||
import Nuxt from './nuxt'
|
||||
export interface LoadNuxtOptions {
|
||||
}
|
||||
|
||||
export async function loadNuxt (opts: LoadNuxtOptions) {
|
||||
const options = await loadNuxtConfig(opts)
|
||||
|
||||
// Temp
|
||||
options.appDir = dirname(require.resolve('@nuxt/app'))
|
||||
options._majorVersion = 3
|
||||
|
||||
const nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
return nuxt
|
||||
}
|
@ -1,3 +1,2 @@
|
||||
export { loadNuxt } from './core'
|
||||
export { Nuxt, loadNuxt } from './nuxt'
|
||||
export { build } from './builder'
|
||||
export { main } from '../../nu/src'
|
||||
|
@ -2,7 +2,6 @@ import path from 'path'
|
||||
import fs from 'fs'
|
||||
import hash from 'hash-sum'
|
||||
import consola from 'consola'
|
||||
|
||||
import { chainFn, sequence } from '@nuxt/kit'
|
||||
|
||||
import Nuxt from './nuxt'
|
@ -1,10 +1,11 @@
|
||||
import type { IncomingHttpHeaders } from 'http'
|
||||
|
||||
import { dirname } from 'path'
|
||||
import isPlainObject from 'lodash/isPlainObject'
|
||||
import consola from 'consola'
|
||||
import Hookable from 'hookable'
|
||||
|
||||
import { version } from '../../package.json'
|
||||
import { loadNuxtConfig } from '@nuxt/kit'
|
||||
import { version } from '../package.json'
|
||||
|
||||
import ModuleContainer from './module'
|
||||
import Resolver from './resolver'
|
||||
@ -18,7 +19,7 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export default class Nuxt extends Hookable {
|
||||
export class Nuxt extends Hookable {
|
||||
_ready?: Promise<this>
|
||||
_initCalled?: boolean
|
||||
|
||||
@ -92,3 +93,15 @@ export default class Nuxt extends Hookable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadNuxt (opts: LoadNuxtOptions) {
|
||||
const options = await loadNuxtConfig(opts)
|
||||
|
||||
// Temp
|
||||
options.appDir = dirname(require.resolve('@nuxt/app'))
|
||||
options._majorVersion = 3
|
||||
|
||||
const nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
return nuxt
|
||||
}
|
@ -8,7 +8,7 @@ import {
|
||||
isExternalDependency,
|
||||
clearRequireCache
|
||||
} from '@nuxt/kit'
|
||||
import { Nuxt } from '../core'
|
||||
import { Nuxt } from './nuxt'
|
||||
|
||||
interface ResolvePathOptions {
|
||||
isAlias?: boolean
|
Loading…
Reference in New Issue
Block a user