compile.test.js — astro Source File
Architecture documentation for compile.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c5028325_572c_6687_ffcf_e948c808d95d["compile.test.js"] 12269b3f_02d1_3f9c_a4eb_d0e1b999e987["../../../dist/vite-plugin-astro/compile.js"] c5028325_572c_6687_ffcf_e948c808d95d --> 12269b3f_02d1_3f9c_a4eb_d0e1b999e987 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] c5028325_572c_6687_ffcf_e948c808d95d --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] c5028325_572c_6687_ffcf_e948c808d95d --> 6b0635f9_51ea_77aa_767b_7857878e98a6 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] c5028325_572c_6687_ffcf_e948c808d95d --> d9a92db9_c95e_9165_13ac_24b3d859d946 58b96617_ab14_83d2_3aac_1c7f1ca9b66c["es-module-lexer"] c5028325_572c_6687_ffcf_e948c808d95d --> 58b96617_ab14_83d2_3aac_1c7f1ca9b66c 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] c5028325_572c_6687_ffcf_e948c808d95d --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 style c5028325_572c_6687_ffcf_e948c808d95d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { pathToFileURL } from 'node:url';
import { init, parse } from 'es-module-lexer';
import { resolveConfig } from 'vite';
import { compileAstro } from '../../../dist/vite-plugin-astro/compile.js';
/**
* @param {string} source
* @param {string} id
*/
async function compile(source, id, inlineConfig = {}) {
const viteConfig = await resolveConfig({ configFile: false, ...inlineConfig }, 'serve');
return await compileAstro({
compileProps: {
astroConfig: { root: pathToFileURL('/'), base: '/', experimental: {} },
viteConfig,
filename: id,
source,
},
astroFileToCompileMetadata: new Map(),
});
}
describe('astro full compile', () => {
it('should compile a single file', async () => {
const result = await compile(`<h1>Hello World</h1>`, '/src/components/index.astro');
assert.ok(result.code);
});
it('should compile typescript', async () => {
const result = await compile(
`\
---
const name: string = 'world'
---
<h1>Hello {name}</h1>`,
'/src/components/index.astro',
);
assert.ok(result.code);
});
it('should error on invalid js', async () => {
let result;
try {
result = await compile(
`\
---
const name = 'world
---
<h1>Hello {name}</h1>`,
'/src/components/index.astro',
);
} catch (e) {
assert.equal(e.message.includes('Unterminated string literal'), true);
}
assert.equal(result, undefined);
});
it('has file and url exports for markdwon compat', async () => {
const result = await compile(`<h1>Hello World</h1>`, '/src/components/index.astro');
await init;
const [, exports] = parse(result.code);
const names = exports.map((e) => e.n);
assert.equal(names.includes('default'), true);
assert.equal(names.includes('file'), true);
assert.equal(names.includes('url'), true);
});
describe('when the code contains syntax that is transformed by esbuild', () => {
let code = `\
---
using x = {}
---`;
it('should not transform the syntax by default', async () => {
const result = await compile(code, '/src/components/index.astro');
assert.equal(result.code.includes('using x = {}'), true);
});
it('should transform the syntax by esbuild.target', async () => {
const result = await compile(code, '/src/components/index.astro', {
esbuild: { target: 'es2018' },
});
assert.equal(result.code.includes('using x = {}'), false);
});
});
});
Domain
Subdomains
Functions
Dependencies
- ../../../dist/vite-plugin-astro/compile.js
- es-module-lexer
- node:test
- node:url
- strict
- vite
Source
Frequently Asked Questions
What does compile.test.js do?
compile.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in compile.test.js?
compile.test.js defines 1 function(s): compile.
What does compile.test.js depend on?
compile.test.js imports 6 module(s): ../../../dist/vite-plugin-astro/compile.js, es-module-lexer, node:test, node:url, strict, vite.
Where is compile.test.js in the architecture?
compile.test.js is located at packages/astro/test/units/vite-plugin-astro/compile.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/units/vite-plugin-astro).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free