summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/giant-impalas-design.md6
-rw-r--r--packages/astro/package.json4
-rw-r--r--packages/astro/src/cli/index.ts13
-rw-r--r--packages/astro/src/core/config.ts14
-rw-r--r--packages/integrations/tailwind/package.json2
-rw-r--r--pnpm-lock.yaml40
6 files changed, 49 insertions, 30 deletions
diff --git a/.changeset/giant-impalas-design.md b/.changeset/giant-impalas-design.md
new file mode 100644
index 000000000..9c46aea48
--- /dev/null
+++ b/.changeset/giant-impalas-design.md
@@ -0,0 +1,6 @@
+---
+'astro': patch
+'@astrojs/tailwind': patch
+---
+
+Support "astro add" before installing project dependencies
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 0305562aa..92f31808c 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -84,8 +84,8 @@
"@babel/generator": "^7.17.9",
"@babel/parser": "^7.17.9",
"@babel/traverse": "^7.17.9",
- "@proload/core": "^0.2.2",
- "@proload/plugin-tsm": "^0.1.1",
+ "@proload/core": "^0.3.2-next.4",
+ "@proload/plugin-tsm": "^0.2.1-next.0",
"ast-types": "^0.14.2",
"boxen": "^6.2.1",
"ci-info": "^3.3.0",
diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts
index 45f50f832..f4a7ed895 100644
--- a/packages/astro/src/cli/index.ts
+++ b/packages/astro/src/cli/index.ts
@@ -104,15 +104,6 @@ export async function cli(args: string[]) {
logging.level = 'silent';
}
- let config: AstroConfig;
- try {
- // Note: ideally, `loadConfig` would return the config AND its filePath
- // For now, `add` has to resolve the config again internally
- config = await loadConfig({ cwd: root, flags, cmd });
- } catch (err) {
- return throwAndExit(err);
- }
-
switch (cmd) {
case 'add': {
try {
@@ -124,6 +115,7 @@ export async function cli(args: string[]) {
}
case 'dev': {
try {
+ const config = await loadConfig({ cwd: root, flags, cmd });
await devServer(config, { logging });
return await new Promise(() => {}); // lives forever
} catch (err) {
@@ -133,6 +125,7 @@ export async function cli(args: string[]) {
case 'build': {
try {
+ const config = await loadConfig({ cwd: root, flags, cmd });
return await build(config, { logging });
} catch (err) {
return throwAndExit(err);
@@ -140,12 +133,14 @@ export async function cli(args: string[]) {
}
case 'check': {
+ const config = await loadConfig({ cwd: root, flags, cmd });
const ret = await check(config);
return process.exit(ret);
}
case 'preview': {
try {
+ const config = await loadConfig({ cwd: root, flags, cmd });
const server = await preview(config, { logging });
return await server.closed(); // keep alive until the server is closed
} catch (err) {
diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts
index de947530d..74942e56f 100644
--- a/packages/astro/src/core/config.ts
+++ b/packages/astro/src/core/config.ts
@@ -10,7 +10,7 @@ import { pathToFileURL, fileURLToPath } from 'url';
import { mergeConfig as mergeViteConfig } from 'vite';
import { BUNDLED_THEMES } from 'shiki';
import { z } from 'zod';
-import load, { ProloadError } from '@proload/core';
+import load, { resolve, ProloadError } from '@proload/core';
import loadTypeScript from '@proload/plugin-tsm';
import postcssrc from 'postcss-load-config';
import { arraify, isObject } from './util.js';
@@ -385,11 +385,15 @@ export async function resolveConfigURL(
userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`;
userConfigPath = fileURLToPath(new URL(userConfigPath, `file://${root}/`));
}
- // Automatically load config file using Proload
+ // Resolve config file path using Proload
// If `userConfigPath` is `undefined`, Proload will search for `astro.config.[cm]?[jt]s`
- const config = await load('astro', { mustExist: false, cwd: root, filePath: userConfigPath });
- if (config) {
- return pathToFileURL(config.filePath);
+ const configPath = await resolve('astro', {
+ mustExist: false,
+ cwd: root,
+ filePath: userConfigPath,
+ });
+ if (configPath) {
+ return pathToFileURL(configPath);
}
}
diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json
index 86a4769a6..55361d10a 100644
--- a/packages/integrations/tailwind/package.json
+++ b/packages/integrations/tailwind/package.json
@@ -27,7 +27,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
- "@proload/core": "^0.2.2",
+ "@proload/core": "^0.3.1",
"autoprefixer": "^10.4.4",
"postcss": "^8.4.12",
"tailwindcss": "^3.0.24"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 835892abd..7920fc6ed 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -457,8 +457,8 @@ importers:
'@babel/parser': ^7.17.9
'@babel/traverse': ^7.17.9
'@babel/types': ^7.17.0
- '@proload/core': ^0.2.2
- '@proload/plugin-tsm': ^0.1.1
+ '@proload/core': ^0.3.2-next.4
+ '@proload/plugin-tsm': ^0.2.1-next.0
'@types/babel__core': ^7.1.19
'@types/babel__generator': ^7.6.4
'@types/babel__traverse': ^7.17.0
@@ -542,8 +542,8 @@ importers:
'@babel/generator': 7.17.9
'@babel/parser': 7.17.9
'@babel/traverse': 7.17.9
- '@proload/core': 0.2.2
- '@proload/plugin-tsm': 0.1.1_@proload+core@0.2.2
+ '@proload/core': 0.3.2-next.4
+ '@proload/plugin-tsm': 0.2.1-next.0_@proload+core@0.3.2-next.4
ast-types: 0.14.2
boxen: 6.2.1
ci-info: 3.3.0
@@ -1412,7 +1412,7 @@ importers:
packages/integrations/tailwind:
specifiers:
- '@proload/core': ^0.2.2
+ '@proload/core': ^0.3.1
'@types/tailwindcss': ^3.0.10
astro: workspace:*
astro-scripts: workspace:*
@@ -1420,7 +1420,7 @@ importers:
postcss: ^8.4.12
tailwindcss: ^3.0.24
dependencies:
- '@proload/core': 0.2.2
+ '@proload/core': 0.3.1
autoprefixer: 10.4.4_postcss@8.4.12
postcss: 8.4.12
tailwindcss: 3.0.24
@@ -3652,19 +3652,27 @@ packages:
/@polka/url/1.0.0-next.21:
resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==}
- /@proload/core/0.2.2:
- resolution: {integrity: sha512-HYQEblYXIpW77kvGyW4penEl9D9e9MouPhTqVaDz9+QVFliYjsq18inTfnfTa81s3oraPVtTk60tqCWOf2fKGQ==}
+ /@proload/core/0.3.1:
+ resolution: {integrity: sha512-u902sdjipQ6WjpV6rxcF0CnQP6Z6Gd54MBPuMbZ5amCcdb/meWY6UtCQSLIJmG+zbXtf8Hwzf6ePBey158QAQQ==}
dependencies:
deepmerge: 4.2.2
escalade: 3.1.1
+ resolve-pkg: 2.0.0
dev: false
- /@proload/plugin-tsm/0.1.1_@proload+core@0.2.2:
- resolution: {integrity: sha512-qfGegg6I3YBCZDjYR9xb41MTc2EfL0sQQmw49Z/yi9OstIpUa/67MBy4AuNhoyG9FuOXia9gPoeBk5pGnBOGtA==}
+ /@proload/core/0.3.2-next.4:
+ resolution: {integrity: sha512-58nw3h4+qBDizhlTbt/Q4iGWiiSWcYqdRgIAy3KMla1nqNFO8stG5vzDjPGMPyX6DsAhEj3PCqb4G0d82b2kqQ==}
+ dependencies:
+ deepmerge: 4.2.2
+ escalade: 3.1.1
+ dev: false
+
+ /@proload/plugin-tsm/0.2.1-next.0_@proload+core@0.3.2-next.4:
+ resolution: {integrity: sha512-76NvJmWD1MBip1oifMLohTJfdi4DQihTUnwWacscsLxUaT/5/FNNolD5CIoH/+qhsU6HyVpz8JfEzVpkMuxKfA==}
peerDependencies:
- '@proload/core': ^0.2.1
+ '@proload/core': ^0.3.2-next.0
dependencies:
- '@proload/core': 0.2.2
+ '@proload/core': 0.3.2-next.4
tsm: 2.2.1
dev: false
@@ -8963,7 +8971,13 @@ packages:
/resolve-from/5.0.0:
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
engines: {node: '>=8'}
- dev: true
+
+ /resolve-pkg/2.0.0:
+ resolution: {integrity: sha512-+1lzwXehGCXSeryaISr6WujZzowloigEofRB+dj75y9RRa/obVcYgbHJd53tdYw8pvZj8GojXaaENws8Ktw/hQ==}
+ engines: {node: '>=8'}
+ dependencies:
+ resolve-from: 5.0.0
+ dev: false
/resolve/1.22.0:
resolution: {integrity: sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==}