Skip to content

Commit ec7c676

Browse files
committed
Updates to make more correct
1 parent 7c0b779 commit ec7c676

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "commonjs",
2+
"type": "module",
33
"private": true,
44
"dependencies": {
55
"@fastly/js-compute": "^3.33.2",
@@ -15,8 +15,11 @@
1515
},
1616
"scripts": {
1717
"prebuild": "webpack",
18-
"build": "js-compute-runtime bin/index.js bin/main.wasm",
18+
"build": "js-compute-runtime bin/index.cjs bin/main.wasm",
1919
"start": "fastly compute serve",
2020
"deploy": "fastly compute publish"
21+
},
22+
"engines": {
23+
"node": ">= 20.11"
2124
}
2225
}

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import { includeBytes } from "fastly:experimental";
66
import * as jws from "jws";
77

8-
import fetchConfig from "./config";
8+
import fetchConfig from "./config.js";
99

10-
import { getQueueCookie, setQueueCookie } from "./cookies";
10+
import { getQueueCookie, setQueueCookie } from "./cookies.js";
1111

1212
import {
1313
getStore,
@@ -16,11 +16,11 @@ import {
1616
incrementQueueCursor,
1717
incrementQueueLength,
1818
incrementAutoPeriod,
19-
} from "./store";
19+
} from "./store.js";
2020

21-
import log from "./logging";
21+
import log from "./logging.js";
2222

23-
import processView from "./views";
23+
import processView from "./views.js";
2424

2525
const textDecoder = new TextDecoder();
2626

webpack.config.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
const path = require("path");
2-
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
1+
import path from "path";
2+
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
33

4-
module.exports = {
4+
export default {
55
entry: "./src/index.js",
66
optimization: {
77
minimize: true,
88
},
99
target: "webworker",
1010
output: {
11-
filename: "index.js",
12-
path: path.resolve(__dirname, "bin"),
13-
libraryTarget: "this",
11+
filename: 'index.cjs',
12+
path: path.resolve(import.meta.dirname, "bin"),
13+
chunkFormat: 'commonjs',
14+
library: {
15+
type: 'commonjs',
16+
},
1417
},
1518
module: {
1619
// Loaders go here.
@@ -27,11 +30,8 @@ module.exports = {
2730
}),
2831
],
2932
externals: [
30-
({request,}, callback) => {
31-
if (/^fastly:.*$/.test(request)) {
32-
return callback(null, 'commonjs ' + request);
33-
}
34-
callback();
35-
}
33+
// Allow webpack to handle 'fastly:*' namespaced module imports by treating
34+
// them as modules rather than trying to process them as URLs
35+
/^fastly:.*$/,
3636
],
3737
};

0 commit comments

Comments
 (0)