From 7c0b779928f52e67b213e2d85c0bebc58ab36d3f Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Wed, 26 Mar 2025 11:38:00 +0900 Subject: [PATCH 1/3] Consistent package.json --- package.json | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index c50ef1e..5117688 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,22 @@ { - "author": "oss@fastly.com", - "bugs": { - "url": "https://github.com/fastly/compute-starter-kit-javascript-queue/issues" - }, + "type": "commonjs", + "private": true, "dependencies": { - "@fastly/js-compute": "^3.0.0", + "@fastly/js-compute": "^3.33.2", "@upstash/redis": "^1.23.4", "jws": "^4.0.0" }, "devDependencies": { - "@fastly/cli": "^10.14.0", + "@fastly/cli": "^11.0.0", "buffer": "^6.0.3", "node-polyfill-webpack-plugin": "^2.0.1", - "webpack": "^5.89.0", + "webpack": "^5.98.0", "webpack-cli": "^5.1.4" }, - "engines": { - "node": "^18.0.0" - }, - "homepage": "https://developer.fastly.com/solutions/starters/compute-starter-kit-javascript-queue", - "license": "MIT", - "main": "src/index.js", - "name": "compute-starter-kit-javascript-queue", - "repository": { - "type": "git", - "url": "git+https://github.com/fastly/compute-starter-kit-javascript-queue.git" - }, "scripts": { "prebuild": "webpack", "build": "js-compute-runtime bin/index.js bin/main.wasm", "start": "fastly compute serve", "deploy": "fastly compute publish" - }, - "version": "1.0.0-pre" + } } From ec7c676ad418205f4acbaf4e11000898d9eb9302 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Wed, 9 Apr 2025 17:59:08 +0900 Subject: [PATCH 2/3] Updates to make more correct --- package.json | 7 +++++-- src/index.js | 10 +++++----- webpack.config.js | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 5117688..47f9e26 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "type": "commonjs", + "type": "module", "private": true, "dependencies": { "@fastly/js-compute": "^3.33.2", @@ -15,8 +15,11 @@ }, "scripts": { "prebuild": "webpack", - "build": "js-compute-runtime bin/index.js bin/main.wasm", + "build": "js-compute-runtime bin/index.cjs bin/main.wasm", "start": "fastly compute serve", "deploy": "fastly compute publish" + }, + "engines": { + "node": ">= 20.11" } } diff --git a/src/index.js b/src/index.js index 1f82eaf..8b39d9b 100644 --- a/src/index.js +++ b/src/index.js @@ -5,9 +5,9 @@ import { includeBytes } from "fastly:experimental"; import * as jws from "jws"; -import fetchConfig from "./config"; +import fetchConfig from "./config.js"; -import { getQueueCookie, setQueueCookie } from "./cookies"; +import { getQueueCookie, setQueueCookie } from "./cookies.js"; import { getStore, @@ -16,11 +16,11 @@ import { incrementQueueCursor, incrementQueueLength, incrementAutoPeriod, -} from "./store"; +} from "./store.js"; -import log from "./logging"; +import log from "./logging.js"; -import processView from "./views"; +import processView from "./views.js"; const textDecoder = new TextDecoder(); diff --git a/webpack.config.js b/webpack.config.js index fe5e248..3ea0264 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,16 +1,19 @@ -const path = require("path"); -const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); +import path from "path"; +import NodePolyfillPlugin from "node-polyfill-webpack-plugin"; -module.exports = { +export default { entry: "./src/index.js", optimization: { minimize: true, }, target: "webworker", output: { - filename: "index.js", - path: path.resolve(__dirname, "bin"), - libraryTarget: "this", + filename: 'index.cjs', + path: path.resolve(import.meta.dirname, "bin"), + chunkFormat: 'commonjs', + library: { + type: 'commonjs', + }, }, module: { // Loaders go here. @@ -27,11 +30,8 @@ module.exports = { }), ], externals: [ - ({request,}, callback) => { - if (/^fastly:.*$/.test(request)) { - return callback(null, 'commonjs ' + request); - } - callback(); - } + // Allow webpack to handle 'fastly:*' namespaced module imports by treating + // them as modules rather than trying to process them as URLs + /^fastly:.*$/, ], }; From 5133267274f49e19a983b308395a876722c1ba17 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Wed, 9 Apr 2025 18:11:12 +0900 Subject: [PATCH 3/3] Update to Node 20.11 (Some syntax used in webpack.config needs this minimum version) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6f7abe..a6c9ddc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: '18' + node-version: '20.11' - name: Setup Fastly CLI uses: fastly/compute-actions/setup@v5 - name: Install Dependencies