mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
refactor: externalize @nuxt/app
This commit is contained in:
parent
46f771a98b
commit
c95d88c6cb
31
packages/app/package.json
Normal file
31
packages/app/package.json
Normal file
@ -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": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -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" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
},
|
||||
"build": {
|
||||
"entries": {
|
||||
"index": {},
|
||||
"index": { "format": "cjs" },
|
||||
"compat": { "format": "cjs" },
|
||||
"runtime/": {}
|
||||
},
|
||||
|
@ -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",
|
||||
|
@ -1,3 +0,0 @@
|
||||
import { resolve } from 'path'
|
||||
|
||||
export const APP_DIR = resolve(__dirname, 'app')
|
@ -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)
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export { loadNuxt } from './core'
|
||||
export { build } from './builder'
|
||||
export { main } from './cli'
|
||||
|
@ -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(', ')}`)
|
||||
|
Loading…
Reference in New Issue
Block a user