astro 1.1.6 → 1.2.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/@types/astro.d.ts +4 -2
- package/dist/cli/index.js +56 -23
- package/dist/core/add/index.js +72 -68
- package/dist/core/build/generate.js +3 -1
- package/dist/core/build/vite-plugin-analyzer.js +7 -1
- package/dist/{vite-plugin-astro → core/compile}/compile.d.ts +3 -8
- package/dist/{vite-plugin-astro → core/compile}/compile.js +23 -56
- package/dist/core/compile/index.d.ts +3 -0
- package/dist/core/compile/index.js +7 -0
- package/dist/core/compile/style.d.ts +5 -0
- package/dist/core/compile/style.js +31 -0
- package/dist/core/compile/types.d.ts +7 -0
- package/dist/core/compile/types.js +0 -0
- package/dist/core/config.d.ts +6 -2
- package/dist/core/config.js +58 -37
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/index.d.ts +1 -0
- package/dist/core/dev/index.js +4 -2
- package/dist/core/endpoint/dev/index.d.ts +2 -0
- package/dist/core/endpoint/index.d.ts +2 -0
- package/dist/core/endpoint/index.js +2 -1
- package/dist/core/messages.d.ts +2 -1
- package/dist/core/messages.js +5 -4
- package/dist/core/util.d.ts +13 -0
- package/dist/core/util.js +10 -2
- package/dist/jsx/babel.js +2 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/hydration.js +1 -1
- package/dist/runtime/server/render/component.js +2 -1
- package/dist/runtime/server/render/page.js +1 -1
- package/dist/runtime/server/serialize.d.ts +2 -1
- package/dist/runtime/server/serialize.js +37 -12
- package/dist/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/vite-plugin-astro/hmr.js +3 -1
- package/dist/vite-plugin-astro/index.js +18 -26
- package/dist/vite-plugin-astro-server/index.js +1 -0
- package/dist/vite-plugin-markdown-legacy/index.js +16 -10
- package/dist/vite-style-transform/index.d.ts +2 -0
- package/dist/vite-style-transform/index.js +5 -0
- package/dist/vite-style-transform/style-transform.d.ts +10 -0
- package/dist/vite-style-transform/style-transform.js +36 -0
- package/dist/{vite-plugin-astro/styles.d.ts → vite-style-transform/transform-with-vite.d.ts} +0 -0
- package/dist/{vite-plugin-astro/styles.js → vite-style-transform/transform-with-vite.js} +0 -0
- package/package.json +8 -7
|
@@ -5,12 +5,13 @@ import fs from "fs";
|
|
|
5
5
|
import matter from "gray-matter";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import { pagesVirtualModuleId } from "../core/app/index.js";
|
|
8
|
+
import { cachedCompilation } from "../core/compile/index.js";
|
|
8
9
|
import { collectErrorMetadata } from "../core/errors.js";
|
|
9
|
-
import { cachedCompilation } from "../vite-plugin-astro/compile.js";
|
|
10
|
-
import {
|
|
11
|
-
createTransformStyleWithViteFn
|
|
12
|
-
} from "../vite-plugin-astro/styles.js";
|
|
13
10
|
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
11
|
+
import {
|
|
12
|
+
createTransformStyles,
|
|
13
|
+
createViteStyleTransformer
|
|
14
|
+
} from "../vite-style-transform/index.js";
|
|
14
15
|
const MARKDOWN_IMPORT_FLAG = "?mdImport";
|
|
15
16
|
const MARKDOWN_CONTENT_FLAG = "?content";
|
|
16
17
|
function safeMatter(source, id) {
|
|
@@ -43,13 +44,16 @@ function markdown({ config, logging }) {
|
|
|
43
44
|
}
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
|
-
let
|
|
47
|
+
let styleTransformer;
|
|
47
48
|
let viteDevServer;
|
|
48
49
|
return {
|
|
49
50
|
name: "astro:markdown",
|
|
50
51
|
enforce: "pre",
|
|
51
52
|
configResolved(_resolvedConfig) {
|
|
52
|
-
|
|
53
|
+
styleTransformer = createViteStyleTransformer(_resolvedConfig);
|
|
54
|
+
},
|
|
55
|
+
configureServer(server) {
|
|
56
|
+
styleTransformer.viteDevServer = server;
|
|
53
57
|
},
|
|
54
58
|
async resolveId(id, importer, options) {
|
|
55
59
|
if (id.endsWith(`.md${MARKDOWN_CONTENT_FLAG}`)) {
|
|
@@ -161,10 +165,12 @@ ${astroResult}
|
|
|
161
165
|
filename,
|
|
162
166
|
moduleId: id,
|
|
163
167
|
source: astroResult,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
transformStyle: createTransformStyles(
|
|
169
|
+
styleTransformer,
|
|
170
|
+
filename,
|
|
171
|
+
Boolean(opts == null ? void 0 : opts.ssr),
|
|
172
|
+
this
|
|
173
|
+
)
|
|
168
174
|
};
|
|
169
175
|
let transformResult = await cachedCompilation(compileProps);
|
|
170
176
|
let { code: tsResult } = transformResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PluginContext } from 'rollup';
|
|
2
|
+
import type { TransformStyle } from '../core/compile/index';
|
|
3
|
+
import { TransformStyleWithVite } from './transform-with-vite.js';
|
|
4
|
+
import type * as vite from 'vite';
|
|
5
|
+
export declare type ViteStyleTransformer = {
|
|
6
|
+
viteDevServer?: vite.ViteDevServer;
|
|
7
|
+
transformStyleWithVite: TransformStyleWithVite;
|
|
8
|
+
};
|
|
9
|
+
export declare function createViteStyleTransformer(viteConfig: vite.ResolvedConfig): ViteStyleTransformer;
|
|
10
|
+
export declare function createTransformStyles(viteStyleTransformer: ViteStyleTransformer, filename: string, ssr: boolean, pluginContext: PluginContext): TransformStyle;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fileURLToPath } from "url";
|
|
2
|
+
import { createTransformStyleWithViteFn } from "./transform-with-vite.js";
|
|
3
|
+
function createViteStyleTransformer(viteConfig) {
|
|
4
|
+
return {
|
|
5
|
+
transformStyleWithVite: createTransformStyleWithViteFn(viteConfig)
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function getNormalizedIDForPostCSS(filename) {
|
|
9
|
+
try {
|
|
10
|
+
const filenameURL = new URL(`file://${filename}`);
|
|
11
|
+
return fileURLToPath(filenameURL);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
return filename;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createTransformStyles(viteStyleTransformer, filename, ssr, pluginContext) {
|
|
17
|
+
if (!pluginContext.addWatchFile) {
|
|
18
|
+
pluginContext.addWatchFile = () => {
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const normalizedID = getNormalizedIDForPostCSS(filename);
|
|
22
|
+
return async function(styleSource, lang) {
|
|
23
|
+
const result = await viteStyleTransformer.transformStyleWithVite.call(pluginContext, {
|
|
24
|
+
id: normalizedID,
|
|
25
|
+
source: styleSource,
|
|
26
|
+
lang,
|
|
27
|
+
ssr,
|
|
28
|
+
viteDevServer: viteStyleTransformer.viteDevServer
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createTransformStyles,
|
|
35
|
+
createViteStyleTransformer
|
|
36
|
+
};
|
package/dist/{vite-plugin-astro/styles.d.ts → vite-style-transform/transform-with-vite.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"vendor"
|
|
83
83
|
],
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@astrojs/compiler": "^0.
|
|
85
|
+
"@astrojs/compiler": "^0.24.0",
|
|
86
86
|
"@astrojs/language-server": "^0.23.0",
|
|
87
87
|
"@astrojs/markdown-remark": "^1.1.1",
|
|
88
88
|
"@astrojs/telemetry": "^1.0.0",
|
|
@@ -93,8 +93,11 @@
|
|
|
93
93
|
"@babel/plugin-transform-react-jsx": "^7.17.12",
|
|
94
94
|
"@babel/traverse": "^7.18.2",
|
|
95
95
|
"@babel/types": "^7.18.4",
|
|
96
|
-
"@proload/core": "^0.3.
|
|
96
|
+
"@proload/core": "^0.3.3",
|
|
97
97
|
"@proload/plugin-tsm": "^0.2.1",
|
|
98
|
+
"@types/babel__core": "^7.1.19",
|
|
99
|
+
"@types/html-escaper": "^3.0.0",
|
|
100
|
+
"@types/yargs-parser": "^21.0.0",
|
|
98
101
|
"boxen": "^6.2.1",
|
|
99
102
|
"ci-info": "^3.3.1",
|
|
100
103
|
"common-ancestor-path": "^1.0.1",
|
|
@@ -139,7 +142,6 @@
|
|
|
139
142
|
},
|
|
140
143
|
"devDependencies": {
|
|
141
144
|
"@playwright/test": "^1.22.2",
|
|
142
|
-
"@types/babel__core": "^7.1.19",
|
|
143
145
|
"@types/babel__generator": "^7.6.4",
|
|
144
146
|
"@types/babel__traverse": "^7.17.1",
|
|
145
147
|
"@types/chai": "^4.3.1",
|
|
@@ -148,7 +150,6 @@
|
|
|
148
150
|
"@types/debug": "^4.1.7",
|
|
149
151
|
"@types/diff": "^5.0.2",
|
|
150
152
|
"@types/estree": "^0.0.51",
|
|
151
|
-
"@types/html-escaper": "^3.0.0",
|
|
152
153
|
"@types/mime": "^2.0.3",
|
|
153
154
|
"@types/mocha": "^9.1.1",
|
|
154
155
|
"@types/parse5": "^6.0.3",
|
|
@@ -158,7 +159,6 @@
|
|
|
158
159
|
"@types/rimraf": "^3.0.2",
|
|
159
160
|
"@types/send": "^0.17.1",
|
|
160
161
|
"@types/unist": "^2.0.6",
|
|
161
|
-
"@types/yargs-parser": "^21.0.0",
|
|
162
162
|
"ast-types": "^0.14.2",
|
|
163
163
|
"astro-scripts": "0.0.7",
|
|
164
164
|
"chai": "^4.3.6",
|
|
@@ -178,7 +178,8 @@
|
|
|
178
178
|
"dev": "astro-scripts dev --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.ts\"",
|
|
179
179
|
"postbuild": "astro-scripts copy \"src/**/*.astro\"",
|
|
180
180
|
"benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
|
|
181
|
-
"test": "mocha --exit --timeout
|
|
181
|
+
"test:unit": "mocha --exit --timeout 2000 ./test/units/**/*.test.js",
|
|
182
|
+
"test": "pnpm run test:unit && mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
|
|
182
183
|
"test:match": "mocha --timeout 20000 -g",
|
|
183
184
|
"test:e2e": "playwright test",
|
|
184
185
|
"test:e2e:match": "playwright test -g"
|