-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not inject env vars into non-source files (#13001)
- Loading branch information
Showing
10 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes a bug that caused Astro to attempt to inject environment variables into non-source files, causing performance problems and broken builds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
SECRET_PLACE=CLUB_33 | ||
PUBLIC_PLACE=BLUE_BAYOU | ||
KITTY=CHESHIRE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/astro/test/fixtures/astro-envs/src/data/cats.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"tiddles": { | ||
"name": "Tiddles", | ||
"age": 3, | ||
"colour": "black" | ||
}, | ||
"mittens": { | ||
"name": "Mittens", | ||
"age": 5, | ||
"colour": "white" | ||
}, | ||
"fluffy": { | ||
"name": "Fluffy", | ||
"age": 2, | ||
"colour": "grey" | ||
}, | ||
"whiskers": { | ||
"name": "Whiskers", | ||
"age": 4, | ||
"colour": "tabby" | ||
}, | ||
"bobby-env": { | ||
"name": "import.meta.env.KITTY", | ||
"age": 1, | ||
"colour": "calico" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* Just mentioning import.meta.env is enough to trigger this */ | ||
body { | ||
background-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
--- | ||
<h1>import.meta.env.KITTEN</h1> | ||
|
||
```js | ||
console.log(import.meta.env.KITTEN) | ||
``` |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-envs/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
--- | ||
import Client from '../components/Client.vue'; | ||
import css from '../data/hello.css?inline'; | ||
const {env} = await import('../data/cats.json'); | ||
--- | ||
<head /> | ||
<environment-variable>{import.meta.env.PUBLIC_PLACE}</environment-variable> | ||
<environment-variable>{import.meta.env.SECRET_PLACE}</environment-variable> | ||
<environment-variable>{import.meta.env.SITE}</environment-variable> | ||
<environment-variable id="base-url">{import.meta.env.BASE_URL}</environment-variable> | ||
<environment-variable id="env">{env}</environment-variable> | ||
<environment-variable id="css">{css.includes('SECRET_PLACE') ? 'bad' : 'good' }</environment-variable> | ||
<Client client:load /> |
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/astro-envs/src/pages/info.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
Did you know import.meta.env is a magic word? | ||
</body> | ||
|
||
</html> |