diff --git a/packages/nuxt3/src/builder/builder.ts b/packages/nuxt3/src/builder/builder.ts index 7c6c1697e7..2267a69b07 100644 --- a/packages/nuxt3/src/builder/builder.ts +++ b/packages/nuxt3/src/builder/builder.ts @@ -4,6 +4,7 @@ import chokidar from 'chokidar' import consola from 'consola' import fsExtra from 'fs-extra' import Glob from 'glob' +import globby from 'globby' import hash from 'hash-sum' import pify from 'pify' import upath from 'upath' @@ -15,8 +16,7 @@ import template from 'lodash/template' import uniq from 'lodash/uniq' import uniqBy from 'lodash/uniqBy' -import { BundleBuilder } from 'nuxt/webpack' -import vueAppTemplate from 'nuxt/vue-app/template' +import { BundleBuilder } from 'src/webpack' import { r, @@ -29,7 +29,7 @@ import { scanRequireTree, TARGETS, isFullStatic -} from 'nuxt/utils' +} from 'src/utils' import Ignore from './ignore' import BuildContext from './context/build' @@ -77,8 +77,7 @@ export default class Builder { }) } - // Resolve template - this.template = vueAppTemplate + this.resolveAppTemplate() // Create a new bundle builder this.bundleBuilder = this.getBundleBuilder(bundleBuilder) @@ -97,6 +96,18 @@ export default class Builder { } } + resolveAppTemplate() { + // Resolve appDir + const templatesDir = path.join(this.options.appDir, '_templates') + const files = globby.sync(path.join(templatesDir, '/**')) + .map(f => f.replace(templatesDir + path.sep, '')) + this.template = { + dependencies: {}, + dir: templatesDir, + files + } + } + getBundleBuilder () { const context = new BuildContext(this) return new BundleBuilder(context) @@ -169,7 +180,7 @@ export default class Builder { // Generate routes and interpret the template files await this.generateRoutesAndFiles() - // Add vue-app template dir to watchers + // Add app template dir to watchers this.options.build.watch.push(this.globPathWithExtensions(this.template.dir)) await this.resolvePlugins() @@ -336,7 +347,7 @@ export default class Builder { } async resolveApp ({ templateVars }) { - templateVars.appPath = 'nuxt-app/app.tutorial.vue' + templateVars.appPath = 'app/app.tutorial.vue' for (const appFile of this.appFiles) { if (await fsExtra.exists(appFile)) { @@ -503,7 +514,7 @@ export default class Builder { // Modules & user provided templates // first custom to keep their index ...customTemplateFiles, - // @nuxt/vue-app templates + // @nuxt/app templates ...templateContext.templateFiles ]) diff --git a/packages/nuxt3/src/builder/context/template.ts b/packages/nuxt3/src/builder/context/template.ts index 7b11dd5b4c..2ffb23ccb6 100644 --- a/packages/nuxt3/src/builder/context/template.ts +++ b/packages/nuxt3/src/builder/context/template.ts @@ -4,7 +4,7 @@ import uniqBy from 'lodash/uniqBy' import serialize from 'serialize-javascript' import devalue from '@nuxt/devalue' -import { r, wp, wChunk, serializeFunction, isFullStatic } from 'nuxt/utils' +import { r, wp, wChunk, serializeFunction, isFullStatic } from 'src/utils' export default class TemplateContext { constructor(builder, options) { diff --git a/packages/nuxt3/src/cli/command.ts b/packages/nuxt3/src/cli/command.ts index 6b8824085e..4c68b3fd0f 100644 --- a/packages/nuxt3/src/cli/command.ts +++ b/packages/nuxt3/src/cli/command.ts @@ -8,9 +8,9 @@ import { forceExit } from './utils' import { loadNuxtConfig } from './utils/config' import { indent, foldLines, colorize } from './utils/formatting' import { startSpaces, optionSpaces, forceExitTimeout } from './utils/constants' -import { Nuxt } from 'nuxt/core' -import { Builder } from 'nuxt/builder' -import { Generator } from 'nuxt/generator' +import { Nuxt } from 'src/core' +import { Builder } from 'src/builder' +import { Generator } from 'src/generator' export default class NuxtCommand extends Hookable { constructor (cmd = { name: '', usage: '', description: '' }, argv = process.argv.slice(2), hooks = {}) { diff --git a/packages/nuxt3/src/cli/commands/build.ts b/packages/nuxt3/src/cli/commands/build.ts index f234b3661b..8f3eab5eb0 100644 --- a/packages/nuxt3/src/cli/commands/build.ts +++ b/packages/nuxt3/src/cli/commands/build.ts @@ -1,5 +1,5 @@ import consola from 'consola' -import { MODES, TARGETS } from 'nuxt/utils' +import { MODES, TARGETS } from 'src/utils' import { common, locking } from '../options' import { createLock } from '../utils' diff --git a/packages/nuxt3/src/cli/commands/export.ts b/packages/nuxt3/src/cli/commands/export.ts index 026200c3fe..58ce739b57 100644 --- a/packages/nuxt3/src/cli/commands/export.ts +++ b/packages/nuxt3/src/cli/commands/export.ts @@ -1,6 +1,6 @@ import path from 'path' import consola from 'consola' -import { TARGETS } from 'nuxt/utils' +import { TARGETS } from 'src/utils' import { common, locking } from '../options' import { createLock } from '../utils' diff --git a/packages/nuxt3/src/cli/commands/generate.ts b/packages/nuxt3/src/cli/commands/generate.ts index b7386626a8..206bb796ba 100644 --- a/packages/nuxt3/src/cli/commands/generate.ts +++ b/packages/nuxt3/src/cli/commands/generate.ts @@ -1,4 +1,4 @@ -import { TARGETS } from 'nuxt/utils' +import { TARGETS } from 'src/utils' import { common, locking } from '../options' import { normalizeArg, createLock } from '../utils' diff --git a/packages/nuxt3/src/cli/commands/serve.ts b/packages/nuxt3/src/cli/commands/serve.ts index 071c65f3b5..b48b66a193 100644 --- a/packages/nuxt3/src/cli/commands/serve.ts +++ b/packages/nuxt3/src/cli/commands/serve.ts @@ -3,12 +3,12 @@ import { join, extname, basename } from 'path' import connect from 'connect' import serveStatic from 'serve-static' import compression from 'compression' -import { getNuxtConfig } from 'nuxt/config' -import { TARGETS } from 'nuxt/utils' +import { getNuxtConfig } from 'src/config' +import { TARGETS } from 'src/utils' import { common, server } from '../options' import { showBanner } from '../utils/banner' -import { Listener } from 'nuxt/server' -import { Nuxt } from 'nuxt/core' +import { Listener } from 'src/server' +import { Nuxt } from 'src/core' export default { name: 'serve', diff --git a/packages/nuxt3/src/cli/commands/start.ts b/packages/nuxt3/src/cli/commands/start.ts index 3da1c2c711..b35cd6a063 100644 --- a/packages/nuxt3/src/cli/commands/start.ts +++ b/packages/nuxt3/src/cli/commands/start.ts @@ -1,4 +1,4 @@ -import { TARGETS } from 'nuxt/utils' +import { TARGETS } from 'src/utils' import { common, server } from '../options' import { showBanner } from '../utils/banner' diff --git a/packages/nuxt3/src/cli/options/common.ts b/packages/nuxt3/src/cli/options/common.ts index 50a8a74b1a..ea5f8034b8 100644 --- a/packages/nuxt3/src/cli/options/common.ts +++ b/packages/nuxt3/src/cli/options/common.ts @@ -1,4 +1,4 @@ -import { defaultNuxtConfigFile } from 'nuxt/config' +import { defaultNuxtConfigFile } from 'src/config' import { normalizeArg } from '../utils' export default { diff --git a/packages/nuxt3/src/cli/utils/config.ts b/packages/nuxt3/src/cli/utils/config.ts index 97804f738d..3d4b6a37f8 100644 --- a/packages/nuxt3/src/cli/utils/config.ts +++ b/packages/nuxt3/src/cli/utils/config.ts @@ -1,7 +1,7 @@ import path from 'path' import defaultsDeep from 'lodash/defaultsDeep' -import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from 'nuxt/config' -import { MODES } from 'nuxt/utils' +import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from 'src/config' +import { MODES } from 'src/utils' export async function loadNuxtConfig (argv, configContext) { const rootDir = path.resolve(argv._[0] || '.') diff --git a/packages/nuxt3/src/cli/utils/index.ts b/packages/nuxt3/src/cli/utils/index.ts index 27c6dec9bf..e2b33019c8 100644 --- a/packages/nuxt3/src/cli/utils/index.ts +++ b/packages/nuxt3/src/cli/utils/index.ts @@ -1,7 +1,7 @@ import path from 'path' import exit from 'exit' -import { lock } from 'nuxt/utils' +import { lock } from 'src/utils' import chalk from 'chalk' import env from 'std-env' import { warningBox } from './formatting' diff --git a/packages/nuxt3/src/cli/utils/webpack.ts b/packages/nuxt3/src/cli/utils/webpack.ts index 53c3c1a84d..bf267a1211 100644 --- a/packages/nuxt3/src/cli/utils/webpack.ts +++ b/packages/nuxt3/src/cli/utils/webpack.ts @@ -1,5 +1,5 @@ -import { loadNuxt } from 'nuxt/core' -import { getBuilder } from 'nuxt/builder' +import { loadNuxt } from 'src/core' +import { getBuilder } from 'src/builder' export async function getWebpackConfig(name = 'client', loadOptions = {}) { const nuxt = await loadNuxt(loadOptions) diff --git a/packages/nuxt3/src/config/config/_common.ts b/packages/nuxt3/src/config/config/_common.ts index 2d67b70125..a6e133f37d 100644 --- a/packages/nuxt3/src/config/config/_common.ts +++ b/packages/nuxt3/src/config/config/_common.ts @@ -1,6 +1,7 @@ import capitalize from 'lodash/capitalize' import env from 'std-env' -import { TARGETS, MODES } from 'nuxt/utils' +import path from 'path' +import { TARGETS, MODES } from 'src/utils' export default () => ({ // Env @@ -47,6 +48,7 @@ export default () => ({ modulesDir: [ 'node_modules' ], + appDir: path.resolve(__dirname, '../../../app'), dir: { assets: 'assets', app: 'app', diff --git a/packages/nuxt3/src/config/config/modes.ts b/packages/nuxt3/src/config/config/modes.ts index 0a6c6e8a17..a1f071cdc7 100644 --- a/packages/nuxt3/src/config/config/modes.ts +++ b/packages/nuxt3/src/config/config/modes.ts @@ -1,4 +1,4 @@ -import { MODES } from 'nuxt/utils' +import { MODES } from 'src/utils' export default () => ({ [MODES.universal]: { diff --git a/packages/nuxt3/src/config/load.ts b/packages/nuxt3/src/config/load.ts index 8e2c4cf1c7..b60bcff242 100644 --- a/packages/nuxt3/src/config/load.ts +++ b/packages/nuxt3/src/config/load.ts @@ -3,7 +3,7 @@ import fs from 'fs' import defu from 'defu' import consola from 'consola' import dotenv from 'dotenv' -import { clearRequireCache, scanRequireTree } from 'nuxt/utils' +import { clearRequireCache, scanRequireTree } from 'src/utils' import jiti from 'jiti' import _createRequire from 'create-require' import destr from 'destr' diff --git a/packages/nuxt3/src/config/options.ts b/packages/nuxt3/src/config/options.ts index 8f86a4f927..97784a735c 100644 --- a/packages/nuxt3/src/config/options.ts +++ b/packages/nuxt3/src/config/options.ts @@ -6,7 +6,7 @@ import pick from 'lodash/pick' import uniq from 'lodash/uniq' import consola from 'consola' import destr from 'destr' -import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from 'nuxt/utils' +import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from 'src/utils' import { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config' export function getNuxtConfig (_options) { @@ -413,6 +413,7 @@ export function getNuxtConfig (_options) { } options.build.transpile = [].concat(options.build.transpile || []) + options.build.transpile.push('app') if (options.build.quiet === true) { consola.level = 0 diff --git a/packages/nuxt3/src/core/index.ts b/packages/nuxt3/src/core/index.ts index 96d3b79c1e..16f86764cf 100644 --- a/packages/nuxt3/src/core/index.ts +++ b/packages/nuxt3/src/core/index.ts @@ -1,5 +1,5 @@ export { default as Module } from './module' export { default as Nuxt } from './nuxt' export { default as Resolver } from './resolver' -export { loadNuxtConfig } from 'nuxt/config' +export { loadNuxtConfig } from 'src/config' export { loadNuxt } from './load' diff --git a/packages/nuxt3/src/core/module.ts b/packages/nuxt3/src/core/module.ts index c130942f9e..27c0fad5fa 100644 --- a/packages/nuxt3/src/core/module.ts +++ b/packages/nuxt3/src/core/module.ts @@ -3,7 +3,7 @@ import fs from 'fs' import hash from 'hash-sum' import consola from 'consola' -import { chainFn, sequence } from 'nuxt/utils' +import { chainFn, sequence } from 'src/utils' export default class ModuleContainer { constructor (nuxt) { diff --git a/packages/nuxt3/src/core/nuxt.ts b/packages/nuxt3/src/core/nuxt.ts index 2cdd3160c2..a3bb7bc832 100644 --- a/packages/nuxt3/src/core/nuxt.ts +++ b/packages/nuxt3/src/core/nuxt.ts @@ -3,9 +3,9 @@ import isPlainObject from 'lodash/isPlainObject' import consola from 'consola' import Hookable from 'hable' -import { defineAlias } from 'nuxt/utils' -import { getNuxtConfig } from 'nuxt/config' -import { Server } from 'nuxt/server' +import { defineAlias } from 'src/utils' +import { getNuxtConfig } from 'src/config' +import { Server } from 'src/server' import { version } from '../../package.json' diff --git a/packages/nuxt3/src/core/resolver.ts b/packages/nuxt3/src/core/resolver.ts index e1c1bb4914..20b762b257 100644 --- a/packages/nuxt3/src/core/resolver.ts +++ b/packages/nuxt3/src/core/resolver.ts @@ -7,7 +7,7 @@ import { startsWithSrcAlias, isExternalDependency, clearRequireCache -} from 'nuxt/utils' +} from 'src/utils' export default class Resolver { constructor (nuxt) { diff --git a/packages/nuxt3/src/generator/generator.ts b/packages/nuxt3/src/generator/generator.ts index 9b3b79e45a..fdfc1b3f84 100644 --- a/packages/nuxt3/src/generator/generator.ts +++ b/packages/nuxt3/src/generator/generator.ts @@ -6,7 +6,7 @@ import defu from 'defu' import htmlMinifier from 'html-minifier' import { parse } from 'node-html-parser' -import { isFullStatic, flatRoutes, isString, isUrl, promisifyRoute, waitFor, TARGETS } from 'nuxt/utils' +import { isFullStatic, flatRoutes, isString, isUrl, promisifyRoute, waitFor, TARGETS } from 'src/utils' export default class Generator { constructor (nuxt, builder) { diff --git a/packages/nuxt3/src/server/jsdom.ts b/packages/nuxt3/src/server/jsdom.ts index f61a775b82..c84b24ad55 100644 --- a/packages/nuxt3/src/server/jsdom.ts +++ b/packages/nuxt3/src/server/jsdom.ts @@ -1,5 +1,5 @@ import consola from 'consola' -import { timeout } from 'nuxt/utils' +import { timeout } from 'src/utils' export default async function renderAndGetWindow ( url = 'http://localhost:3000', diff --git a/packages/nuxt3/src/server/middleware/nuxt.ts b/packages/nuxt3/src/server/middleware/nuxt.ts index bc439547c7..3e60be3166 100644 --- a/packages/nuxt3/src/server/middleware/nuxt.ts +++ b/packages/nuxt3/src/server/middleware/nuxt.ts @@ -2,7 +2,7 @@ import generateETag from 'etag' import fresh from 'fresh' import consola from 'consola' -import { getContext, TARGETS } from 'nuxt/utils' +import { getContext, TARGETS } from 'src/utils' export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware (req, res, next) { // Get context diff --git a/packages/nuxt3/src/server/middleware/timing.ts b/packages/nuxt3/src/server/middleware/timing.ts index 5c62c02868..c0434b651c 100644 --- a/packages/nuxt3/src/server/middleware/timing.ts +++ b/packages/nuxt3/src/server/middleware/timing.ts @@ -1,6 +1,6 @@ import consola from 'consola' import onHeaders from 'on-headers' -import { Timer } from 'nuxt/utils' +import { Timer } from 'src/utils' export default options => (req, res, next) => { if (res.timing) { diff --git a/packages/nuxt3/src/server/server.ts b/packages/nuxt3/src/server/server.ts index 2019c04962..dea665936d 100644 --- a/packages/nuxt3/src/server/server.ts +++ b/packages/nuxt3/src/server/server.ts @@ -4,8 +4,8 @@ import launchMiddleware from 'launch-editor-middleware' import serveStatic from 'serve-static' import servePlaceholder from 'serve-placeholder' import connect from 'connect' -import { determineGlobals, isUrl } from 'nuxt/utils' -import { VueRenderer } from 'nuxt/vue-renderer' +import { determineGlobals, isUrl } from 'src/utils' +import { VueRenderer } from 'src/vue-renderer' import ServerContext from './context' import renderAndGetWindow from './jsdom' diff --git a/packages/nuxt3/src/vue-app/app.pages.vue b/packages/nuxt3/src/vue-app/app.pages.vue deleted file mode 100644 index 421ece8591..0000000000 --- a/packages/nuxt3/src/vue-app/app.pages.vue +++ /dev/null @@ -1,46 +0,0 @@ - - - - - diff --git a/packages/nuxt3/src/vue-app/app.tutorial.vue b/packages/nuxt3/src/vue-app/app.tutorial.vue deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/nuxt3/src/vue-app/components/index.ts b/packages/nuxt3/src/vue-app/components/index.ts deleted file mode 100644 index cd0183132b..0000000000 --- a/packages/nuxt3/src/vue-app/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -// nothing here diff --git a/packages/nuxt3/src/vue-app/declarations/node.d.ts b/packages/nuxt3/src/vue-app/declarations/node.d.ts deleted file mode 100644 index 52ed3cb71b..0000000000 --- a/packages/nuxt3/src/vue-app/declarations/node.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -declare module NodeJS { - interface Process { - browser: boolean - client: boolean - mode: 'spa' | 'universal' - modern: boolean - server: boolean - static: boolean - } -} diff --git a/packages/nuxt3/src/vue-app/declarations/nuxt-build.d.ts b/packages/nuxt3/src/vue-app/declarations/nuxt-build.d.ts deleted file mode 100644 index f9e2263e8d..0000000000 --- a/packages/nuxt3/src/vue-app/declarations/nuxt-build.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module 'nuxt-build/routes' { - import { RouteRecordRaw } from 'vue-router' - - const _default: RouteRecordRaw[] - export default _default -} diff --git a/packages/nuxt3/src/vue-app/declarations/window.d.ts b/packages/nuxt3/src/vue-app/declarations/window.d.ts deleted file mode 100644 index cbcfb2f26d..0000000000 --- a/packages/nuxt3/src/vue-app/declarations/window.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -interface Window { - __NUXT__?: Record -} diff --git a/packages/nuxt3/src/vue-app/index.ts b/packages/nuxt3/src/vue-app/index.ts deleted file mode 100644 index 8c573c09fc..0000000000 --- a/packages/nuxt3/src/vue-app/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { init } from './nuxt' diff --git a/packages/nuxt3/src/vue-app/nuxt.ts b/packages/nuxt3/src/vue-app/nuxt.ts deleted file mode 100644 index c3e10e524d..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { IncomingMessage, ServerResponse } from 'http' -import Hookable from 'hookable' -import type { App } from 'vue' - -import type { Plugin } from './types' -import { defineGetter } from './utils' - -export class Nuxt extends Hookable { - app: App - ssrContext?: Record - globalName: string - context: { - req?: IncomingMessage - res?: ServerResponse - } - - constructor ({ app, ssrContext, globalName }: { app: Nuxt['app'], ssrContext?: Nuxt['ssrContext'], globalName: Nuxt['globalName'] }) { - super() - this.app = app - this.ssrContext = ssrContext - this.globalName = globalName - } - - provide (name: string, value: any) { - const $name = '$' + name - defineGetter(this.app, $name, value) - defineGetter(this.app.config.globalProperties, $name, value) - } -} - -interface InitOptions { - app: Nuxt['app'] - plugins?: Plugin[] - ssrContext?: Nuxt['ssrContext'] - globalName?: Nuxt['globalName'] -} - -export async function init ({ app, plugins, ssrContext, globalName = 'nuxt' }: InitOptions) { - const nuxt = new Nuxt({ app, ssrContext, globalName }) - nuxt.provide('nuxt', nuxt) - - const inject: Nuxt['provide'] = nuxt.provide.bind(nuxt) - - for (const plugin of plugins) { - await plugin(nuxt, inject) - } -} - - -declare module 'vue' { - interface App { - $nuxt: Nuxt - } -} diff --git a/packages/nuxt3/src/vue-app/nuxt/entry.client.ts b/packages/nuxt3/src/vue-app/nuxt/entry.client.ts deleted file mode 100644 index 28b5b41c5f..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/entry.client.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { createSSRApp } from 'vue' -import { init } from 'nuxt-app' -import plugins from './plugins.client' -import App from '<%= appPath %>' - -async function initApp () { - const app = createSSRApp(App) - - await init({ - app, - plugins - }) - - await app.$nuxt.callHook('client:create') - - app.mount('#__nuxt') - - await app.$nuxt.callHook('client:mounted') - - console.log('App ready:', app) // eslint-disable-line no-console -} - -initApp().catch((error) => { - console.error('Error while mounting app:', error) // eslint-disable-line no-console -}) diff --git a/packages/nuxt3/src/vue-app/nuxt/entry.server.ts b/packages/nuxt3/src/vue-app/nuxt/entry.server.ts deleted file mode 100644 index c8658d0e73..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/entry.server.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createApp } from 'vue' - -import { init } from 'nuxt-app' -import plugins from 'nuxt-build/plugins.server' -import App from '<%= appPath %>' - -export default async function createNuxtAppServer (ssrContext = {}) { - const app = createApp(App) - - await init({ - app, - plugins, - ssrContext - }) - - await app.$nuxt.callHook('server:create') - - return app -} diff --git a/packages/nuxt3/src/vue-app/nuxt/layouts/default.vue b/packages/nuxt3/src/vue-app/nuxt/layouts/default.vue deleted file mode 100644 index 5d3ae9c407..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/layouts/default.vue +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/packages/nuxt3/src/vue-app/nuxt/plugins.client.ts b/packages/nuxt3/src/vue-app/nuxt/plugins.client.ts deleted file mode 100644 index 42478b7396..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/plugins.client.ts +++ /dev/null @@ -1,5 +0,0 @@ -import sharedPlugins from './plugins' - -export default [ - ...sharedPlugins -] diff --git a/packages/nuxt3/src/vue-app/nuxt/plugins.server.ts b/packages/nuxt3/src/vue-app/nuxt/plugins.server.ts deleted file mode 100644 index 19fa11178e..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/plugins.server.ts +++ /dev/null @@ -1,7 +0,0 @@ -import preload from 'nuxt-app/plugins/preload' -import sharedPlugins from './plugins' - -export default [ - ...sharedPlugins, - preload -] diff --git a/packages/nuxt3/src/vue-app/nuxt/plugins.ts b/packages/nuxt3/src/vue-app/nuxt/plugins.ts deleted file mode 100644 index fde82e51b7..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/plugins.ts +++ /dev/null @@ -1,11 +0,0 @@ -// import router from 'nuxt-app/plugins/router' -import state from 'nuxt-app/plugins/state' -import components from 'nuxt-app/plugins/components' -import legacy from 'nuxt-app/plugins/legacy' - -export default [ - // router, - state, - components, - legacy -] diff --git a/packages/nuxt3/src/vue-app/nuxt/routes.ts b/packages/nuxt3/src/vue-app/nuxt/routes.ts deleted file mode 100644 index 87adf0b0f5..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/routes.ts +++ /dev/null @@ -1,19 +0,0 @@ -const Index = () => import('~/pages' /* webpackChunkName: "Home" */) -const About = () => import('~/pages/about' /* webpackChunkName: "About" */) -const Custom = () => import('~/pages/custom' /* webpackChunkName: "Custom" */) - -export default [ - { - path: '', - __file: '@/pages/index.vue', - component: Index - }, - { - path: '/about', - component: About - }, - { - path: '/custom', - component: Custom - } -] diff --git a/packages/nuxt3/src/vue-app/nuxt/views/app.template.html b/packages/nuxt3/src/vue-app/nuxt/views/app.template.html deleted file mode 100644 index 6fc4ebb42c..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/views/app.template.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - {{ HEAD }} - - -
{{ APP }}
- - diff --git a/packages/nuxt3/src/vue-app/nuxt/views/error.html b/packages/nuxt3/src/vue-app/nuxt/views/error.html deleted file mode 100644 index c7354d5518..0000000000 --- a/packages/nuxt3/src/vue-app/nuxt/views/error.html +++ /dev/null @@ -1,23 +0,0 @@ - - - -Server error - - - - - -
-
- -
Server error
-
{{ message }}
-
- -
- - diff --git a/packages/nuxt3/src/vue-app/plugins/components.ts b/packages/nuxt3/src/vue-app/plugins/components.ts deleted file mode 100644 index 96c298c6d8..0000000000 --- a/packages/nuxt3/src/vue-app/plugins/components.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Plugin } from 'nuxt/vue-app/types' - -// import { h, defineComponent } from 'vue' -import { RouterLink } from 'vue-router' - -// const NuxtLink = defineComponent({ -// extends: Link -// }) - -const components: Plugin = function ({ app }) { - app.component('NuxtLink', RouterLink) - app.component('NLink', RouterLink) // TODO: deprecate -} - -export default components diff --git a/packages/nuxt3/src/vue-app/plugins/legacy.ts b/packages/nuxt3/src/vue-app/plugins/legacy.ts deleted file mode 100644 index f32372be32..0000000000 --- a/packages/nuxt3/src/vue-app/plugins/legacy.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { App } from 'vue' -import type { Plugin } from 'nuxt/vue-app/types' - -const legacy: Plugin = function ({ app }) { - app.$nuxt.context = {} - - if (process.client) { - const legacyApp: App & { $root?: App } = { ...app } - legacyApp.$root = legacyApp - window[app.$nuxt.globalName] = legacyApp - } - - if (process.server) { - const { ssrContext } = app.$nuxt - app.$nuxt.context.req = ssrContext.req - app.$nuxt.context.res = ssrContext.res - } -} - -export default legacy diff --git a/packages/nuxt3/src/vue-app/plugins/preload.ts b/packages/nuxt3/src/vue-app/plugins/preload.ts deleted file mode 100644 index 30ea61c9a4..0000000000 --- a/packages/nuxt3/src/vue-app/plugins/preload.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Plugin } from 'nuxt/vue-app/types' - -const preload: Plugin = function ({ app }) { - app.mixin({ - beforeCreate () { - const { _registeredComponents } = this.$nuxt.ssrContext - const { __moduleIdentifier } = this.$options - _registeredComponents.push(__moduleIdentifier) - } - }) -} - -export default preload diff --git a/packages/nuxt3/src/vue-app/plugins/router.ts b/packages/nuxt3/src/vue-app/plugins/router.ts deleted file mode 100644 index b8104d28a1..0000000000 --- a/packages/nuxt3/src/vue-app/plugins/router.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { ref } from 'vue' -import { createRouter, createWebHistory, createMemoryHistory } from 'vue-router' - -import type { Plugin } from 'nuxt/vue-app/types' - -import routes from 'nuxt-build/routes' - -const router: Plugin = function ({ app }) { - const routerHistory = process.client - ? createWebHistory() - : createMemoryHistory() - - const router = createRouter({ - history: routerHistory, - routes - }) - app.use(router) - - const previousRoute = ref() - router.afterEach((to, from) => { - previousRoute.value = from - }) - - Object.defineProperty(app.config.globalProperties, 'previousRoute', { - get: () => previousRoute.value - }) - - if (process.server) { - app.$nuxt.hook('server:create', async () => { - router.push(app.$nuxt.ssrContext.url) - await router.isReady() - }) - } else { - app.$nuxt.hook('client:create', async () => { - router.push(router.history.location.fullPath) - await router.isReady() - }) - } -} - -export default router diff --git a/packages/nuxt3/src/vue-app/plugins/state.ts b/packages/nuxt3/src/vue-app/plugins/state.ts deleted file mode 100644 index de1d20da20..0000000000 --- a/packages/nuxt3/src/vue-app/plugins/state.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Plugin } from 'nuxt/vue-app/types' - -const state: Plugin = function ({ app }) { - if (process.server) { - app.$nuxt.state = { - serverRendered: true - // data, fetch, vuex, etc. - } - app.$nuxt.ssrContext.nuxt = app.$nuxt.state - } - - if (process.client) { - app.$nuxt.state = window.__NUXT__ || {} - } -} - -export default state diff --git a/packages/nuxt3/src/vue-app/template.ts b/packages/nuxt3/src/vue-app/template.ts deleted file mode 100644 index ac901a7183..0000000000 --- a/packages/nuxt3/src/vue-app/template.ts +++ /dev/null @@ -1,12 +0,0 @@ -import path from 'path' -import globby from 'globby' - -const dir = path.join(__dirname, 'nuxt') -const files = globby.sync(path.join(dir, '/**')) - .map(f => f.replace(dir + path.sep, '')) // TODO: workaround - -export default { - dependencies: {}, - dir, - files -} diff --git a/packages/nuxt3/src/vue-app/types.ts b/packages/nuxt3/src/vue-app/types.ts deleted file mode 100644 index d61c923768..0000000000 --- a/packages/nuxt3/src/vue-app/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Nuxt } from './nuxt'; - -export interface Plugin { - (nuxt: Nuxt, inject?: Nuxt['provide']): Promise | void -} diff --git a/packages/nuxt3/src/vue-app/utils.ts b/packages/nuxt3/src/vue-app/utils.ts deleted file mode 100644 index 51fed88a2c..0000000000 --- a/packages/nuxt3/src/vue-app/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function defineGetter (obj: Record, key: K, val: V) { - Object.defineProperty(obj, key, { get: () => val }) -} diff --git a/packages/nuxt3/src/vue-app/vetur/nuxt-attributes.json b/packages/nuxt3/src/vue-app/vetur/nuxt-attributes.json deleted file mode 100644 index d6bbfa21fb..0000000000 --- a/packages/nuxt3/src/vue-app/vetur/nuxt-attributes.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "nuxtChildKey": { - "description": "This prop will be set to , useful to make transitions inside a dynamic page and different route. Default: `$route.fullPath`" - }, - "to": { - "description": "Denotes the target route of the link. When clicked, the value of the to prop will be passed to router.push() internally, so the value can be either a string or a location descriptor object." - }, - "prefetch": { - "type": "boolean", - "description": "Prefetch route target (overrides router.prefetchLinks value in nuxt.config.js)." - }, - "no-prefetch": { - "description": "Avoid prefetching route target." - }, - "replace": { - "type": "boolean", - "description": "Setting replace prop will call router.replace() instead of router.push() when clicked, so the navigation will not leave a history record." - }, - "append": { - "type": "boolean", - "description": "Setting append prop always appends the relative path to the current path. For example, assuming we are navigating from /a to a relative link b, without append we will end up at /b, but with append we will end up at /a/b." - }, - "tag": { - "description": "Specify which tag to render to, and it will still listen to click events for navigation." - }, - "active-class": { - "description": "Configure the active CSS class applied when the link is active." - }, - "exact": { - "description": "The default active class matching behavior is inclusive match. For example, will get this class applied as long as the current path starts with /a/ or is /a.\nOne consequence of this is that will be active for every route! To force the link into \"exact match mode\", use the exact prop: " - }, - "event": { - "description": "Specify the event(s) that can trigger the link navigation." - }, - "exact-active-class": { - "description": "Configure the active CSS class applied when the link is active with exact match. Note the default value can also be configured globally via the linkExactActiveClass router constructor option." - } -} diff --git a/packages/nuxt3/src/vue-app/vetur/nuxt-tags.json b/packages/nuxt3/src/vue-app/vetur/nuxt-tags.json deleted file mode 100644 index 3fc2c28194..0000000000 --- a/packages/nuxt3/src/vue-app/vetur/nuxt-tags.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "nuxt": { - "attributes": [ - "nuxtChildKey" - ], - "description": "Component to render the current nuxt page." - }, - "n-child": { - "description": "Component for displaying the children components in a nested route." - }, - "nuxt-child": { - "description": "Component for displaying the children components in a nested route." - }, - "n-link": { - "attributes": [ - "to", - "replace", - "append", - "tag", - "active-class", - "exact", - "event", - "exact-active-class", - "prefetch", - "no-prefetch" - ], - "description": "Component for navigating between Nuxt pages." - }, - "nuxt-link": { - "attributes": [ - "to", - "replace", - "append", - "tag", - "active-class", - "exact", - "event", - "exact-active-class", - "prefetch", - "no-prefetch" - ], - "description": "Component for navigating between Nuxt pages." - }, - "no-ssr": { - "description": "Component for excluding a part of your app from server-side rendering." - } -} diff --git a/packages/nuxt3/src/vue-renderer/renderer.ts b/packages/nuxt3/src/vue-renderer/renderer.ts index d9ee549950..5ffee5efe2 100644 --- a/packages/nuxt3/src/vue-renderer/renderer.ts +++ b/packages/nuxt3/src/vue-renderer/renderer.ts @@ -2,7 +2,7 @@ import path from 'path' import fs from 'fs-extra' import consola from 'consola' import template from 'lodash/template' -import { TARGETS, isModernRequest, waitFor } from 'nuxt/utils' +import { TARGETS, isModernRequest, waitFor } from 'src/utils' import SPARenderer from './renderers/spa' import SSRRenderer from './renderers/ssr' diff --git a/packages/nuxt3/src/vue-renderer/renderers/modern.ts b/packages/nuxt3/src/vue-renderer/renderers/modern.ts index 83fc24efc3..0b0e4b64da 100644 --- a/packages/nuxt3/src/vue-renderer/renderers/modern.ts +++ b/packages/nuxt3/src/vue-renderer/renderers/modern.ts @@ -1,4 +1,4 @@ -import { isUrl, urlJoin, safariNoModuleFix } from 'nuxt/utils' +import { isUrl, urlJoin, safariNoModuleFix } from 'src/utils' import SSRRenderer from './ssr' export default class ModernRenderer extends SSRRenderer { diff --git a/packages/nuxt3/src/vue-renderer/renderers/spa.ts b/packages/nuxt3/src/vue-renderer/renderers/spa.ts index f557752192..78943a43ba 100644 --- a/packages/nuxt3/src/vue-renderer/renderers/spa.ts +++ b/packages/nuxt3/src/vue-renderer/renderers/spa.ts @@ -3,7 +3,7 @@ import cloneDeep from 'lodash/cloneDeep' import VueMeta from 'vue-meta' import LRU from 'lru-cache' import devalue from '@nuxt/devalue' -import { TARGETS, isModernRequest } from 'nuxt/utils' +import { TARGETS, isModernRequest } from 'src/utils' import BaseRenderer from './base' export default class SPARenderer extends BaseRenderer { diff --git a/packages/nuxt3/src/vue-renderer/renderers/ssr.ts b/packages/nuxt3/src/vue-renderer/renderers/ssr.ts index d75a05dc88..068aea5e2f 100644 --- a/packages/nuxt3/src/vue-renderer/renderers/ssr.ts +++ b/packages/nuxt3/src/vue-renderer/renderers/ssr.ts @@ -3,7 +3,7 @@ import crypto from 'crypto' import { format } from 'util' import fs from 'fs-extra' import consola from 'consola' -import { TARGETS, urlJoin } from 'nuxt/utils' +import { TARGETS, urlJoin } from 'src/utils' import devalue from '@nuxt/devalue' import { createBundleRenderer } from 'vue-bundle-renderer' import BaseRenderer from './base' diff --git a/packages/nuxt3/src/webpack/builder.ts b/packages/nuxt3/src/webpack/builder.ts index 1d477d28d3..666ccdd6e9 100644 --- a/packages/nuxt3/src/webpack/builder.ts +++ b/packages/nuxt3/src/webpack/builder.ts @@ -6,7 +6,7 @@ import webpackDevMiddleware from 'webpack-dev-middleware' import webpackHotMiddleware from 'webpack-hot-middleware' import consola from 'consola' -import { TARGETS, parallel, sequence, wrapArray, isModernRequest } from 'nuxt/utils' +import { TARGETS, parallel, sequence, wrapArray, isModernRequest } from 'src/utils' import { createMFS } from './utils/mfs' import * as WebpackConfigs from './config' diff --git a/packages/nuxt3/src/webpack/config/base.ts b/packages/nuxt3/src/webpack/config/base.ts index 003e609e92..2372899100 100644 --- a/packages/nuxt3/src/webpack/config/base.ts +++ b/packages/nuxt3/src/webpack/config/base.ts @@ -9,7 +9,7 @@ import TerserWebpackPlugin from 'terser-webpack-plugin' import WebpackBar from 'webpackbar' import env from 'std-env' import semver from 'semver' -import { TARGETS, isUrl, urlJoin, getPKG } from 'nuxt/utils' +import { TARGETS, isUrl, urlJoin, getPKG } from 'src/utils' import PerfLoader from '../utils/perf-loader' import StyleLoader from '../utils/style-loader' import WarningIgnorePlugin from '../plugins/warning-ignore' @@ -258,7 +258,7 @@ export default class WebpackBaseConfig { alias () { return { ...this.buildContext.options.alias, - 'nuxt-app': path.dirname(require.resolve('../../vue-app')), + 'app': this.buildContext.options.appDir, 'nuxt-build': this.buildContext.options.buildDir, 'vue-meta': require.resolve(`vue-meta${this.isServer ? '' : '/dist/vue-meta.esm.browser.js'}`) } @@ -304,7 +304,7 @@ export default class WebpackBaseConfig { ] }, { - test: /\.m?jsx?$/i, + test: /\.m?[jt]sx?$/i, exclude: (file) => { file = file.split('node_modules', 2)[1] diff --git a/packages/nuxt3/src/webpack/plugins/vue/modern.ts b/packages/nuxt3/src/webpack/plugins/vue/modern.ts index 11e60b3dfe..855380f7ba 100644 --- a/packages/nuxt3/src/webpack/plugins/vue/modern.ts +++ b/packages/nuxt3/src/webpack/plugins/vue/modern.ts @@ -5,7 +5,7 @@ import EventEmitter from 'events' import HtmlWebpackPlugin from 'html-webpack-plugin' -import { safariNoModuleFix } from 'nuxt/utils' +import { safariNoModuleFix } from 'src/utils' const assetsMap = {} const watcher = new EventEmitter() diff --git a/packages/nuxt3/src/webpack/utils/postcss.ts b/packages/nuxt3/src/webpack/utils/postcss.ts index 5a699fdf21..564ba9b2ed 100644 --- a/packages/nuxt3/src/webpack/utils/postcss.ts +++ b/packages/nuxt3/src/webpack/utils/postcss.ts @@ -6,7 +6,7 @@ import merge from 'lodash/merge' import cloneDeep from 'lodash/cloneDeep' import createResolver from 'postcss-import-resolver' -import { isPureObject } from 'nuxt/utils' +import { isPureObject } from 'src/utils' export const orderPresets = { cssnanoLast (names) { diff --git a/packages/nuxt3/src/webpack/utils/style-loader.ts b/packages/nuxt3/src/webpack/utils/style-loader.ts index b0a37db9b8..3a1962a83e 100644 --- a/packages/nuxt3/src/webpack/utils/style-loader.ts +++ b/packages/nuxt3/src/webpack/utils/style-loader.ts @@ -1,7 +1,7 @@ import path from 'path' import ExtractCssChunksPlugin from 'extract-css-chunks-webpack-plugin' -import { wrapArray } from 'nuxt/utils' +import { wrapArray } from 'src/utils' import PostcssConfig from './postcss'