diff --git a/.github/workflows/prereleases.yml b/.github/workflows/prereleases.yml index a9c16a8fd83a..234987e7c077 100644 --- a/.github/workflows/prereleases.yml +++ b/.github/workflows/prereleases.yml @@ -32,6 +32,7 @@ jobs: run: | node .github/version-script.js wrangler node .github/version-script.js create-cloudflare + node .github/version-script.js workers-shared - name: Build run: pnpm run build @@ -58,6 +59,10 @@ jobs: run: pnpm --filter create-cloudflare publish --tag beta env: NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + - name: Publish workers-shared@beta to NPM + run: pnpm --filter workers-shared publish --tag beta + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - name: Get Package Version run: echo "WRANGLER_VERSION=$(npm view wrangler@beta version)" >> $GITHUB_ENV diff --git a/packages/workers-shared/.eslintrc.js b/packages/workers-shared/.eslintrc.js new file mode 100644 index 000000000000..a56877269a90 --- /dev/null +++ b/packages/workers-shared/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + root: true, + extends: ["@cloudflare/eslint-config-worker"], + ignorePatterns: ["dist"], +}; diff --git a/packages/workers-shared/asset-server-worker/src/index.ts b/packages/workers-shared/asset-server-worker/src/index.ts index 3249a340c471..afeacd84f98e 100644 --- a/packages/workers-shared/asset-server-worker/src/index.ts +++ b/packages/workers-shared/asset-server-worker/src/index.ts @@ -1,5 +1,5 @@ export default { - async fetch(request, env) { + async fetch() { return new Response("Hello from Asset Server Worker 🚀"); }, }; diff --git a/packages/workers-shared/package.json b/packages/workers-shared/package.json index cf179e4d9681..02b2c7961914 100644 --- a/packages/workers-shared/package.json +++ b/packages/workers-shared/package.json @@ -2,16 +2,50 @@ "name": "@cloudflare/workers-shared", "version": "0.1.0", "description": "Package that is used at Cloudflare to power some internal features of Cloudflare Workers.", + "keywords": [ + "cloudflare", + "workers", + "cloudflare workers" + ], + "homepage": "https://github.com/cloudflare/workers-sdk/tree/main/packages/workers-shared#readme", + "bugs": { + "url": "https://github.com/cloudflare/workers-sdk/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/cloudflare/workers-sdk.git", + "directory": "packages/workers-shared" + }, + "license": "MIT OR Apache-2.0", + "author": "wrangler@cloudflare.com", + "files": [ + "dist" + ], "scripts": { - "build": "pnpm run clean && pnpm run bundle:asset-server", + "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", + "bundle:asset-server:prod": "pnpm run bundle:asset-server --minify", + "check:lint": "eslint . --max-warnings=0", + "check:type": "tsc", "clean": "rimraf dist", "dev": "pnpm run clean && concurrently -n bundle:asset-server -c blue \"pnpm run bundle:asset-server --watch\"" }, "devDependencies": { + "@cloudflare/eslint-config-worker": "workspace:*", + "@cloudflare/workers-tsconfig": "workspace:*", + "@cloudflare/workers-types": "^4.20240806.0", "concurrently": "^8.2.2", "esbuild": "0.17.19", "rimraf": "^6.0.1", "typescript": "^5.5.4" + }, + "engines": { + "node": ">=16.7.0" + }, + "volta": { + "extends": "../../package.json" + }, + "workers-sdk": { + "prerelease": true } } diff --git a/packages/workers-shared/tsconfig.json b/packages/workers-shared/tsconfig.json new file mode 100644 index 000000000000..f02acfbe9ca4 --- /dev/null +++ b/packages/workers-shared/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@cloudflare/workers-tsconfig/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "sourceMap": true, + "forceConsistentCasingInFileNames": true, + "useUnknownInCatchVariables": false, + "types": ["@cloudflare/workers-types"] + }, + "include": ["**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3fa2d7064b53..3b52892f1de9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1465,6 +1465,15 @@ importers: packages/workers-shared: devDependencies: + '@cloudflare/eslint-config-worker': + specifier: workspace:* + version: link:../eslint-config-worker + '@cloudflare/workers-tsconfig': + specifier: workspace:* + version: link:../workers-tsconfig + '@cloudflare/workers-types': + specifier: ^4.20240806.0 + version: 4.20240806.0 concurrently: specifier: ^8.2.2 version: 8.2.2