astro 6.2.1 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/utils/assets.d.ts +4 -5
- package/dist/assets/utils/node.d.ts +2 -2
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/runtime-assets.d.ts +2 -2
- package/dist/content/utils.d.ts +2 -3
- package/dist/core/build/add-rolldown-input.d.ts +2 -0
- package/dist/core/build/{add-rollup-input.js → add-rolldown-input.js} +3 -3
- package/dist/core/build/graph.d.ts +8 -8
- package/dist/core/build/plugins/plugin-analyzer.js +1 -1
- package/dist/core/build/plugins/plugin-component-entry.d.ts +1 -1
- package/dist/core/build/plugins/plugin-component-entry.js +3 -3
- package/dist/core/build/plugins/plugin-internals.js +1 -1
- package/dist/core/build/plugins/plugin-prerender.js +1 -1
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/static-build.js +31 -31
- package/dist/core/build/util.d.ts +2 -2
- package/dist/core/build/util.js +2 -2
- package/dist/core/compile/compile.d.ts +1 -1
- package/dist/core/compile/compile.js +20 -16
- package/dist/core/config/schemas/base.d.ts +4 -6
- package/dist/core/config/schemas/base.js +7 -9
- package/dist/core/config/schemas/relative.d.ts +7 -7
- package/dist/core/config/schemas/relative.js +3 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/utils.js +1 -1
- package/dist/core/errors/zod-error-map.js +0 -27
- package/dist/core/head-propagation/hint.d.ts +4 -0
- package/dist/core/head-propagation/hint.js +7 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/vite-plugin.js +2 -2
- package/dist/toolbar/vite-plugin-dev-toolbar.js +1 -23
- package/dist/types/public/config.d.ts +0 -1
- package/dist/types/public/content.d.ts +3 -3
- package/dist/types/public/integrations.d.ts +2 -2
- package/dist/vite-plugin-adapter-config/index.js +1 -1
- package/dist/vite-plugin-astro/compile.d.ts +3 -5
- package/dist/vite-plugin-astro/compile.js +4 -60
- package/dist/vite-plugin-astro/index.js +15 -28
- package/dist/vite-plugin-astro/types.d.ts +2 -1
- package/dist/vite-plugin-head/index.js +9 -3
- package/dist/vite-plugin-pages/util.d.ts +1 -1
- package/package.json +3 -5
- package/templates/content/module.mjs +1 -1
- package/dist/core/build/add-rollup-input.d.ts +0 -2
- package/dist/core/compile/compile-rs.d.ts +0 -25
- package/dist/core/compile/compile-rs.js +0 -111
- package/dist/core/head-propagation/comment.d.ts +0 -7
- package/dist/core/head-propagation/comment.js +0 -7
- package/dist/vite-plugin-astro/compile-rs.d.ts +0 -12
- package/dist/vite-plugin-astro/compile-rs.js +0 -39
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { AggregateError, CompilerError } from "../errors/errors.js";
|
|
3
|
-
import { AstroErrorData } from "../errors/index.js";
|
|
4
|
-
import { normalizePath, resolvePath } from "../viteUtils.js";
|
|
5
|
-
import { createStylePreprocessor } from "./style.js";
|
|
6
|
-
async function compile({
|
|
7
|
-
astroConfig,
|
|
8
|
-
viteConfig,
|
|
9
|
-
toolbarEnabled,
|
|
10
|
-
filename,
|
|
11
|
-
source
|
|
12
|
-
}) {
|
|
13
|
-
let preprocessStyles;
|
|
14
|
-
let transform;
|
|
15
|
-
try {
|
|
16
|
-
({ preprocessStyles, transform } = await import("@astrojs/compiler-rs"));
|
|
17
|
-
} catch (err) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
`Failed to load @astrojs/compiler-rs. Make sure it is installed and up to date. Original error: ${err}`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
const cssPartialCompileResults = [];
|
|
23
|
-
const cssTransformErrors = [];
|
|
24
|
-
let transformResult;
|
|
25
|
-
try {
|
|
26
|
-
const preprocessedStyles = await preprocessStyles(
|
|
27
|
-
source,
|
|
28
|
-
createStylePreprocessor({
|
|
29
|
-
filename,
|
|
30
|
-
viteConfig,
|
|
31
|
-
astroConfig,
|
|
32
|
-
cssPartialCompileResults,
|
|
33
|
-
cssTransformErrors
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
transformResult = transform(source, {
|
|
37
|
-
compact: astroConfig.compressHTML,
|
|
38
|
-
filename,
|
|
39
|
-
normalizedFilename: normalizeFilename(filename, astroConfig.root),
|
|
40
|
-
sourcemap: "both",
|
|
41
|
-
internalURL: "astro/compiler-runtime",
|
|
42
|
-
// TODO: remove in Astro v7
|
|
43
|
-
astroGlobalArgs: JSON.stringify(astroConfig.site),
|
|
44
|
-
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
|
45
|
-
resultScopedSlot: true,
|
|
46
|
-
transitionsAnimationURL: "astro/components/viewtransitions.css",
|
|
47
|
-
annotateSourceFile: viteConfig.command === "serve" && astroConfig.devToolbar && astroConfig.devToolbar.enabled && toolbarEnabled,
|
|
48
|
-
preprocessedStyles,
|
|
49
|
-
resolvePath(specifier) {
|
|
50
|
-
return resolvePath(specifier, filename);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
} catch (err) {
|
|
54
|
-
throw new CompilerError({
|
|
55
|
-
...AstroErrorData.UnknownCompilerError,
|
|
56
|
-
message: err.message ?? "Unknown compiler error",
|
|
57
|
-
stack: err.stack,
|
|
58
|
-
location: {
|
|
59
|
-
file: filename
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
handleCompileResultErrors(filename, transformResult, cssTransformErrors);
|
|
64
|
-
return {
|
|
65
|
-
...transformResult,
|
|
66
|
-
css: transformResult.css.map((code, i) => ({
|
|
67
|
-
...cssPartialCompileResults[i],
|
|
68
|
-
code
|
|
69
|
-
}))
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function handleCompileResultErrors(filename, result, cssTransformErrors) {
|
|
73
|
-
const compilerError = result.diagnostics.find((diag) => diag.severity === "error");
|
|
74
|
-
if (compilerError) {
|
|
75
|
-
throw new CompilerError({
|
|
76
|
-
name: "CompilerError",
|
|
77
|
-
message: compilerError.text,
|
|
78
|
-
location: {
|
|
79
|
-
line: compilerError.labels[0].line,
|
|
80
|
-
column: compilerError.labels[0].column,
|
|
81
|
-
file: filename
|
|
82
|
-
},
|
|
83
|
-
hint: compilerError.hint
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
switch (cssTransformErrors.length) {
|
|
87
|
-
case 0:
|
|
88
|
-
break;
|
|
89
|
-
case 1: {
|
|
90
|
-
throw cssTransformErrors[0];
|
|
91
|
-
}
|
|
92
|
-
default: {
|
|
93
|
-
throw new AggregateError({
|
|
94
|
-
...cssTransformErrors[0],
|
|
95
|
-
errors: cssTransformErrors
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function normalizeFilename(filename, root) {
|
|
101
|
-
const normalizedFilename = normalizePath(filename);
|
|
102
|
-
const normalizedRoot = normalizePath(fileURLToPath(root));
|
|
103
|
-
if (normalizedFilename.startsWith(normalizedRoot)) {
|
|
104
|
-
return normalizedFilename.slice(normalizedRoot.length - 1);
|
|
105
|
-
} else {
|
|
106
|
-
return normalizedFilename;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export {
|
|
110
|
-
compile
|
|
111
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SourceMapInput } from 'rollup';
|
|
2
|
-
import { type CompileProps, type CompileResult } from '../core/compile/compile-rs.js';
|
|
3
|
-
import type { CompileMetadata } from './types.js';
|
|
4
|
-
interface CompileAstroOption {
|
|
5
|
-
compileProps: CompileProps;
|
|
6
|
-
astroFileToCompileMetadata: Map<string, CompileMetadata>;
|
|
7
|
-
}
|
|
8
|
-
export interface CompileAstroResult extends Omit<CompileResult, 'map'> {
|
|
9
|
-
map: SourceMapInput;
|
|
10
|
-
}
|
|
11
|
-
export declare function compileAstro({ compileProps, astroFileToCompileMetadata, }: CompileAstroOption): Promise<CompileAstroResult>;
|
|
12
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { compile } from "../core/compile/compile-rs.js";
|
|
2
|
-
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
3
|
-
async function compileAstro({
|
|
4
|
-
compileProps,
|
|
5
|
-
astroFileToCompileMetadata
|
|
6
|
-
}) {
|
|
7
|
-
const transformResult = await compile(compileProps);
|
|
8
|
-
const { fileId: file, fileUrl: url } = getFileInfo(
|
|
9
|
-
compileProps.filename,
|
|
10
|
-
compileProps.astroConfig
|
|
11
|
-
);
|
|
12
|
-
let SUFFIX = "";
|
|
13
|
-
SUFFIX += `
|
|
14
|
-
const $$file = ${JSON.stringify(file)};
|
|
15
|
-
const $$url = ${JSON.stringify(
|
|
16
|
-
url
|
|
17
|
-
)};export { $$file as file, $$url as url };
|
|
18
|
-
`;
|
|
19
|
-
if (!compileProps.viteConfig.isProduction) {
|
|
20
|
-
let i = 0;
|
|
21
|
-
while (i < transformResult.scripts.length) {
|
|
22
|
-
SUFFIX += `import "${compileProps.filename}?astro&type=script&index=${i}&lang.ts";`;
|
|
23
|
-
i++;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
astroFileToCompileMetadata.set(compileProps.filename, {
|
|
27
|
-
originalCode: compileProps.source,
|
|
28
|
-
css: transformResult.css,
|
|
29
|
-
scripts: transformResult.scripts
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
...transformResult,
|
|
33
|
-
code: transformResult.code + SUFFIX,
|
|
34
|
-
map: transformResult.map || null
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
compileAstro
|
|
39
|
-
};
|