diff --git a/packages/app/package.json b/packages/app/package.json new file mode 100644 index 0000000000..c52101bfb4 --- /dev/null +++ b/packages/app/package.json @@ -0,0 +1,31 @@ +{ + "name": "@nuxt/app", + "version": "0.0.0", + "repository": "nuxt/framework", + "license": "MIT", + "main": "./dist/index.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "mkdist", + "stub": "rm -rf dist && ln -s src dist #", + "prepublishOnly": "yarn build" + }, + "dependencies": { + "create-require": "^1.1.1", + "defu": "^3.2.2", + "dotenv": "^8.2.0", + "jiti": "^1.6.4", + "rc9": "^1.2.0", + "scule": "^0.1.1", + "std-env": "^2.3.0", + "ufo": "^0.6.10", + "untyped": "^0.2.2" + }, + "build": { + "entries": { + "index": {} + } + } +} diff --git a/packages/nuxt3/src/app/_templates/entry.client.js b/packages/app/src/_templates/entry.client.js similarity index 100% rename from packages/nuxt3/src/app/_templates/entry.client.js rename to packages/app/src/_templates/entry.client.js diff --git a/packages/nuxt3/src/app/_templates/entry.server.js b/packages/app/src/_templates/entry.server.js similarity index 100% rename from packages/nuxt3/src/app/_templates/entry.server.js rename to packages/app/src/_templates/entry.server.js diff --git a/packages/nuxt3/src/app/_templates/layouts/default.vue b/packages/app/src/_templates/layouts/default.vue similarity index 100% rename from packages/nuxt3/src/app/_templates/layouts/default.vue rename to packages/app/src/_templates/layouts/default.vue diff --git a/packages/nuxt3/src/app/_templates/plugins.client.js b/packages/app/src/_templates/plugins.client.js similarity index 100% rename from packages/nuxt3/src/app/_templates/plugins.client.js rename to packages/app/src/_templates/plugins.client.js diff --git a/packages/nuxt3/src/app/_templates/plugins.js b/packages/app/src/_templates/plugins.js similarity index 100% rename from packages/nuxt3/src/app/_templates/plugins.js rename to packages/app/src/_templates/plugins.js diff --git a/packages/nuxt3/src/app/_templates/plugins.server.js b/packages/app/src/_templates/plugins.server.js similarity index 100% rename from packages/nuxt3/src/app/_templates/plugins.server.js rename to packages/app/src/_templates/plugins.server.js diff --git a/packages/nuxt3/src/app/_templates/routes.js b/packages/app/src/_templates/routes.js similarity index 100% rename from packages/nuxt3/src/app/_templates/routes.js rename to packages/app/src/_templates/routes.js diff --git a/packages/nuxt3/src/app/_templates/views/app.template.html b/packages/app/src/_templates/views/app.template.html similarity index 100% rename from packages/nuxt3/src/app/_templates/views/app.template.html rename to packages/app/src/_templates/views/app.template.html diff --git a/packages/nuxt3/src/app/_templates/views/error.html b/packages/app/src/_templates/views/error.html similarity index 100% rename from packages/nuxt3/src/app/_templates/views/error.html rename to packages/app/src/_templates/views/error.html diff --git a/packages/nuxt3/src/app/app.pages.vue b/packages/app/src/app.pages.vue similarity index 100% rename from packages/nuxt3/src/app/app.pages.vue rename to packages/app/src/app.pages.vue diff --git a/packages/nuxt3/src/app/app.tutorial.vue b/packages/app/src/app.tutorial.vue similarity index 100% rename from packages/nuxt3/src/app/app.tutorial.vue rename to packages/app/src/app.tutorial.vue diff --git a/packages/nuxt3/src/app/composables/asyncData.ts b/packages/app/src/composables/asyncData.ts similarity index 100% rename from packages/nuxt3/src/app/composables/asyncData.ts rename to packages/app/src/composables/asyncData.ts diff --git a/packages/nuxt3/src/app/composables/data.ts b/packages/app/src/composables/data.ts similarity index 100% rename from packages/nuxt3/src/app/composables/data.ts rename to packages/app/src/composables/data.ts diff --git a/packages/nuxt3/src/app/composables/hydrate.ts b/packages/app/src/composables/hydrate.ts similarity index 100% rename from packages/nuxt3/src/app/composables/hydrate.ts rename to packages/app/src/composables/hydrate.ts diff --git a/packages/nuxt3/src/app/composables/index.ts b/packages/app/src/composables/index.ts similarity index 100% rename from packages/nuxt3/src/app/composables/index.ts rename to packages/app/src/composables/index.ts diff --git a/packages/nuxt3/src/app/declarations/node.d.ts b/packages/app/src/declarations/node.d.ts similarity index 100% rename from packages/nuxt3/src/app/declarations/node.d.ts rename to packages/app/src/declarations/node.d.ts diff --git a/packages/nuxt3/src/app/declarations/nuxt-build.d.ts b/packages/app/src/declarations/nuxt-build.d.ts similarity index 100% rename from packages/nuxt3/src/app/declarations/nuxt-build.d.ts rename to packages/app/src/declarations/nuxt-build.d.ts diff --git a/packages/nuxt3/src/app/declarations/shim.d.ts b/packages/app/src/declarations/shim.d.ts similarity index 100% rename from packages/nuxt3/src/app/declarations/shim.d.ts rename to packages/app/src/declarations/shim.d.ts diff --git a/packages/nuxt3/src/app/declarations/types.ts b/packages/app/src/declarations/types.ts similarity index 100% rename from packages/nuxt3/src/app/declarations/types.ts rename to packages/app/src/declarations/types.ts diff --git a/packages/nuxt3/src/app/declarations/window.d.ts b/packages/app/src/declarations/window.d.ts similarity index 100% rename from packages/nuxt3/src/app/declarations/window.d.ts rename to packages/app/src/declarations/window.d.ts diff --git a/packages/nuxt3/src/app/index.ts b/packages/app/src/index.ts similarity index 100% rename from packages/nuxt3/src/app/index.ts rename to packages/app/src/index.ts diff --git a/packages/nuxt3/src/app/nuxt/composables.ts b/packages/app/src/nuxt/composables.ts similarity index 100% rename from packages/nuxt3/src/app/nuxt/composables.ts rename to packages/app/src/nuxt/composables.ts diff --git a/packages/nuxt3/src/app/nuxt/index.ts b/packages/app/src/nuxt/index.ts similarity index 100% rename from packages/nuxt3/src/app/nuxt/index.ts rename to packages/app/src/nuxt/index.ts diff --git a/packages/nuxt3/src/app/pages/404.vue b/packages/app/src/pages/404.vue similarity index 100% rename from packages/nuxt3/src/app/pages/404.vue rename to packages/app/src/pages/404.vue diff --git a/packages/nuxt3/src/app/plugins/head/head.ts b/packages/app/src/plugins/head/head.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/head/head.ts rename to packages/app/src/plugins/head/head.ts diff --git a/packages/nuxt3/src/app/plugins/head/index.ts b/packages/app/src/plugins/head/index.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/head/index.ts rename to packages/app/src/plugins/head/index.ts diff --git a/packages/nuxt3/src/app/plugins/legacy.ts b/packages/app/src/plugins/legacy.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/legacy.ts rename to packages/app/src/plugins/legacy.ts diff --git a/packages/nuxt3/src/app/plugins/logs.client.dev.ts b/packages/app/src/plugins/logs.client.dev.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/logs.client.dev.ts rename to packages/app/src/plugins/logs.client.dev.ts diff --git a/packages/nuxt3/src/app/plugins/preload.server.ts b/packages/app/src/plugins/preload.server.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/preload.server.ts rename to packages/app/src/plugins/preload.server.ts diff --git a/packages/nuxt3/src/app/plugins/progress.client.ts b/packages/app/src/plugins/progress.client.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/progress.client.ts rename to packages/app/src/plugins/progress.client.ts diff --git a/packages/nuxt3/src/app/plugins/router/NuxtPage.vue b/packages/app/src/plugins/router/NuxtPage.vue similarity index 100% rename from packages/nuxt3/src/app/plugins/router/NuxtPage.vue rename to packages/app/src/plugins/router/NuxtPage.vue diff --git a/packages/nuxt3/src/app/plugins/router/index.ts b/packages/app/src/plugins/router/index.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/router/index.ts rename to packages/app/src/plugins/router/index.ts diff --git a/packages/nuxt3/src/app/plugins/vuex.ts b/packages/app/src/plugins/vuex.ts similarity index 100% rename from packages/nuxt3/src/app/plugins/vuex.ts rename to packages/app/src/plugins/vuex.ts diff --git a/packages/nuxt3/src/app/utils/index.ts b/packages/app/src/utils/index.ts similarity index 100% rename from packages/nuxt3/src/app/utils/index.ts rename to packages/app/src/utils/index.ts diff --git a/packages/kit/package.json b/packages/kit/package.json index 6dcc1406b1..8a7551289f 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -4,6 +4,7 @@ "repository": "nuxt/framework", "license": "MIT", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], @@ -26,7 +27,7 @@ }, "build": { "entries": { - "index": {} + "index": { "format": "cjs" } } } } diff --git a/packages/nitro/package.json b/packages/nitro/package.json index f60dcaa892..de44b5d42d 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -14,7 +14,7 @@ }, "build": { "entries": { - "index": {}, + "index": { "format": "cjs" }, "compat": { "format": "cjs" }, "runtime/": {} }, diff --git a/packages/nuxt3/package.json b/packages/nuxt3/package.json index 5350df9f31..901a2bccdc 100644 --- a/packages/nuxt3/package.json +++ b/packages/nuxt3/package.json @@ -14,8 +14,7 @@ }, "build": { "entries": { - "index": {}, - "app/": {} + "index": { "format": "cjs" } }, "dependencies": [ "@vue/compiler-sfc", @@ -39,6 +38,7 @@ ] }, "dependencies": { + "@nuxt/app": "0.0.0", "@nuxt/friendly-errors-webpack-plugin": "^2.5.0", "@nuxt/nitro": "^0.1.11", "@vitejs/plugin-vue": "^1.1.5", diff --git a/packages/nuxt3/src/consts.ts b/packages/nuxt3/src/consts.ts deleted file mode 100644 index dcb9f8dcbf..0000000000 --- a/packages/nuxt3/src/consts.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { resolve } from 'path' - -export const APP_DIR = resolve(__dirname, 'app') diff --git a/packages/nuxt3/src/core/load.ts b/packages/nuxt3/src/core/load.ts index 492dfed93b..6584be162e 100644 --- a/packages/nuxt3/src/core/load.ts +++ b/packages/nuxt3/src/core/load.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path' +import { dirname } from 'path' import { loadNuxtConfig } from '@nuxt/kit' import Nuxt from './nuxt' export interface LoadNuxtOptions { @@ -8,7 +8,7 @@ export async function loadNuxt (opts: LoadNuxtOptions) { const options = await loadNuxtConfig(opts) // Temp - options.appDir = resolve(__dirname, '../app') + options.appDir = dirname(require.resolve('@nuxt/app')) options._majorVersion = 3 const nuxt = new Nuxt(options) diff --git a/packages/nuxt3/src/index.ts b/packages/nuxt3/src/index.ts index c618652485..b9be2c102c 100644 --- a/packages/nuxt3/src/index.ts +++ b/packages/nuxt3/src/index.ts @@ -1,4 +1,3 @@ - export { loadNuxt } from './core' export { build } from './builder' export { main } from './cli' diff --git a/scripts/build.ts b/scripts/build.ts index a2d6bf414e..f5eb8c594f 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -56,12 +56,12 @@ async function main () { if (entry.bundle) { const input = resolve(ctx.rootDir, entry.input) stubbed.push(entry.output) - const output = resolve(ctx.rootDir, entry.output) + '.ts' + const output = resolve(ctx.rootDir, entry.output) + '.js' await mkdir(dirname(output)).catch(() => { }) - await writeFile(output, entry.format === 'cjs' - ? `module.exports = require('jiti')()('${input}')` - : `export * from '${input}'` - ) + const cjsStub = `module.exports = require('jiti')()('${input}')` + const esStub = `export * from '${input}'` + await writeFile(output, entry.format === 'cjs' ? cjsStub : esStub) + await writeFile(output.replace('.js', '.d.ts'), esStub) } } consola.success(`Stub done: ${stubbed.join(', ')}`)