astro 1.1.3 → 1.1.6
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/core/build/internal.js +7 -3
- package/dist/core/build/static-build.js +2 -2
- package/dist/core/build/vite-plugin-analyzer.js +2 -3
- package/dist/core/build/vite-plugin-css.js +1 -0
- package/dist/core/create-vite.js +78 -26
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/path.d.ts +1 -0
- package/dist/core/path.js +5 -0
- package/dist/core/render/dev/css.js +3 -3
- package/dist/core/util.js +1 -1
- package/dist/jsx/babel.js +3 -8
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/hydration.js +2 -2
- package/dist/vite-plugin-jsx/index.js +13 -3
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prependForwardSlash } from "../path.js";
|
|
1
|
+
import { prependForwardSlash, removeFileExtension } from "../path.js";
|
|
2
2
|
import { viteID } from "../util.js";
|
|
3
3
|
function createBuildInternals() {
|
|
4
4
|
const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
|
|
@@ -45,8 +45,12 @@ function* getPageDatasByChunk(internals, chunk) {
|
|
|
45
45
|
function* getPageDatasByClientOnlyID(internals, viteid) {
|
|
46
46
|
const pagesByClientOnly = internals.pagesByClientOnly;
|
|
47
47
|
if (pagesByClientOnly.size) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let pathname = `/@fs${prependForwardSlash(viteid)}`;
|
|
49
|
+
let pageBuildDatas = pagesByClientOnly.get(viteid);
|
|
50
|
+
if (!pageBuildDatas) {
|
|
51
|
+
pathname = `/@fs${prependForwardSlash(removeFileExtension(viteid))}`;
|
|
52
|
+
pageBuildDatas = pagesByClientOnly.get(pathname);
|
|
53
|
+
}
|
|
50
54
|
if (pageBuildDatas) {
|
|
51
55
|
for (const pageData of pageBuildDatas) {
|
|
52
56
|
yield pageData;
|
|
@@ -23,9 +23,9 @@ async function staticBuild(opts) {
|
|
|
23
23
|
if (isModeServerWithNoAdapter(opts.astroConfig)) {
|
|
24
24
|
throw new Error(`Cannot use \`output: 'server'\` without an adapter.
|
|
25
25
|
Install and configure the appropriate server adapter for your final deployment.
|
|
26
|
-
|
|
26
|
+
Learn more: https://docs.astro.build/en/guides/server-side-rendering/
|
|
27
27
|
|
|
28
|
-
// astro.config.js
|
|
28
|
+
// Example: astro.config.js
|
|
29
29
|
import netlify from '@astrojs/netlify';
|
|
30
30
|
export default {
|
|
31
31
|
output: 'server',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { prependForwardSlash } from "../../core/path.js";
|
|
2
|
-
import { resolveClientDevPath } from "../../core/render/dev/resolve.js";
|
|
3
2
|
import { getTopLevelPages } from "./graph.js";
|
|
4
3
|
import { getPageDataByViteID, trackClientOnlyPageDatas } from "./internal.js";
|
|
5
4
|
function vitePluginAnalyzer(internals) {
|
|
@@ -66,14 +65,14 @@ function vitePluginAnalyzer(internals) {
|
|
|
66
65
|
continue;
|
|
67
66
|
const astro = info.meta.astro;
|
|
68
67
|
for (const c of astro.hydratedComponents) {
|
|
69
|
-
const rid = c.resolvedPath ?
|
|
68
|
+
const rid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
|
|
70
69
|
internals.discoveredHydratedComponents.add(rid);
|
|
71
70
|
}
|
|
72
71
|
hoistScanner.scan.call(this, astro.scripts, id);
|
|
73
72
|
if (astro.clientOnlyComponents.length) {
|
|
74
73
|
const clientOnlys = [];
|
|
75
74
|
for (const c of astro.clientOnlyComponents) {
|
|
76
|
-
const cid = c.resolvedPath ?
|
|
75
|
+
const cid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
|
|
77
76
|
internals.discoveredClientOnlyComponents.add(cid);
|
|
78
77
|
clientOnlys.push(cid);
|
|
79
78
|
}
|
|
@@ -92,6 +92,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
92
92
|
if (Object.keys(c.modules).every((id) => internals.cssChunkModuleIds.has(id))) {
|
|
93
93
|
for (const importedCssImport of meta.importedCss) {
|
|
94
94
|
delete bundle[importedCssImport];
|
|
95
|
+
meta.importedCss.delete(importedCssImport);
|
|
95
96
|
}
|
|
96
97
|
return;
|
|
97
98
|
}
|
package/dist/core/create-vite.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import path from "path";
|
|
2
4
|
import { fileURLToPath } from "url";
|
|
3
5
|
import * as vite from "vite";
|
|
4
6
|
import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.js";
|
|
@@ -116,32 +118,82 @@ function sortPlugins(pluginOptions) {
|
|
|
116
118
|
pluginOptions.splice(jsxPluginIndex, 0, mdxPlugin);
|
|
117
119
|
}
|
|
118
120
|
async function getAstroPackages({ root }) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
const { astroPackages } = new DependencyWalker(root);
|
|
122
|
+
return astroPackages;
|
|
123
|
+
}
|
|
124
|
+
class DependencyWalker {
|
|
125
|
+
constructor(root) {
|
|
126
|
+
this.astroDeps = /* @__PURE__ */ new Set();
|
|
127
|
+
this.nonAstroDeps = /* @__PURE__ */ new Set();
|
|
128
|
+
const pkgUrl = new URL("./package.json", root);
|
|
129
|
+
this.require = createRequire(pkgUrl);
|
|
130
|
+
const pkgPath = fileURLToPath(pkgUrl);
|
|
131
|
+
if (!fs.existsSync(pkgPath))
|
|
132
|
+
return;
|
|
133
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
134
|
+
const deps = [
|
|
135
|
+
...Object.keys(pkg.dependencies || {}),
|
|
136
|
+
...Object.keys(pkg.devDependencies || {})
|
|
137
|
+
];
|
|
138
|
+
this.scanDependencies(deps);
|
|
139
|
+
}
|
|
140
|
+
get astroPackages() {
|
|
141
|
+
return Array.from(this.astroDeps);
|
|
142
|
+
}
|
|
143
|
+
seen(dep) {
|
|
144
|
+
return this.astroDeps.has(dep) || this.nonAstroDeps.has(dep);
|
|
145
|
+
}
|
|
146
|
+
readPkgJSON(dir) {
|
|
147
|
+
try {
|
|
148
|
+
const filePath = path.join(dir, "package.json");
|
|
149
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
150
|
+
} catch (e) {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
resolvePkgJSON(dep) {
|
|
154
|
+
try {
|
|
155
|
+
const pkgJson = this.require(dep + "/package.json");
|
|
156
|
+
return pkgJson;
|
|
157
|
+
} catch (e) {
|
|
158
|
+
try {
|
|
159
|
+
let dir = path.dirname(this.require.resolve(dep));
|
|
160
|
+
while (dir) {
|
|
161
|
+
const pkgJSON = this.readPkgJSON(dir);
|
|
162
|
+
if (pkgJSON && pkgJSON.name === dep)
|
|
163
|
+
return pkgJSON;
|
|
164
|
+
const parentDir = path.dirname(dir);
|
|
165
|
+
if (parentDir === dir)
|
|
166
|
+
break;
|
|
167
|
+
dir = parentDir;
|
|
168
|
+
}
|
|
169
|
+
} catch (e2) {
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
scanDependencies(deps) {
|
|
174
|
+
const newDeps = [];
|
|
175
|
+
for (const dep of deps) {
|
|
176
|
+
if (isCommonNotAstro(dep)) {
|
|
177
|
+
this.nonAstroDeps.add(dep);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const pkgJson = this.resolvePkgJSON(dep);
|
|
181
|
+
if (!pkgJson) {
|
|
182
|
+
this.nonAstroDeps.add(dep);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const { dependencies = {}, peerDependencies = {}, keywords = [] } = pkgJson;
|
|
186
|
+
if (peerDependencies.astro || dependencies.astro || keywords.includes("astro") || keywords.includes("astro-component") || /^(@[^\/]+\/)?astro\-/.test(dep)) {
|
|
187
|
+
this.astroDeps.add(dep);
|
|
188
|
+
const unknownDependencies = Object.keys(dependencies).filter((d) => !this.seen(d));
|
|
189
|
+
newDeps.push(...unknownDependencies);
|
|
190
|
+
} else {
|
|
191
|
+
this.nonAstroDeps.add(dep);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (newDeps.length)
|
|
195
|
+
this.scanDependencies(newDeps);
|
|
196
|
+
}
|
|
145
197
|
}
|
|
146
198
|
const COMMON_DEPENDENCIES_NOT_ASTRO = [
|
|
147
199
|
"autoprefixer",
|
package/dist/core/dev/index.js
CHANGED
|
@@ -46,7 +46,7 @@ async function dev(config, options) {
|
|
|
46
46
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
|
-
const currentVersion = "1.1.
|
|
49
|
+
const currentVersion = "1.1.6";
|
|
50
50
|
if (currentVersion.includes("-")) {
|
|
51
51
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
52
52
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -46,7 +46,7 @@ function devStart({
|
|
|
46
46
|
https,
|
|
47
47
|
site
|
|
48
48
|
}) {
|
|
49
|
-
const version = "1.1.
|
|
49
|
+
const version = "1.1.6";
|
|
50
50
|
const rootPath = site ? site.pathname : "/";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -225,7 +225,7 @@ function printHelp({
|
|
|
225
225
|
message.push(
|
|
226
226
|
linebreak(),
|
|
227
227
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
228
|
-
`v${"1.1.
|
|
228
|
+
`v${"1.1.6"}`
|
|
229
229
|
)} ${headline}`
|
|
230
230
|
);
|
|
231
231
|
}
|
package/dist/core/path.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export declare function startsWithDotDotSlash(path: string): boolean;
|
|
|
8
8
|
export declare function startsWithDotSlash(path: string): boolean;
|
|
9
9
|
export declare function isRelativePath(path: string): boolean;
|
|
10
10
|
export declare function joinPaths(...paths: (string | undefined)[]): string;
|
|
11
|
+
export declare function removeFileExtension(path: string): string;
|
package/dist/core/path.js
CHANGED
|
@@ -36,11 +36,16 @@ function isString(path) {
|
|
|
36
36
|
function joinPaths(...paths) {
|
|
37
37
|
return paths.filter(isString).map(trimSlashes).join("/");
|
|
38
38
|
}
|
|
39
|
+
function removeFileExtension(path) {
|
|
40
|
+
let idx = path.lastIndexOf(".");
|
|
41
|
+
return idx === -1 ? path : path.slice(0, idx);
|
|
42
|
+
}
|
|
39
43
|
export {
|
|
40
44
|
appendForwardSlash,
|
|
41
45
|
isRelativePath,
|
|
42
46
|
joinPaths,
|
|
43
47
|
prependForwardSlash,
|
|
48
|
+
removeFileExtension,
|
|
44
49
|
removeLeadingForwardSlash,
|
|
45
50
|
removeTrailingForwardSlash,
|
|
46
51
|
startsWithDotDotSlash,
|
|
@@ -3,14 +3,14 @@ import { viteID } from "../../util.js";
|
|
|
3
3
|
import { STYLE_EXTENSIONS } from "../util.js";
|
|
4
4
|
import { crawlGraph } from "./vite.js";
|
|
5
5
|
async function getStylesForURL(filePath, viteServer, mode) {
|
|
6
|
-
var _a;
|
|
7
6
|
const importedCssUrls = /* @__PURE__ */ new Set();
|
|
8
7
|
const importedStylesMap = /* @__PURE__ */ new Map();
|
|
9
8
|
for await (const importedModule of crawlGraph(viteServer, viteID(filePath), true)) {
|
|
10
9
|
const ext = path.extname(importedModule.url).toLowerCase();
|
|
11
10
|
if (STYLE_EXTENSIONS.has(ext)) {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const ssrModule = importedModule.ssrModule ?? await viteServer.ssrLoadModule(importedModule.url);
|
|
12
|
+
if (mode === "development" && typeof (ssrModule == null ? void 0 : ssrModule.default) === "string") {
|
|
13
|
+
importedStylesMap.set(importedModule.url, ssrModule.default);
|
|
14
14
|
} else {
|
|
15
15
|
importedCssUrls.add(importedModule.url);
|
|
16
16
|
}
|
package/dist/core/util.js
CHANGED
|
@@ -5,7 +5,7 @@ import resolve from "resolve";
|
|
|
5
5
|
import slash from "slash";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
7
|
import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
|
|
8
|
-
const ASTRO_VERSION = "1.1.
|
|
8
|
+
const ASTRO_VERSION = "1.1.6";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
package/dist/jsx/babel.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { resolveClientDevPath } from "../core/render/dev/resolve.js";
|
|
3
4
|
import { HydrationDirectiveProps } from "../runtime/server/hydration.js";
|
|
4
5
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
5
6
|
function isComponent(tagName) {
|
|
@@ -194,10 +195,7 @@ function astroJSX() {
|
|
|
194
195
|
let resolvedPath;
|
|
195
196
|
if (meta.path.startsWith(".")) {
|
|
196
197
|
const fileURL = pathToFileURL(state.filename);
|
|
197
|
-
resolvedPath = `/@fs${new URL(meta.path, fileURL).pathname}
|
|
198
|
-
if (resolvedPath.endsWith(".jsx")) {
|
|
199
|
-
resolvedPath = resolvedPath.slice(0, -4);
|
|
200
|
-
}
|
|
198
|
+
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
|
|
201
199
|
} else {
|
|
202
200
|
resolvedPath = meta.path;
|
|
203
201
|
}
|
|
@@ -273,10 +271,7 @@ function astroJSX() {
|
|
|
273
271
|
let resolvedPath;
|
|
274
272
|
if (meta.path.startsWith(".")) {
|
|
275
273
|
const fileURL = pathToFileURL(state.filename);
|
|
276
|
-
resolvedPath = `/@fs${new URL(meta.path, fileURL).pathname}
|
|
277
|
-
if (resolvedPath.endsWith(".jsx")) {
|
|
278
|
-
resolvedPath = resolvedPath.slice(0, -4);
|
|
279
|
-
}
|
|
274
|
+
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
|
|
280
275
|
} else {
|
|
281
276
|
resolvedPath = meta.path;
|
|
282
277
|
}
|
|
@@ -85,10 +85,10 @@ async function generateHydrateScript(scriptOptions, metadata) {
|
|
|
85
85
|
island.props[key] = value;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
island.props["component-url"] = await result.resolve(componentUrl);
|
|
88
|
+
island.props["component-url"] = await result.resolve(decodeURI(componentUrl));
|
|
89
89
|
if (renderer.clientEntrypoint) {
|
|
90
90
|
island.props["component-export"] = componentExport.value;
|
|
91
|
-
island.props["renderer-url"] = await result.resolve(renderer.clientEntrypoint);
|
|
91
|
+
island.props["renderer-url"] = await result.resolve(decodeURI(renderer.clientEntrypoint));
|
|
92
92
|
island.props["props"] = escapeHTML(serializeProps(props));
|
|
93
93
|
}
|
|
94
94
|
island.props["ssr"] = "";
|
|
@@ -112,7 +112,7 @@ function jsx({ config, logging }) {
|
|
|
112
112
|
enforce: "pre",
|
|
113
113
|
async configResolved(resolvedConfig) {
|
|
114
114
|
viteConfig = resolvedConfig;
|
|
115
|
-
const possibleRenderers =
|
|
115
|
+
const possibleRenderers = collectJSXRenderers(config._ctx.renderers);
|
|
116
116
|
for (const [importSource, renderer] of possibleRenderers) {
|
|
117
117
|
jsxRenderers.set(importSource, renderer);
|
|
118
118
|
if (importSource === "astro") {
|
|
@@ -163,8 +163,8 @@ function jsx({ config, logging }) {
|
|
|
163
163
|
if (!importSource && IMPORT_KEYWORD_REGEX.test(code)) {
|
|
164
164
|
importSource = await detectImportSourceFromImports(code, id, jsxRenderers);
|
|
165
165
|
}
|
|
166
|
-
if (!importSource) {
|
|
167
|
-
const [defaultRendererName] = defaultJSXRendererEntry
|
|
166
|
+
if (!importSource && defaultJSXRendererEntry) {
|
|
167
|
+
const [defaultRendererName] = defaultJSXRendererEntry;
|
|
168
168
|
error(
|
|
169
169
|
logging,
|
|
170
170
|
"renderer",
|
|
@@ -173,6 +173,16 @@ Unable to resolve a renderer that handles this file! With more than one renderer
|
|
|
173
173
|
Add ${colors.cyan(
|
|
174
174
|
IMPORT_STATEMENTS[defaultRendererName] || `import '${defaultRendererName}';`
|
|
175
175
|
)} or ${colors.cyan(`/* jsxImportSource: ${defaultRendererName} */`)} to this file.
|
|
176
|
+
`
|
|
177
|
+
);
|
|
178
|
+
return null;
|
|
179
|
+
} else if (!importSource) {
|
|
180
|
+
error(
|
|
181
|
+
logging,
|
|
182
|
+
"renderer",
|
|
183
|
+
`${colors.yellow(id)}
|
|
184
|
+
Unable to find a renderer for JSX. Do you have one configured in your Astro config? See this page to learn how:
|
|
185
|
+
https://docs.astro.build/en/core-concepts/framework-components/#installing-integrations
|
|
176
186
|
`
|
|
177
187
|
);
|
|
178
188
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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",
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"@babel/types": "^7.18.4",
|
|
96
96
|
"@proload/core": "^0.3.2",
|
|
97
97
|
"@proload/plugin-tsm": "^0.2.1",
|
|
98
|
-
"ast-types": "^0.14.2",
|
|
99
98
|
"boxen": "^6.2.1",
|
|
100
99
|
"ci-info": "^3.3.1",
|
|
101
100
|
"common-ancestor-path": "^1.0.1",
|
|
@@ -160,6 +159,7 @@
|
|
|
160
159
|
"@types/send": "^0.17.1",
|
|
161
160
|
"@types/unist": "^2.0.6",
|
|
162
161
|
"@types/yargs-parser": "^21.0.0",
|
|
162
|
+
"ast-types": "^0.14.2",
|
|
163
163
|
"astro-scripts": "0.0.7",
|
|
164
164
|
"chai": "^4.3.6",
|
|
165
165
|
"cheerio": "^1.0.0-rc.11",
|