Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adblock issue #2875

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-bears-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Generalize output assets to avoid adblocker false positives
12 changes: 6 additions & 6 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
input: Array.from(input),
output: {
format: 'esm',
entryFileNames: '[name].[hash].mjs',
chunkFileNames: 'chunks/[name].[hash].mjs',
assetFileNames: 'assets/[name].[hash][extname]',
entryFileNames: 'entry.[hash].mjs',
chunkFileNames: 'chunks/chunk.[hash].mjs',
assetFileNames: 'assets/asset.[hash][extname]',
},
},
// must match an esbuild target
Expand Down Expand Up @@ -162,9 +162,9 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
input: Array.from(input),
output: {
format: 'esm',
entryFileNames: '[name].[hash].js',
chunkFileNames: 'chunks/[name].[hash].js',
assetFileNames: 'assets/[name].[hash][extname]',
entryFileNames: 'entry.[hash].js',
chunkFileNames: 'chunks/chunk.[hash].js',
assetFileNames: 'assets/asset.[hash][extname]',
},
preserveEntrySignatures: 'exports-only',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/astro-client-only.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ describe('Client only components', () => {
const script = $script.html();

// test 2: svelte renderer is on the page
expect(/import\(".\/PersistentCounter.*/g.test(script)).to.be.ok;
expect(/import\(".\/entry.*/g.test(script)).to.be.ok;
});
});
8 changes: 4 additions & 4 deletions packages/astro/test/astro-css-bundling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { loadFixture } from './test-utils.js';
// note: the hashes should be deterministic, but updating the file contents will change hashes
// be careful not to test that the HTML simply contains CSS, because it always will! filename and quanity matter here (bundling).
const EXPECTED_CSS = {
'/index.html': ['/assets/index'], // don’t match hashes, which change based on content
'/one/index.html': ['/assets/one'],
'/two/index.html': ['/assets/two'],
'/index.html': ['/assets/'], // don’t match hashes, which change based on content
'/one/index.html': ['/assets/'],
'/two/index.html': ['/assets/'],
};
const UNEXPECTED_CSS = ['/src/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css'];

Expand All @@ -32,7 +32,7 @@ describe('CSS Bundling', function () {
// test 1: assert new bundled CSS is present
for (const href of css) {
const link = $(`link[rel="stylesheet"][href^="${href}"]`);
expect(link).to.have.lengthOf(1);
expect(link.length).to.be.greaterThanOrEqual(1);
const outHref = link.attr('href');
builtCSS.add(outHref.startsWith('../') ? outHref.substr(2) : outHref);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/astro-dynamic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ describe('Dynamic components', () => {
// test 2: correct script is being loaded.
// because of bundling, we don't have access to the source import,
// only the bundled import.
expect($('script').html()).to.include(`import setup from '../only`);
expect($('script').html()).to.include(`import setup from '../entry`);
});
});