From 3398d5a7d6617528787f6522b7172efaaae0c2e2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 18 Jun 2021 11:54:35 +0200 Subject: [PATCH] refactor: use # prefex for internal aliases leftovers --- packages/nitro/src/rollup/config.ts | 2 +- packages/nitro/src/rollup/plugins/middleware.ts | 2 +- packages/nitro/src/rollup/plugins/static.ts | 6 +++--- packages/nitro/src/runtime/entries/azure.ts | 2 +- packages/nitro/src/runtime/entries/azure_functions.ts | 2 +- packages/nitro/src/runtime/entries/cli.ts | 2 +- packages/nitro/src/runtime/entries/cloudflare.ts | 2 +- packages/nitro/src/runtime/entries/dev.ts | 2 +- packages/nitro/src/runtime/entries/firebase.ts | 2 +- packages/nitro/src/runtime/entries/lambda.ts | 2 +- packages/nitro/src/runtime/entries/node.ts | 2 +- packages/nitro/src/runtime/entries/server.ts | 2 +- packages/nitro/src/runtime/entries/service-worker.ts | 2 +- packages/nitro/src/runtime/entries/vercel.ts | 2 +- packages/nitro/src/runtime/server/index.ts | 2 +- packages/nitro/src/runtime/server/static.ts | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/nitro/src/rollup/config.ts b/packages/nitro/src/rollup/config.ts index 041e253e8b..0fffe7a937 100644 --- a/packages/nitro/src/rollup/config.ts +++ b/packages/nitro/src/rollup/config.ts @@ -189,7 +189,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => { // Polyfill 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 diff --git a/packages/nitro/src/rollup/plugins/middleware.ts b/packages/nitro/src/rollup/plugins/middleware.ts index 9bc1dd26de..a2029dbeb8 100644 --- a/packages/nitro/src/rollup/plugins/middleware.ts +++ b/packages/nitro/src/rollup/plugins/middleware.ts @@ -12,7 +12,7 @@ export function middleware (getMiddleware: () => ServerMiddleware[]) { let lastDump = '' return virtual({ - '~serverMiddleware': { + '#server-middleware': { load: () => { const middleware = getMiddleware() diff --git a/packages/nitro/src/rollup/plugins/static.ts b/packages/nitro/src/rollup/plugins/static.ts index 7ef673a464..3bee3066eb 100644 --- a/packages/nitro/src/rollup/plugins/static.ts +++ b/packages/nitro/src/rollup/plugins/static.ts @@ -28,11 +28,11 @@ export function staticAssets (context: NitroContext) { } return virtual({ - '~static-assets': `export default ${JSON.stringify(assets, null, 2)};`, - '~static': ` + '#static-assets': `export default ${JSON.stringify(assets, null, 2)};`, + '#static': ` import { promises } from 'fs' import { resolve } from 'path' -import assets from '~static-assets' +import assets from '#static-assets' export function readAsset (id) { return promises.readFile(resolve(mainDir, getAsset(id).path)) diff --git a/packages/nitro/src/runtime/entries/azure.ts b/packages/nitro/src/runtime/entries/azure.ts index 04621ab38a..5b36e566db 100644 --- a/packages/nitro/src/runtime/entries/azure.ts +++ b/packages/nitro/src/runtime/entries/azure.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { parseURL } from 'ufo' import { localCall } from '../server' diff --git a/packages/nitro/src/runtime/entries/azure_functions.ts b/packages/nitro/src/runtime/entries/azure_functions.ts index eb309aa7f3..b2536ddfef 100644 --- a/packages/nitro/src/runtime/entries/azure_functions.ts +++ b/packages/nitro/src/runtime/entries/azure_functions.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { localCall } from '../server' export default async function handle (context, req) { diff --git a/packages/nitro/src/runtime/entries/cli.ts b/packages/nitro/src/runtime/entries/cli.ts index 91d3141266..390157169b 100644 --- a/packages/nitro/src/runtime/entries/cli.ts +++ b/packages/nitro/src/runtime/entries/cli.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { localCall } from '../server' async function cli () { diff --git a/packages/nitro/src/runtime/entries/cloudflare.ts b/packages/nitro/src/runtime/entries/cloudflare.ts index dd953b9db1..2f5fddbeb0 100644 --- a/packages/nitro/src/runtime/entries/cloudflare.ts +++ b/packages/nitro/src/runtime/entries/cloudflare.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { getAssetFromKV } from '@cloudflare/kv-asset-handler' import { localCall } from '../server' diff --git a/packages/nitro/src/runtime/entries/dev.ts b/packages/nitro/src/runtime/entries/dev.ts index 7386fb5f39..9e6ea538fb 100644 --- a/packages/nitro/src/runtime/entries/dev.ts +++ b/packages/nitro/src/runtime/entries/dev.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { Server } from 'http' import { parentPort } from 'worker_threads' import type { AddressInfo } from 'net' diff --git a/packages/nitro/src/runtime/entries/firebase.ts b/packages/nitro/src/runtime/entries/firebase.ts index ffbeba419f..162fa04071 100644 --- a/packages/nitro/src/runtime/entries/firebase.ts +++ b/packages/nitro/src/runtime/entries/firebase.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { handle } from '../server' diff --git a/packages/nitro/src/runtime/entries/lambda.ts b/packages/nitro/src/runtime/entries/lambda.ts index 897eb689bc..116b58c21c 100644 --- a/packages/nitro/src/runtime/entries/lambda.ts +++ b/packages/nitro/src/runtime/entries/lambda.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { withQuery } from 'ufo' import { localCall } from '../server' diff --git a/packages/nitro/src/runtime/entries/node.ts b/packages/nitro/src/runtime/entries/node.ts index 5646685d25..1e713c313c 100644 --- a/packages/nitro/src/runtime/entries/node.ts +++ b/packages/nitro/src/runtime/entries/node.ts @@ -1,2 +1,2 @@ -import '~polyfill' +import '#polyfill' export * from '../server' diff --git a/packages/nitro/src/runtime/entries/server.ts b/packages/nitro/src/runtime/entries/server.ts index a03ce951e7..4bd5f92bb4 100644 --- a/packages/nitro/src/runtime/entries/server.ts +++ b/packages/nitro/src/runtime/entries/server.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { Server } from 'http' import destr from 'destr' import { handle } from '../server' diff --git a/packages/nitro/src/runtime/entries/service-worker.ts b/packages/nitro/src/runtime/entries/service-worker.ts index 6db71038cc..d5bbfafc6e 100644 --- a/packages/nitro/src/runtime/entries/service-worker.ts +++ b/packages/nitro/src/runtime/entries/service-worker.ts @@ -1,5 +1,5 @@ // @ts-nocheck -import '~polyfill' +import '#polyfill' import { localCall } from '../server' addEventListener('fetch', (event: any) => { diff --git a/packages/nitro/src/runtime/entries/vercel.ts b/packages/nitro/src/runtime/entries/vercel.ts index 3967889b40..9ffc6566a6 100644 --- a/packages/nitro/src/runtime/entries/vercel.ts +++ b/packages/nitro/src/runtime/entries/vercel.ts @@ -1,4 +1,4 @@ -import '~polyfill' +import '#polyfill' import { handle } from '../server' export default handle diff --git a/packages/nitro/src/runtime/server/index.ts b/packages/nitro/src/runtime/server/index.ts index a8e8183f49..19e88a5f10 100644 --- a/packages/nitro/src/runtime/server/index.ts +++ b/packages/nitro/src/runtime/server/index.ts @@ -6,7 +6,7 @@ import { createCall, createFetch as createLocalFetch } from 'unenv/runtime/fetch import { timingMiddleware } from './timing' import { handleError } from './error' // @ts-ignore -import serverMiddleware from '~serverMiddleware' +import serverMiddleware from '#server-middleware' const app = createApp({ debug: destr(process.env.DEBUG), diff --git a/packages/nitro/src/runtime/server/static.ts b/packages/nitro/src/runtime/server/static.ts index c99886610a..138164015c 100644 --- a/packages/nitro/src/runtime/server/static.ts +++ b/packages/nitro/src/runtime/server/static.ts @@ -1,7 +1,7 @@ import { createError } from 'h3' import { withoutTrailingSlash, withLeadingSlash, parseURL } from 'ufo' // @ts-ignore -import { getAsset, readAsset } from '~static' +import { getAsset, readAsset } from '#static' const METHODS = ['HEAD', 'GET'] const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/