mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fred fixes
This commit is contained in:
parent
ec6dbab103
commit
c3e7b7f37d
7 changed files with 14 additions and 53 deletions
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"ignoreChanges": ["**/test/**", "**/*.md"],
|
||||
"useWorkspaces": true,
|
||||
"version": "4.0.0"
|
||||
"version": "4.0.0",
|
||||
"command": {
|
||||
"run": {
|
||||
"npmClient": "yarn"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
45
packages/astro/src/@types/compiler.d.ts
vendored
45
packages/astro/src/@types/compiler.d.ts
vendored
|
@ -1,45 +0,0 @@
|
|||
declare module '@astrojs/compiler' {
|
||||
export type Platform = 'browser' | 'node' | 'neutral';
|
||||
export type SourceMap = any;
|
||||
|
||||
export interface TransformOptions {}
|
||||
|
||||
export interface TransformResult {
|
||||
code: string;
|
||||
map: SourceMap;
|
||||
warnings: any[];
|
||||
}
|
||||
|
||||
export interface TransformResults {
|
||||
js: TransformResult;
|
||||
css?: TransformResult;
|
||||
}
|
||||
|
||||
// This function transforms a single JavaScript file. It can be used to minify
|
||||
// JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
|
||||
// to older JavaScript. It returns a promise that is either resolved with a
|
||||
// "TransformResult" object or rejected with a "TransformFailure" object.
|
||||
//
|
||||
// Works in node: yes
|
||||
// Works in browser: yes
|
||||
export declare function transform(input: string, options?: TransformOptions): Promise<string>;
|
||||
|
||||
// This configures the browser-based version of astro. It is necessary to
|
||||
// call this first and wait for the returned promise to be resolved before
|
||||
// making other API calls when using astro in the browser.
|
||||
//
|
||||
// Works in node: yes
|
||||
// Works in browser: yes ("options" is required)
|
||||
export declare function initialize(options: InitializeOptions): Promise<void>;
|
||||
|
||||
export interface InitializeOptions {
|
||||
// The URL of the "astro.wasm" file. This must be provided when running
|
||||
// astro in the browser.
|
||||
wasmURL?: string;
|
||||
|
||||
// By default astro runs the WebAssembly-based browser API in a web worker
|
||||
// to avoid blocking the UI thread. This can be disabled by setting "worker"
|
||||
// to false.
|
||||
worker?: boolean;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import 'vite/client';
|
||||
import '@vite/client';
|
||||
|
||||
if (import.meta.hot) {
|
||||
const parser = new DOMParser();
|
||||
|
|
|
@ -49,7 +49,7 @@ export async function renderAstroComponent(component: InstanceType<typeof AstroC
|
|||
}
|
||||
|
||||
export async function renderToString(result: any, componentFactory: AstroComponentFactory, props: any, children: any) {
|
||||
const Component = componentFactory(result, props, children);
|
||||
const Component = await componentFactory(result, props, children);
|
||||
let template = await renderAstroComponent(Component);
|
||||
return template
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { InlineConfig } from 'vite';
|
||||
import type { InlineConfig, Plugin } from 'vite';
|
||||
import type { AstroConfig } from '../../@types/astro';
|
||||
import type { LogOptions } from '../../logger';
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ export default function astro({ devServer }: AstroPluginOptions): Plugin {
|
|||
let source = await fs.promises.readFile(id, 'utf8');
|
||||
|
||||
// 1. Transform from `.astro` to valid `.ts`
|
||||
const tsResult = await transform(source, { sourcefile: id });
|
||||
|
||||
// use `sourcemap: "inline"` so that the sourcemap is included in the "code" result that we pass to esbuild.
|
||||
const tsResult = await transform(source, { sourcefile: id, sourcemap: 'inline' });
|
||||
// 2. Compile `.ts` to `.js`
|
||||
const { code, map } = await esbuild.transform(tsResult, { loader: 'ts', sourcemap: 'inline', sourcefile: id });
|
||||
const { code, map } = await esbuild.transform(tsResult.code, { loader: 'ts', sourcemap: 'inline', sourcefile: id });
|
||||
|
||||
return {
|
||||
code,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"declarationDir": "./dist/types",
|
||||
"module": "ES2020",
|
||||
"outDir": "./dist",
|
||||
"target": "ES2019"
|
||||
"target": "ES2019",
|
||||
"types": ["vite/client"]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue