From 73eadfe79a95079b3d25f0eb1da0aae999f0e3ee Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 18 Jan 2022 15:56:47 -0600 Subject: [PATCH] fix: build issues --- packages/astro/package.json | 4 +++- packages/astro/src/core/build/scan-based-build.ts | 2 +- packages/astro/src/runtime/server/hydration.ts | 4 ++-- .../astro/src/vite-plugin-build-html/add-rollup-input.ts | 2 +- packages/astro/src/vite-plugin-build-html/index.ts | 4 +++- packages/astro/src/vite-plugin-config-alias/index.ts | 6 ++++-- packages/astro/src/vite-plugin-jsx/index.ts | 4 ++-- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/astro/package.json b/packages/astro/package.json index c83f35568..6fb307faf 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -94,7 +94,7 @@ "prismjs": "^1.25.0", "rehype-slug": "^5.0.0", "resolve": "^1.20.0", - "rollup": "^2.60.0", + "rollup": "^2.59.0", "sass": "^1.43.4", "semver": "^7.3.5", "send": "^0.17.1", @@ -120,11 +120,13 @@ "@types/connect": "^3.4.35", "@types/mime": "^2.0.3", "@types/mocha": "^9.0.0", + "@types/node": "14", "@types/node-fetch": "^3.0.0", "@types/resolve": "^1.20.1", "@types/rimraf": "^3.0.2", "@types/send": "^0.17.1", "@types/yargs-parser": "^20.2.1", + "astro-scripts": "0.0.1", "chai": "^4.3.4", "cheerio": "^1.0.0-rc.10", "mocha": "^9.1.3" diff --git a/packages/astro/src/core/build/scan-based-build.ts b/packages/astro/src/core/build/scan-based-build.ts index 3a295c0db..8561ea46f 100644 --- a/packages/astro/src/core/build/scan-based-build.ts +++ b/packages/astro/src/core/build/scan-based-build.ts @@ -21,7 +21,7 @@ export interface ScanBasedBuildOptions { viteServer: ViteDevServer; } -export async function build(opts: ScanBasedBuildOptions) { +export async function build(opts: ScanBasedBuildOptions): ReturnType { const { allPages, astroConfig, logging, origin, pageNames, routeCache, viteConfig, viteServer } = opts; // Internal maps used to coordinate the HTML and CSS plugins. diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index f056166d1..07d46eebf 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -1,6 +1,6 @@ import type { AstroComponentMetadata } from '../../@types/astro'; -import type { SSRElement } from '../../@types/astro'; -import { serializeListValue } from './util.js'; +import type { SSRElement, SSRResult } from '../../@types/astro'; +import { serializeListValue, hydrationSpecifier } from './util.js'; import serialize from 'serialize-javascript'; // Serializes props passed into a component so that they can be reused during hydration. diff --git a/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts b/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts index 79feb3a7d..4043d3ecd 100644 --- a/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts +++ b/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts @@ -1,4 +1,4 @@ -import { InputOptions } from 'rollup'; +import type { InputOptions } from 'rollup'; function fromEntries(entries: [string, V][]) { const obj: Record = {}; diff --git a/packages/astro/src/vite-plugin-build-html/index.ts b/packages/astro/src/vite-plugin-build-html/index.ts index 22bad8073..da3f28873 100644 --- a/packages/astro/src/vite-plugin-build-html/index.ts +++ b/packages/astro/src/vite-plugin-build-html/index.ts @@ -61,7 +61,7 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin { const cssChunkMap = new Map(); const pageStyleImportOrder: string[] = []; - return { + const plugin: VitePlugin = { name: PLUGIN_NAME, enforce: 'pre', @@ -496,4 +496,6 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin { } }, }; + + return plugin; } diff --git a/packages/astro/src/vite-plugin-config-alias/index.ts b/packages/astro/src/vite-plugin-config-alias/index.ts index 6d2d0a008..1b32841ca 100644 --- a/packages/astro/src/vite-plugin-config-alias/index.ts +++ b/packages/astro/src/vite-plugin-config-alias/index.ts @@ -81,9 +81,10 @@ export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL; name: '@astrojs/vite-plugin-config-alias', enforce: 'pre', async resolveId(sourceId: string, importer, options) { + let resolvedId; try { /** Resolved ID conditionally handled by any other resolver. (this gives priority to all other resolvers) */ - const resolvedId = await this.resolve(sourceId, importer, { skipSelf: true, ...options }); + resolvedId = await this.resolve(sourceId, importer, { skipSelf: true, ...options }); } catch (e) {} // if any other resolver handles the file, return that resolution @@ -95,9 +96,10 @@ export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL; /** Processed Source ID with our alias applied. */ const aliasedSourceId = sourceId.replace(alias.find, alias.replacement); + let resolvedAliasedId; try { /** Resolved ID conditionally handled by any other resolver. (this also gives priority to all other resolvers) */ - const resolvedAliasedId = await this.resolve(aliasedSourceId, importer, { skipSelf: true, ...options }); + resolvedAliasedId = await this.resolve(aliasedSourceId, importer, { skipSelf: true, ...options }); } catch (e) {} // if the existing resolvers find the file, return that resolution diff --git a/packages/astro/src/vite-plugin-jsx/index.ts b/packages/astro/src/vite-plugin-jsx/index.ts index 8434aebb9..2acbad199 100644 --- a/packages/astro/src/vite-plugin-jsx/index.ts +++ b/packages/astro/src/vite-plugin-jsx/index.ts @@ -88,8 +88,8 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin configResolved(resolvedConfig) { viteConfig = resolvedConfig; }, - async transform(code, id, ssrOrOptions) { - const ssr = isSSR(ssrOrOptions); + async transform(code, id, options) { + const ssr = Boolean(options?.ssr); if (!JSX_EXTENSIONS.has(path.extname(id))) { return null; }