refactor: use # prefex for internal aliases

leftovers
This commit is contained in:
Pooya Parsa 2021-06-18 11:54:35 +02:00
parent 98a0c727c9
commit 3398d5a7d6
16 changed files with 18 additions and 18 deletions

View File

@ -189,7 +189,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
// Polyfill // Polyfill
rollupConfig.plugins.push(virtual({ rollupConfig.plugins.push(virtual({
'~polyfill': env.polyfill.map(p => `import '${p}';`).join('\n') '#polyfill': env.polyfill.map(p => `import '${p}';`).join('\n')
})) }))
// https://github.com/rollup/plugins/tree/master/packages/alias // https://github.com/rollup/plugins/tree/master/packages/alias

View File

@ -12,7 +12,7 @@ export function middleware (getMiddleware: () => ServerMiddleware[]) {
let lastDump = '' let lastDump = ''
return virtual({ return virtual({
'~serverMiddleware': { '#server-middleware': {
load: () => { load: () => {
const middleware = getMiddleware() const middleware = getMiddleware()

View File

@ -28,11 +28,11 @@ export function staticAssets (context: NitroContext) {
} }
return virtual({ return virtual({
'~static-assets': `export default ${JSON.stringify(assets, null, 2)};`, '#static-assets': `export default ${JSON.stringify(assets, null, 2)};`,
'~static': ` '#static': `
import { promises } from 'fs' import { promises } from 'fs'
import { resolve } from 'path' import { resolve } from 'path'
import assets from '~static-assets' import assets from '#static-assets'
export function readAsset (id) { export function readAsset (id) {
return promises.readFile(resolve(mainDir, getAsset(id).path)) return promises.readFile(resolve(mainDir, getAsset(id).path))

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { parseURL } from 'ufo' import { parseURL } from 'ufo'
import { localCall } from '../server' import { localCall } from '../server'

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { localCall } from '../server' import { localCall } from '../server'
export default async function handle (context, req) { export default async function handle (context, req) {

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { localCall } from '../server' import { localCall } from '../server'
async function cli () { async function cli () {

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { getAssetFromKV } from '@cloudflare/kv-asset-handler' import { getAssetFromKV } from '@cloudflare/kv-asset-handler'
import { localCall } from '../server' import { localCall } from '../server'

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { Server } from 'http' import { Server } from 'http'
import { parentPort } from 'worker_threads' import { parentPort } from 'worker_threads'
import type { AddressInfo } from 'net' import type { AddressInfo } from 'net'

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { handle } from '../server' import { handle } from '../server'

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { withQuery } from 'ufo' import { withQuery } from 'ufo'
import { localCall } from '../server' import { localCall } from '../server'

View File

@ -1,2 +1,2 @@
import '~polyfill' import '#polyfill'
export * from '../server' export * from '../server'

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { Server } from 'http' import { Server } from 'http'
import destr from 'destr' import destr from 'destr'
import { handle } from '../server' import { handle } from '../server'

View File

@ -1,5 +1,5 @@
// @ts-nocheck // @ts-nocheck
import '~polyfill' import '#polyfill'
import { localCall } from '../server' import { localCall } from '../server'
addEventListener('fetch', (event: any) => { addEventListener('fetch', (event: any) => {

View File

@ -1,4 +1,4 @@
import '~polyfill' import '#polyfill'
import { handle } from '../server' import { handle } from '../server'
export default handle export default handle

View File

@ -6,7 +6,7 @@ import { createCall, createFetch as createLocalFetch } from 'unenv/runtime/fetch
import { timingMiddleware } from './timing' import { timingMiddleware } from './timing'
import { handleError } from './error' import { handleError } from './error'
// @ts-ignore // @ts-ignore
import serverMiddleware from '~serverMiddleware' import serverMiddleware from '#server-middleware'
const app = createApp({ const app = createApp({
debug: destr(process.env.DEBUG), debug: destr(process.env.DEBUG),

View File

@ -1,7 +1,7 @@
import { createError } from 'h3' import { createError } from 'h3'
import { withoutTrailingSlash, withLeadingSlash, parseURL } from 'ufo' import { withoutTrailingSlash, withLeadingSlash, parseURL } from 'ufo'
// @ts-ignore // @ts-ignore
import { getAsset, readAsset } from '~static' import { getAsset, readAsset } from '#static'
const METHODS = ['HEAD', 'GET'] const METHODS = ['HEAD', 'GET']
const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/ const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/