diff --git a/package.json b/package.json index 830bb0a546..b15341c5fe 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,9 @@ ], "scripts": { "link": "lerna link", - "nuxt": "jiti ./scripts/nuxt", "build": "yarn workspaces run build --silent", "stub": "yarn workspaces run stub --silent", - "play": "yarn nuxt dev playground", + "play": "yarn nu dev playground", "lint": "eslint --ext .vue,.ts,.js .", "test": "yarn lint", "postinstall": "yarn stub" diff --git a/packages/nu/bin/nu.js b/packages/nu/bin/nu.js new file mode 100755 index 0000000000..6243ac7577 --- /dev/null +++ b/packages/nu/bin/nu.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +require('..').main() diff --git a/packages/nu/package.json b/packages/nu/package.json new file mode 100644 index 0000000000..8e4899f9a7 --- /dev/null +++ b/packages/nu/package.json @@ -0,0 +1,24 @@ +{ + "name": "@nuxt/nu", + "version": "0.0.0", + "repository": "nuxt/framework", + "license": "MIT", + "main": "./dist/index.js", + "bin": { + "nu": "./bin/nu.js" + }, + "files": [ + "bin", + "dist" + ], + "scripts": { + "build": "jiti ../../scripts/build .", + "stub": "yarn build --stub", + "prepublishOnly": "yarn build" + }, + "build": { + "entries": { + "index": { "format": "cjs" } + } + } +} diff --git a/packages/nuxt3/src/cli.ts b/packages/nu/src/index.ts similarity index 90% rename from packages/nuxt3/src/cli.ts rename to packages/nu/src/index.ts index 0384baf141..4a748d5d6e 100755 --- a/packages/nuxt3/src/cli.ts +++ b/packages/nu/src/index.ts @@ -1,17 +1,20 @@ import { resolve } from 'path' -import { loadNuxt } from './core/load' -import { build } from './builder' async function _main () { const args = process.argv.splice(2) const cmd = args[0] + if (!['dev', 'build'].includes(cmd)) { // eslint-disable-next-line no-console console.error('Usage nuxt dev|build [rootDir]') process.exit(1) } + const isDev = cmd === 'dev' const rootDir = resolve(process.cwd(), args[1] || '.') + + const { loadNuxt, build } = await import('nuxt3') + const nuxt = await loadNuxt({ for: isDev ? 'dev' : 'build', rootDir }) if (isDev) { diff --git a/packages/nuxt3/src/index.ts b/packages/nuxt3/src/index.ts index b9be2c102c..a918a9a721 100644 --- a/packages/nuxt3/src/index.ts +++ b/packages/nuxt3/src/index.ts @@ -1,3 +1,3 @@ export { loadNuxt } from './core' export { build } from './builder' -export { main } from './cli' +export { main } from '../../nu/src' diff --git a/scripts/nuxt.ts b/scripts/nuxt.ts deleted file mode 100755 index 287c7f32d8..0000000000 --- a/scripts/nuxt.ts +++ /dev/null @@ -1 +0,0 @@ -require('nuxt3').main()