summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2022-03-24 11:20:34 -0700
committerGravatar GitHub <noreply@github.com> 2022-03-24 11:20:34 -0700
commit5571227718442e1ec38f4553863b6160b74df722 (patch)
tree414444738ebe51e7c0cb2508920bce9c867dd08c
parentd763ec183ea391ad79ca16bf2b2e76848fc1180c (diff)
downloadastro-5571227718442e1ec38f4553863b6160b74df722.tar.gz
astro-5571227718442e1ec38f4553863b6160b74df722.tar.zst
astro-5571227718442e1ec38f4553863b6160b74df722.zip
fix adblock issue (#2875)
-rw-r--r--.changeset/strong-bears-knock.md5
-rw-r--r--packages/astro/src/core/build/static-build.ts12
-rw-r--r--packages/astro/test/astro-client-only.test.js2
-rw-r--r--packages/astro/test/astro-css-bundling.test.js8
-rw-r--r--packages/astro/test/astro-dynamic.test.js2
5 files changed, 17 insertions, 12 deletions
diff --git a/.changeset/strong-bears-knock.md b/.changeset/strong-bears-knock.md
new file mode 100644
index 000000000..dd432a934
--- /dev/null
+++ b/.changeset/strong-bears-knock.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Generalize output assets to avoid adblocker false positives
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index e9dd75478..de60e8a88 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -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
@@ -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',
},
diff --git a/packages/astro/test/astro-client-only.test.js b/packages/astro/test/astro-client-only.test.js
index 80358ece3..211a7df2a 100644
--- a/packages/astro/test/astro-client-only.test.js
+++ b/packages/astro/test/astro-client-only.test.js
@@ -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;
});
});
diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js
index 588febc82..105b35bc9 100644
--- a/packages/astro/test/astro-css-bundling.test.js
+++ b/packages/astro/test/astro-css-bundling.test.js
@@ -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'];
@@ -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);
}
diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js
index 81a960ffb..bc3d10b78 100644
--- a/packages/astro/test/astro-dynamic.test.js
+++ b/packages/astro/test/astro-dynamic.test.js
@@ -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`);
});
});