Skip to content

Commit

Permalink
feat: throw error if routes are configured in _routes.json (#12360)
Browse files Browse the repository at this point in the history
* chore(cloudflare): throw error if routes are configured in _routes.json

* Update packages/adapter-cloudflare/index.js

* chore(adapter-cloudflare): remove check on options.routes

* chore(adapter-cloudflare): changeset

* Update .changeset/angry-spies-rule.md

---------

Co-authored-by: Ben McCann <[email protected]>
  • Loading branch information
kettei-sproutty and benmccann authored Jun 18, 2024
1 parent da5a72c commit a624bfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/angry-spies-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/adapter-cloudflare": minor
---

feat: validate that no `_routes.json` is present to avoid overwriting it
8 changes: 7 additions & 1 deletion packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFileSync } from 'node:fs';
import { existsSync, writeFileSync } from 'node:fs';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as esbuild from 'esbuild';
Expand All @@ -24,6 +24,12 @@ export default function (options = {}) {
return {
name: '@sveltejs/adapter-cloudflare',
async adapt(builder) {
if (existsSync('_routes.json')) {
throw new Error(
'Cloudflare routes should be configured in svelte.config.js rather than _routes.json'
);
}

const files = fileURLToPath(new URL('./files', import.meta.url).href);
const dest = builder.getBuildDirectory('cloudflare');
const tmp = builder.getBuildDirectory('cloudflare-tmp');
Expand Down

0 comments on commit a624bfa

Please sign in to comment.