refactor(nitro): use # prefix for aliases (#101)

This commit is contained in:
pooya parsa 2021-04-20 13:03:18 +02:00 committed by GitHub
parent 1b10a1f091
commit 5646770cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 15 deletions

View File

@ -174,7 +174,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
...nitroContext.middleware ...nitroContext.middleware
] ]
if (nitroContext.serveStatic) { if (nitroContext.serveStatic) {
_middleware.unshift({ route: '/', handle: '~runtime/server/static' }) _middleware.unshift({ route: '/', handle: '#nitro/server/static' })
} }
return _middleware return _middleware
})) }))
@ -189,10 +189,10 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
const vue2ServerRenderer = 'vue-server-renderer/' + (nitroContext._nuxt.dev ? 'build.dev.js' : 'build.prod.js') const vue2ServerRenderer = 'vue-server-renderer/' + (nitroContext._nuxt.dev ? 'build.dev.js' : 'build.prod.js')
rollupConfig.plugins.push(alias({ rollupConfig.plugins.push(alias({
entries: { entries: {
'~runtime': nitroContext._internal.runtimeDir, '#nitro': nitroContext._internal.runtimeDir,
'~renderer': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer)), '#nitro-renderer': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer)),
'~vueServerRenderer': vue2ServerRenderer, '#nitro-vue-renderer': vue2ServerRenderer,
'~build': nitroContext._nuxt.buildDir, '#build': nitroContext._nuxt.buildDir,
...env.alias ...env.alias
} }
})) }))

View File

@ -38,7 +38,7 @@ export function statAsset (id) {
if (!opts.inline) { if (!opts.inline) {
return virtual({ return virtual({
'~nitro/assets': ` '#assets': `
import { statSync, promises as fsp } from 'fs' import { statSync, promises as fsp } from 'fs'
import { resolve } from 'path' import { resolve } from 'path'
@ -68,7 +68,7 @@ export function getAsset (id) {
} }
return virtual({ return virtual({
'~nitro/assets': { '#assets': {
async load () { async load () {
const assets: Record<string, Asset> = {} const assets: Record<string, Asset> = {}
for (const assetdir in opts.dirs) { for (const assetdir in opts.dirs) {

View File

@ -18,7 +18,7 @@ export function externals (opts: NodeExternalsOptions): Plugin {
name: 'node-externals', name: 'node-externals',
resolveId (id) { resolveId (id) {
// Internals // Internals
if (!id || id.startsWith('\x00') || id.includes('?')) { if (!id || id.startsWith('\x00') || id.includes('?') || id.startsWith('#')) {
return null return null
} }

View File

@ -30,7 +30,7 @@ export function storage (opts: StorageOptions) {
const driverImports = Array.from(new Set(mounts.map(m => m.driver))) const driverImports = Array.from(new Set(mounts.map(m => m.driver)))
return virtual({ return virtual({
'~nitro/storage': ` '#storage': `
import { createStorage } from 'unstorage' import { createStorage } from 'unstorage'
${driverImports.map(i => `import ${getImportName(i)} from '${i}'`).join('\n')} ${driverImports.map(i => `import ${getImportName(i)} from '${i}'`).join('\n')}

View File

@ -2,13 +2,13 @@ import { createRenderer } from 'vue-bundle-renderer'
import devalue from '@nuxt/devalue' import devalue from '@nuxt/devalue'
import config from './config' import config from './config'
// @ts-ignore // @ts-ignore
import { renderToString } from '~renderer' import { renderToString } from '#nitro-renderer'
// @ts-ignore // @ts-ignore
import createApp from '~build/dist/server/server' import createApp from '#build/dist/server/server'
// @ts-ignore // @ts-ignore
import clientManifest from '~build/dist/server/client.manifest.json' import clientManifest from '#build/dist/server/client.manifest.json'
// @ts-ignore // @ts-ignore
import htmlTemplate from '~build/views/document.template.js' import htmlTemplate from '#build/views/document.template.js'
function _interopDefault (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e } function _interopDefault (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e }

View File

@ -1,5 +1,5 @@
// @ts-ignore // @ts-ignore
import { createRenderer } from '~vueServerRenderer' import { createRenderer } from '#nitro-vue-renderer'
const _renderer = createRenderer({}) const _renderer = createRenderer({})
// @ts-ignore // @ts-ignore

View File

@ -1,6 +1,6 @@
// @ts-ignore // @ts-ignore
import { builderFunction } from '@netlify/functions' import { builderFunction } from '@netlify/functions'
// @ts-ignore // @ts-ignore
import { handler as _handler } from '~runtime/entries/lambda' import { handler as _handler } from '#nitro/entries/lambda'
export const handler = builderFunction(_handler) export const handler = builderFunction(_handler)