Skip to content

Commit

Permalink
Rename asw2 to asset-worker
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble committed Aug 21, 2024
1 parent a94388d commit 48329f3
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/workers-shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This is a package that is used at Cloudflare to power some internal features of [Cloudflare Workers](https://developers.cloudflare.com/workers/), as well as their open-source equivalents here in workers-sdk and Wrangler.

## `asset-server`
## `asset-worker`

The Asset Server Worker.
The Asset Worker.

For more details please refer to the dedicated README file.

Expand Down
3 changes: 0 additions & 3 deletions packages/workers-shared/asset-server-worker/README.md

This file was deleted.

3 changes: 3 additions & 0 deletions packages/workers-shared/asset-worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `asset-worker`

The Asset Worker is a [Cloudflare Worker](https://developers.cloudflare.com/workers/) that is responsible of serving static assets. It is deployed in production and is also used in local `wrangler dev`.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# to this file are persisted in wrangler as well, when necessary.
# (see packages/wrangler/src/dev/miniflare.ts -> buildMiniflareOptions())
##
name = "asw2"
name = "asset-worker"
account_id = "0f1b8aa119a907021f659042f95ea9ba"
workers_dev = false
main = "src/index.ts"
Expand Down
10 changes: 5 additions & 5 deletions packages/workers-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
],
"scripts": {
"build": "pnpm run clean && pnpm run bundle:asset-server:prod",
"bundle:asset-server": "esbuild asset-server-worker/src/index.ts --format=esm --bundle --outfile=dist/asset-server-worker.mjs --sourcemap=external --external:cloudflare:*",
"bundle:asset-server:prod": "pnpm run bundle:asset-server --minify",
"bundle:asset-worker": "esbuild asset-worker/src/index.ts --format=esm --bundle --outfile=dist/asset-worker.mjs --sourcemap=external --external:cloudflare:*",
"bundle:asset-worker:prod": "pnpm run bundle:asset-worker --minify",
"check:lint": "eslint . --max-warnings=0",
"check:type": "tsc",
"clean": "rimraf dist",
"deploy": "pnpm run deploy:asset-server",
"deploy:asset-server": "CLOUDFLARE_API_TOKEN=$WORKERS_NEW_CLOUDFLARE_API_TOKEN wrangler versions upload --experimental-versions -c asset-server-worker/wrangler.toml",
"dev": "pnpm run clean && concurrently -n bundle:asset-server -c blue \"pnpm run bundle:asset-server --watch\""
"deploy": "pnpm run deploy:asset-worker",
"deploy:asset-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_NEW_CLOUDFLARE_API_TOKEN wrangler versions upload --experimental-versions -c asset-worker/wrangler.toml",
"dev": "pnpm run clean && concurrently -n bundle:asset-worker -c blue \"pnpm run bundle:asset-worker --watch\""
},
"devDependencies": {
"@cloudflare/eslint-config-worker": "workspace:*",
Expand Down
18 changes: 8 additions & 10 deletions packages/wrangler/src/dev/miniflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ export function buildMiniflareBindingOptions(config: MiniflareBindingsConfig): {
// Setup service bindings to external services
const serviceBindings: NonNullable<WorkerOptions["serviceBindings"]> = {
...config.serviceBindings,
...(config.experimentalAssets
? { ASSET_SERVER: "asset-server-worker" }
: {}),
...(config.experimentalAssets ? { ASSET_SERVER: "asset-worker" } : {}),
};

const notFoundServices = new Set<string>();
Expand Down Expand Up @@ -920,16 +918,16 @@ function getAssetServerWorker(
if (!config.experimentalAssets) {
return [];
}
const assetServerModulePath = require.resolve(
"@cloudflare/workers-shared/dist/asset-server-worker.mjs"
const assetWorkerModulePath = require.resolve(
"@cloudflare/workers-shared/dist/asset-worker.mjs"
);
const assetServerConfigPath = require.resolve(
"@cloudflare/workers-shared/asset-server-worker/wrangler.toml"
const assetWorkerConfigPath = require.resolve(
"@cloudflare/workers-shared/asset-worker/wrangler.toml"
);
let assetServerConfig: Config | undefined;

try {
assetServerConfig = readConfig(assetServerConfigPath, {});
assetServerConfig = readConfig(assetWorkerConfigPath, {});
} catch (err) {
throw new UserError(
"Failed to read the Asset Server Worker configuration file.\n" + `${err}`
Expand All @@ -941,11 +939,11 @@ function getAssetServerWorker(
name: assetServerConfig?.name,
compatibilityDate: assetServerConfig?.compatibility_date,
compatibilityFlags: assetServerConfig?.compatibility_flags,
modulesRoot: dirname(assetServerModulePath),
modulesRoot: dirname(assetWorkerModulePath),
modules: [
{
type: "ESModule",
path: assetServerModulePath,
path: assetWorkerModulePath,
},
],
unsafeDirectSockets: [
Expand Down

0 comments on commit 48329f3

Please sign in to comment.