summaryrefslogtreecommitdiff
path: root/src/compiler/index.ts
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-03-30 15:06:43 -0400
committerGravatar GitHub <noreply@github.com> 2021-03-30 15:06:43 -0400
commit4a732837cdd1ad5493a25ae58612e9b6a302c651 (patch)
tree724af4f76202d6615a6969cd2d2bd7e3723c3d4f /src/compiler/index.ts
parent7334a550d8e042ae0dc59519149df2b3ad04f058 (diff)
downloadastro-4a732837cdd1ad5493a25ae58612e9b6a302c651.tar.gz
astro-4a732837cdd1ad5493a25ae58612e9b6a302c651.tar.zst
astro-4a732837cdd1ad5493a25ae58612e9b6a302c651.zip
Resolve component URLs during compilation (#40)
Previously dynamic component URLs were being resolved client-side in a weird way that only worked during dev. This change makes them handle during compilation, so it works in both (and improves readability of the dynamic import output).
Diffstat (limited to '')
-rw-r--r--src/compiler/index.ts9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/compiler/index.ts b/src/compiler/index.ts
index 945d9bfc5..8104ef4b4 100644
--- a/src/compiler/index.ts
+++ b/src/compiler/index.ts
@@ -1,4 +1,5 @@
import type { LogOptions } from '../logger.js';
+import type { AstroConfig } from '../@types/astro';
import path from 'path';
import micromark from 'micromark';
@@ -14,15 +15,11 @@ import { optimize } from './optimize/index.js';
import { codegen } from './codegen.js';
interface CompileOptions {
+ astroConfig: AstroConfig;
logging: LogOptions;
resolve: (p: string) => Promise<string>;
}
-const defaultCompileOptions: CompileOptions = {
- logging: defaultLogOptions,
- resolve: (p: string) => Promise.resolve(p),
-};
-
function internalImport(internalPath: string) {
return `/_astro_internal/${internalPath}`;
}
@@ -107,7 +104,7 @@ async function transformFromSource(
export async function compileComponent(
source: string,
- { compileOptions = defaultCompileOptions, filename, projectRoot }: { compileOptions: CompileOptions; filename: string; projectRoot: string }
+ { compileOptions, filename, projectRoot }: { compileOptions: CompileOptions; filename: string; projectRoot: string }
): Promise<CompileResult> {
const sourceJsx = await transformFromSource(source, { compileOptions, filename, projectRoot });
const isPage = path.extname(filename) === '.md' || sourceJsx.items.some((item) => item.name === 'html');