summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar wulinsheng123 <409187100@qq.com> 2023-01-06 00:41:10 +0800
committerGravatar GitHub <noreply@github.com> 2023-01-05 10:41:10 -0600
commit9963c6e4d50c392c3d1ac4492237020f15ccb1de (patch)
tree987b30220b3458bd6a2e295f52e2720e94b81c22
parentf1da0da29f94d34a7960f5b84288b7efa5b113f3 (diff)
downloadastro-9963c6e4d50c392c3d1ac4492237020f15ccb1de.tar.gz
astro-9963c6e4d50c392c3d1ac4492237020f15ccb1de.tar.zst
astro-9963c6e4d50c392c3d1ac4492237020f15ccb1de.zip
feat: change path into assets (#5584)
* feat: change path * feat: fix bug #5502 * fix: astro fix to patch * feat: change to major * chore: update changelog * fix: change entryFileNames into assets folder * fix: fix error message in test Co-authored-by: bluwy <bjornlu.dev@gmail.com>
-rw-r--r--.changeset/lovely-worms-invite.md8
-rw-r--r--packages/astro/src/core/build/static-build.ts4
-rw-r--r--packages/astro/test/astro-dynamic.test.js2
-rw-r--r--packages/astro/test/astro-envs.test.js5
-rw-r--r--packages/astro/test/sourcemap.test.js2
-rw-r--r--packages/integrations/deno/src/index.ts2
-rw-r--r--packages/integrations/image/src/index.ts4
-rw-r--r--packages/integrations/netlify/src/integration-edge-functions.ts2
8 files changed, 19 insertions, 10 deletions
diff --git a/.changeset/lovely-worms-invite.md b/.changeset/lovely-worms-invite.md
new file mode 100644
index 000000000..d081d2b79
--- /dev/null
+++ b/.changeset/lovely-worms-invite.md
@@ -0,0 +1,8 @@
+---
+'@astrojs/deno': major
+'@astrojs/netlify': major
+'@astrojs/image': minor
+'astro': major
+---
+
+Builds chunks into the `assets` folder. This simplifies configuring immutable caching with your adapter provider as all files are now in the same `assets` folder.
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index cfb447eb9..25ff1f5f6 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -212,8 +212,8 @@ async function clientBuild(
input: Array.from(input),
output: {
format: 'esm',
- entryFileNames: '[name].[hash].js',
- chunkFileNames: 'chunks/[name].[hash].js',
+ entryFileNames: 'assets/[name].[hash].js',
+ chunkFileNames: 'assets/chunks/[name].[hash].js',
assetFileNames: 'assets/[name].[hash][extname]',
...viteConfig.build?.rollupOptions?.output,
},
diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js
index 6f3c32198..78c5679a2 100644
--- a/packages/astro/test/astro-dynamic.test.js
+++ b/packages/astro/test/astro-dynamic.test.js
@@ -75,6 +75,6 @@ describe('Dynamic components subpath', () => {
expect($('astro-island').html()).to.equal('');
// test 2: has component url
const attr = $('astro-island').attr('component-url');
- expect(attr).to.include(`blog/PersistentCounter`);
+ expect(attr).to.include(`blog/assets/PersistentCounter`);
});
});
diff --git a/packages/astro/test/astro-envs.test.js b/packages/astro/test/astro-envs.test.js
index bb7354204..17648ef31 100644
--- a/packages/astro/test/astro-envs.test.js
+++ b/packages/astro/test/astro-envs.test.js
@@ -52,7 +52,8 @@ describe('Environment Variables', () => {
});
it('includes public env in client-side JS', async () => {
- let dirs = await fixture.readdir('/');
+ let dirs = await fixture.readdir('/assets');
+ console.log(dirs)
let found = false;
// Look in all of the .js files to see if the public env is inlined.
@@ -61,7 +62,7 @@ describe('Environment Variables', () => {
await Promise.all(
dirs.map(async (path) => {
if (path.endsWith('.js')) {
- let js = await fixture.readFile(`/${path}`);
+ let js = await fixture.readFile(`/assets/${path}`);
if (js.includes('BLUE_BAYOU')) {
found = true;
}
diff --git a/packages/astro/test/sourcemap.test.js b/packages/astro/test/sourcemap.test.js
index c24d7f3f0..4937e2236 100644
--- a/packages/astro/test/sourcemap.test.js
+++ b/packages/astro/test/sourcemap.test.js
@@ -10,7 +10,7 @@ describe('Sourcemap', async () => {
});
it('Builds sourcemap', async () => {
- const dir = await fixture.readdir('.');
+ const dir = await fixture.readdir('./assets');
const counterMap = dir.find((file) => file.match(/^Counter\.\w+\.js\.map$/));
expect(counterMap).to.be.ok;
});
diff --git a/packages/integrations/deno/src/index.ts b/packages/integrations/deno/src/index.ts
index 8907c489d..68452be94 100644
--- a/packages/integrations/deno/src/index.ts
+++ b/packages/integrations/deno/src/index.ts
@@ -86,7 +86,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
// Remove chunks, if they exist. Since we have bundled via esbuild these chunks are trash.
try {
const chunkFileNames =
- _vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'chunks/chunk.[hash].mjs';
+ _vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'assets/chunks/chunk.[hash].mjs';
const chunkPath = npath.dirname(chunkFileNames);
const chunksDirUrl = new URL(chunkPath + '/', _buildConfig.server);
await fs.promises.rm(chunksDirUrl, { recursive: true, force: true });
diff --git a/packages/integrations/image/src/index.ts b/packages/integrations/image/src/index.ts
index c30ee31ed..cc8093981 100644
--- a/packages/integrations/image/src/index.ts
+++ b/packages/integrations/image/src/index.ts
@@ -146,7 +146,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
// For the Squoosh service, copy all wasm files to dist/chunks.
// Because the default loader is dynamically imported (above),
// Vite will bundle squoosh to dist/chunks and expect to find the wasm files there
- await copyWasmFiles(new URL('./chunks', dir));
+ await copyWasmFiles(new URL('./assets/chunks', dir));
}
if (loader && 'transform' in loader && staticImages.size > 0) {
@@ -166,7 +166,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
},
'astro:build:ssr': async () => {
if (resolvedOptions.serviceEntryPoint === '@astrojs/image/squoosh') {
- await copyWasmFiles(new URL('./chunks/', _buildConfig.server));
+ await copyWasmFiles(new URL('./assets/chunks/', _buildConfig.server));
}
},
},
diff --git a/packages/integrations/netlify/src/integration-edge-functions.ts b/packages/integrations/netlify/src/integration-edge-functions.ts
index 35b660e2c..48be316d9 100644
--- a/packages/integrations/netlify/src/integration-edge-functions.ts
+++ b/packages/integrations/netlify/src/integration-edge-functions.ts
@@ -100,7 +100,7 @@ async function bundleServerEntry({ serverEntry, server }: BuildConfig, vite: any
// Remove chunks, if they exist. Since we have bundled via esbuild these chunks are trash.
try {
const chunkFileNames =
- vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'chunks/chunk.[hash].mjs';
+ vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'assets/chunks/chunk.[hash].mjs';
const chunkPath = npath.dirname(chunkFileNames);
const chunksDirUrl = new URL(chunkPath + '/', server);
await fs.promises.rm(chunksDirUrl, { recursive: true, force: true });