fix: build issues

This commit is contained in:
Nate Moore 2022-01-18 15:56:47 -06:00
parent 0457e2a8ee
commit 73eadfe79a
7 changed files with 16 additions and 10 deletions

View file

@ -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"

View file

@ -21,7 +21,7 @@ export interface ScanBasedBuildOptions {
viteServer: ViteDevServer;
}
export async function build(opts: ScanBasedBuildOptions) {
export async function build(opts: ScanBasedBuildOptions): ReturnType<typeof vite.build> {
const { allPages, astroConfig, logging, origin, pageNames, routeCache, viteConfig, viteServer } = opts;
// Internal maps used to coordinate the HTML and CSS plugins.

View file

@ -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.

View file

@ -1,4 +1,4 @@
import { InputOptions } from 'rollup';
import type { InputOptions } from 'rollup';
function fromEntries<V>(entries: [string, V][]) {
const obj: Record<string, V> = {};

View file

@ -61,7 +61,7 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
const cssChunkMap = new Map<string, string[]>();
const pageStyleImportOrder: string[] = [];
return {
const plugin: VitePlugin = {
name: PLUGIN_NAME,
enforce: 'pre',
@ -496,4 +496,6 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
}
},
};
return plugin;
}

View file

@ -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

View file

@ -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;
}