Skip to content

Commit

Permalink
chore: update wrangler version
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundhung committed Nov 26, 2022
1 parent a01f0b6 commit 78c4f3d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: 📦 Build the worker
run: npm run build
- name: 🔥 Publish
run: npx wrangler publish
env:
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"private": true,
"name": "remix-worker-template",
"main": "./dist/worker.mjs",
"description": "All-in-one remix starter template for Cloudflare Workers",
"module": "./dist/worker.mjs",
"scripts": {
"cleanup": "rimraf .cache ./dist ./build ./public/build ./app/styles/tailwind.css",
"build:remix": "remix build",
"build:style": "cross-env NODE_ENV=production tailwindcss -o ./app/styles/tailwind.css --minify",
"build:worker": "cross-env NODE_ENV=production VERSION=$(git rev-parse --short HEAD) node ./scripts/build.mjs",
"build:worker": "cross-env NODE_ENV=production node ./scripts/build.mjs",
"build": "npm run build:style && npm run build:remix && npm run build:worker",
"dev:miniflare": "miniflare --build-command \"node ./scripts/build.mjs\" --build-watch-path ./worker --build-watch-path ./build/index.js --no-cache --watch --open",
"dev:miniflare": "miniflare --modules --build-command \"node ./scripts/build.mjs\" --build-watch-path ./worker --build-watch-path ./build/index.js --no-cache --watch --open",
"dev:remix": "remix watch",
"dev:style": "tailwindcss -o ./app/styles/tailwind.css --watch",
"dev": "concurrently \"npm:dev:*\"",
"prebuild": "npm run cleanup",
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" playwright test",
"start": "miniflare",
"start": "miniflare --modules",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -28,7 +28,6 @@
},
"devDependencies": {
"@cloudflare/workers-types": "^3.18.0",
"@cloudflare/wrangler": "^1.20.0",
"@playwright/test": "^1.28.1",
"@remix-run/dev": "*",
"@remix-run/eslint-config": "*",
Expand All @@ -45,7 +44,8 @@
"prettier": "^2.8.0",
"rimraf": "^3.0.2",
"tailwindcss": "^3.2.4",
"typescript": "^4.9.3"
"typescript": "^4.9.3",
"wrangler": "^2.4.4"
},
"engines": {
"node": ">=16.7"
Expand Down
7 changes: 2 additions & 5 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import * as esbuild from 'esbuild';
async function build() {
// eslint-disable-next-line no-undef
const mode = process.env.NODE_ENV?.toLowerCase() ?? 'development';
// eslint-disable-next-line no-undef
const version = process.env.VERSION ?? new Date().toISOString();

console.log(`Building Worker in ${mode} mode for version ${version}`);
console.log(`Building Worker in ${mode} mode`);

const outfile = './dist/worker.mjs';
const startTime = Date.now();
Expand All @@ -20,8 +18,7 @@ async function build() {
external: ['__STATIC_CONTENT_MANIFEST'],
define: {
'process.env.NODE_ENV': `"${mode}"`,
'process.env.VERSION': `"${version}"`,
'process.env.REMIX_DEV_SERVER_WS_PORT': `""`,
'process.env.REMIX_DEV_SERVER_WS_PORT': `"8002"`,
},
outfile,
});
Expand Down
5 changes: 3 additions & 2 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test as base, expect } from '@playwright/test';
import { Miniflare } from 'miniflare';
import { MockAgent, setGlobalDispatcher } from 'undici';
import packageJson from '../package.json';

interface TestFixtures {
mockAgent: MockAgent;
Expand Down Expand Up @@ -46,9 +47,9 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
mf: [
async ({ port }, use) => {
const mf = new Miniflare({
scriptPath: packageJson.module,
modules: true,
wranglerConfigPath: true,
buildCommand: undefined,
bindings: {},
port,
});

Expand Down
3 changes: 0 additions & 3 deletions worker/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Required for custom adapters
import type { AppLoadContext } from '@remix-run/cloudflare';
import { createRequestHandler as createRemixRequestHandler } from '@remix-run/cloudflare';

// Required only for Worker Site
import {
getAssetFromKV,
MethodNotAllowedError,
Expand Down
17 changes: 2 additions & 15 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
name = "template"
type = "javascript"
workers_dev = true
# account_id = "Or specified with process.env.CF_ACCOUNT_ID"
# zone_id = "Or specified with process.env.CF_ZONE_ID"
main = "./dist/worker.mjs"
# route = "example.com/*"
compatibility_date = "2022-11-25"
compatibility_flags = ["streams_enable_constructors"]

[site]
bucket = "./public"
entry-point = "."

[build]
command = "npm run build"
watch_dir = "./build/index.js"

[build.upload]
format = "modules"
dir = "./dist"
main = "./worker.mjs"
bucket = "./public"

0 comments on commit 78c4f3d

Please sign in to comment.