Update rollup to prevent empty slot bug (#3496)

* Update rollup to prevent empty slot bug

* Adds a changeset

* Updated lockfile

* provide import.meta.env.SITE when there are private envs
This commit is contained in:
Matthew Phillips 2022-06-01 12:21:32 -04:00 committed by GitHub
parent cfb85ee10e
commit d588bc4a9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 82 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Update rollup to fix default param regression

View file

@ -119,7 +119,7 @@
"prompts": "^2.4.2",
"recast": "^0.20.5",
"resolve": "^1.22.0",
"rollup": "^2.75.4",
"rollup": "^2.75.5",
"semver": "^7.3.7",
"serialize-javascript": "^6.0.0",
"shiki": "^0.10.1",

View file

@ -132,8 +132,11 @@ export async function staticBuild(opts: StaticBuildOptions) {
timer.generate = performance.now();
if (opts.buildConfig.staticMode) {
await generatePages(ssrResult, opts, internals, facadeIdToPageDataMap);
await cleanSsrOutput(opts);
try {
await generatePages(ssrResult, opts, internals, facadeIdToPageDataMap);
} finally {
await cleanSsrOutput(opts);
}
} else {
info(opts.logging, null, `\n${bgMagenta(black(' finalizing server assets '))}\n`);
await ssrMoveAssets(opts);

View file

@ -85,6 +85,7 @@ export default function envVitePlugin({
replacements = Object.fromEntries(entries);
// These additional replacements are needed to match Vite
replacements = Object.assign(replacements, {
'import.meta.env.SITE': astroConfig.site ? `'${astroConfig.site}'` : 'undefined',
// This catches destructed `import.meta.env` calls,
// BUT we only want to inject private keys referenced in the file.
// We overwrite this value on a per-file basis.

View file

@ -30,6 +30,11 @@ describe('Environment Variables', () => {
expect(indexHtml).to.include('BLUE_BAYOU');
});
it('does render builtin SITE env', async () => {
let indexHtml = await fixture.readFile('/index.html');
expect(indexHtml).to.include('http://example.com');
});
it('includes public env in client-side JS', async () => {
let dirs = await fixture.readdir('/');
let found = false;

View file

@ -3,5 +3,6 @@ import vue from '@astrojs/vue';
// https://astro.build/config
export default defineConfig({
site: 'http://example.com',
integrations: [vue()],
});

View file

@ -3,4 +3,5 @@ import Client from '../components/Client.vue';
---
<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>
<Client client:load />

View file

@ -0,0 +1,21 @@
---
export interface Props {
title: string,
body: string,
href: string,
}
const {href, title, body} = Astro.props;
debugger;
---
<li class="link-card">
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
<slot name="icon" />
</p>
</a>
</li>

View file

@ -0,0 +1,10 @@
---
import Card from '../components/Card.astro';
---
<html>
<head><title>Testing</title></head>
<body>
<h1>Test</h1>
<Card title="A card" href="http://example.com" body="stuff" />
</body>
</html>

View file

@ -0,0 +1,19 @@
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe('Unused slot', () => {
let fixture;
before(async () => {
fixture = await loadFixture({ root: './fixtures/unused-slot/' });
await fixture.build();
});
it('is able to build with the slot missing', async () => {
let html = await fixture.readFile('/index.html');
let $ = cheerio.load(html);
// No children, slot rendered as empty
expect($('body p').children().length).to.equal(0);
});
});

View file

@ -527,7 +527,7 @@ importers:
prompts: ^2.4.2
recast: ^0.20.5
resolve: ^1.22.0
rollup: ^2.75.4
rollup: ^2.75.5
sass: ^1.52.1
semver: ^7.3.7
serialize-javascript: ^6.0.0
@ -586,7 +586,7 @@ importers:
prompts: 2.4.2
recast: 0.20.5
resolve: 1.22.0
rollup: 2.75.4
rollup: 2.75.5
semver: 7.3.7
serialize-javascript: 6.0.0
shiki: 0.10.1
@ -12175,6 +12175,15 @@ packages:
hasBin: true
optionalDependencies:
fsevents: 2.3.2
dev: true
/rollup/2.75.5:
resolution: {integrity: sha512-JzNlJZDison3o2mOxVmb44Oz7t74EfSd1SQrplQk0wSaXV7uLQXtVdHbxlcT3w+8tZ1TL4r/eLfc7nAbz38BBA==}
engines: {node: '>=10.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
dev: false
/run-parallel/1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
@ -13522,7 +13531,7 @@ packages:
esbuild: 0.14.42
postcss: 8.4.14
resolve: 1.22.0
rollup: 2.75.4
rollup: 2.75.5
optionalDependencies:
fsevents: 2.3.2
dev: false
@ -13546,7 +13555,7 @@ packages:
esbuild: 0.14.42
postcss: 8.4.14
resolve: 1.22.0
rollup: 2.75.4
rollup: 2.75.5
sass: 1.52.1
optionalDependencies:
fsevents: 2.3.2