wrangler 2.12.0 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/__tests__/d1/execute.test.ts +1 -1
- package/src/__tests__/init.test.ts +1 -1
- package/src/__tests__/middleware.test.ts +2 -1
- package/src/__tests__/pages/functions-build.test.ts +44 -45
- package/src/__tests__/pages/publish.test.ts +136 -61
- package/src/__tests__/publish.test.ts +48 -7
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +1 -1
- package/src/api/dev.ts +0 -1
- package/src/api/pages/publish.tsx +31 -51
- package/src/bundle.ts +4 -0
- package/src/dev/dev.tsx +0 -2
- package/src/dev/local.tsx +4 -15
- package/src/dev/start-server.ts +1 -4
- package/src/dev.tsx +0 -3
- package/src/miniflare-cli/index.ts +1 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/pages/build.ts +262 -104
- package/src/pages/buildFunctions.ts +13 -6
- package/src/pages/dev.ts +4 -15
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +48 -33
- package/src/pages/functions/buildWorker.ts +20 -17
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/publish.tsx +1 -10
- package/src/user/user.ts +1 -1
- package/templates/gitignore +1 -0
- package/templates/tsconfig.init.json +1 -2
- package/wrangler-dist/cli.d.ts +1 -9
- package/wrangler-dist/cli.js +528 -423
package/miniflare-dist/index.mjs
CHANGED
|
@@ -6230,7 +6230,7 @@ async function main() {
|
|
|
6230
6230
|
if (logLevelString === "LOG")
|
|
6231
6231
|
logLevelString = "INFO";
|
|
6232
6232
|
const logLevel = MiniflareLogLevel[logLevelString];
|
|
6233
|
-
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel
|
|
6233
|
+
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel);
|
|
6234
6234
|
if (logLevel === MiniflareLogLevel.DEBUG) {
|
|
6235
6235
|
console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
|
|
6236
6236
|
}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ describe("execute", () => {
|
|
|
18
18
|
await expect(
|
|
19
19
|
runWrangler("d1 execute --command 'select 1;'")
|
|
20
20
|
).rejects.toThrowError(
|
|
21
|
-
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/api/
|
|
21
|
+
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.`
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -750,6 +750,7 @@ describe("unchanged functionality when wrapping with middleware", () => {
|
|
|
750
750
|
});
|
|
751
751
|
|
|
752
752
|
describe("multiple middleware", () => {
|
|
753
|
+
runInTempDir();
|
|
753
754
|
it("should respond correctly with D1 databases, scheduled testing, and formatted dev errors", async () => {
|
|
754
755
|
// Kitchen sink test to check interaction between multiple middlewares
|
|
755
756
|
const scriptContent = `
|
|
@@ -769,7 +770,7 @@ describe("multiple middleware", () => {
|
|
|
769
770
|
const stmt = await env.DB.prepare("INSERT INTO test (id, value) VALUES (?, ?)");
|
|
770
771
|
await stmt.bind(1, "one").run();
|
|
771
772
|
}
|
|
772
|
-
}
|
|
773
|
+
}
|
|
773
774
|
`;
|
|
774
775
|
fs.writeFileSync("index.js", scriptContent);
|
|
775
776
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
1
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
3
4
|
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
@@ -39,7 +40,7 @@ describe("functions build", () => {
|
|
|
39
40
|
/* --------------------------------- */
|
|
40
41
|
await runWrangler(`pages functions build`);
|
|
41
42
|
|
|
42
|
-
expect(existsSync("_worker.
|
|
43
|
+
expect(existsSync("_worker.bundle")).toBe(true);
|
|
43
44
|
expect(std.out).toMatchInlineSnapshot(`
|
|
44
45
|
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
|
|
45
46
|
✨ Compiled Worker successfully"
|
|
@@ -47,7 +48,7 @@ describe("functions build", () => {
|
|
|
47
48
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
48
49
|
});
|
|
49
50
|
|
|
50
|
-
it("should include any external modules imported by functions in the output bundle
|
|
51
|
+
it("should include any external modules imported by functions in the output bundle", async () => {
|
|
51
52
|
/* ---------------------------- */
|
|
52
53
|
/* Set up wasm files */
|
|
53
54
|
/* ---------------------------- */
|
|
@@ -76,9 +77,7 @@ describe("functions build", () => {
|
|
|
76
77
|
/* --------------------------------- */
|
|
77
78
|
/* Run cmd & make assertions */
|
|
78
79
|
/* --------------------------------- */
|
|
79
|
-
await runWrangler(
|
|
80
|
-
`pages functions build --outfile=_worker.bundle --experimental-worker-bundle=true`
|
|
81
|
-
);
|
|
80
|
+
await runWrangler(`pages functions build --outfile=_worker.bundle`);
|
|
82
81
|
|
|
83
82
|
expect(existsSync("_worker.bundle")).toBe(true);
|
|
84
83
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -126,12 +125,13 @@ describe("functions build", () => {
|
|
|
126
125
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
127
126
|
});
|
|
128
127
|
|
|
129
|
-
it("should
|
|
128
|
+
it("should output a directory with --outdir", async () => {
|
|
130
129
|
/* ---------------------------- */
|
|
131
130
|
/* Set up wasm files */
|
|
132
131
|
/* ---------------------------- */
|
|
133
132
|
mkdirSync("wasm");
|
|
134
|
-
writeFileSync("wasm/greeting.wasm", "Hello
|
|
133
|
+
writeFileSync("wasm/greeting.wasm", "Hello");
|
|
134
|
+
writeFileSync("wasm/name.wasm", "wasm Functions");
|
|
135
135
|
|
|
136
136
|
/* ---------------------------- */
|
|
137
137
|
/* Set up Functions */
|
|
@@ -141,10 +141,12 @@ describe("functions build", () => {
|
|
|
141
141
|
"functions/hello.js",
|
|
142
142
|
`
|
|
143
143
|
import hello from "./../wasm/greeting.wasm";
|
|
144
|
+
import name from "./../wasm/name.wasm";
|
|
144
145
|
|
|
145
146
|
export async function onRequest() {
|
|
146
|
-
const
|
|
147
|
-
|
|
147
|
+
const greetingModule = await WebAssembly.instantiate(greeting);
|
|
148
|
+
const nameModule = await WebAssembly.instantiate(name);
|
|
149
|
+
return new Response(greetingModule.exports.hello + " " + nameModule.exports.name);
|
|
148
150
|
}
|
|
149
151
|
`
|
|
150
152
|
);
|
|
@@ -152,13 +154,23 @@ describe("functions build", () => {
|
|
|
152
154
|
/* --------------------------------- */
|
|
153
155
|
/* Run cmd & make assertions */
|
|
154
156
|
/* --------------------------------- */
|
|
155
|
-
await
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)
|
|
157
|
+
await runWrangler(`pages functions build --outdir=dist`);
|
|
158
|
+
|
|
159
|
+
expect(existsSync("dist")).toBe(true);
|
|
160
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
161
|
+
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
|
|
162
|
+
✨ Compiled Worker successfully"
|
|
163
|
+
`);
|
|
164
|
+
|
|
165
|
+
expect(execSync("ls dist", { encoding: "utf-8" })).toMatchInlineSnapshot(`
|
|
166
|
+
"e8f0f80fe25d71a0fc2b9a08c877020211192308-name.wasm
|
|
167
|
+
f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0-greeting.wasm
|
|
168
|
+
index.js
|
|
169
|
+
"
|
|
170
|
+
`);
|
|
159
171
|
});
|
|
160
172
|
|
|
161
|
-
it("should build _worker.js
|
|
173
|
+
it("should build _worker.js", async () => {
|
|
162
174
|
/* ---------------------------- */
|
|
163
175
|
/* Set up js files */
|
|
164
176
|
/* ---------------------------- */
|
|
@@ -190,7 +202,7 @@ export default {
|
|
|
190
202
|
/* Run cmd & make assertions */
|
|
191
203
|
/* --------------------------------- */
|
|
192
204
|
await runWrangler(
|
|
193
|
-
`pages functions build --build-output-directory=public --outfile=_worker.bundle
|
|
205
|
+
`pages functions build --build-output-directory=public --outfile=_worker.bundle`
|
|
194
206
|
);
|
|
195
207
|
expect(existsSync("_worker.bundle")).toBe(true);
|
|
196
208
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -206,7 +218,7 @@ export default {
|
|
|
206
218
|
workerBundleContents,
|
|
207
219
|
[
|
|
208
220
|
[/------formdata-undici-0.[0-9]*/g, "------formdata-undici-0.test"],
|
|
209
|
-
[/
|
|
221
|
+
[/functionsWorker-0.[0-9]*.js/g, "functionsWorker-0.test.js"],
|
|
210
222
|
]
|
|
211
223
|
);
|
|
212
224
|
|
|
@@ -214,9 +226,9 @@ export default {
|
|
|
214
226
|
"------formdata-undici-0.test
|
|
215
227
|
Content-Disposition: form-data; name=\\"metadata\\"
|
|
216
228
|
|
|
217
|
-
{\\"main_module\\":\\"
|
|
229
|
+
{\\"main_module\\":\\"functionsWorker-0.test.js\\"}
|
|
218
230
|
------formdata-undici-0.test
|
|
219
|
-
Content-Disposition: form-data; name=\\"
|
|
231
|
+
Content-Disposition: form-data; name=\\"functionsWorker-0.test.js\\"; filename=\\"functionsWorker-0.test.js\\"
|
|
220
232
|
Content-Type: application/javascript+module
|
|
221
233
|
|
|
222
234
|
// ../utils/meaning-of-life.js
|
|
@@ -231,18 +243,10 @@ export default {
|
|
|
231
243
|
export {
|
|
232
244
|
worker_default as default
|
|
233
245
|
};
|
|
234
|
-
//# sourceMappingURL=bundledWorker-0.test.mjs.map
|
|
235
246
|
|
|
236
247
|
------formdata-undici-0.test--"
|
|
237
248
|
`);
|
|
238
249
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
239
|
-
|
|
240
|
-
await expect(
|
|
241
|
-
runWrangler(`pages functions build --build-output-directory=public`)
|
|
242
|
-
).rejects.toThrowError();
|
|
243
|
-
expect(std.err).toMatch(
|
|
244
|
-
/ENOENT: no such file or directory, scandir '.*functions'/
|
|
245
|
-
);
|
|
246
250
|
});
|
|
247
251
|
|
|
248
252
|
it("should include all external modules imported by _worker.js in the output bundle, when bundling _worker.js", async () => {
|
|
@@ -275,12 +279,10 @@ export default {
|
|
|
275
279
|
/* --------------------------------- */
|
|
276
280
|
/* Run cmd & make assertions */
|
|
277
281
|
/* --------------------------------- */
|
|
278
|
-
await runWrangler(
|
|
279
|
-
`pages functions build --build-output-directory=public --experimental-worker-bundle=true`
|
|
280
|
-
);
|
|
282
|
+
await runWrangler(`pages functions build --build-output-directory=public`);
|
|
281
283
|
|
|
282
284
|
// built to _worker.js by default
|
|
283
|
-
expect(existsSync("_worker.
|
|
285
|
+
expect(existsSync("_worker.bundle")).toBe(true);
|
|
284
286
|
expect(std.out).toMatchInlineSnapshot(`
|
|
285
287
|
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
|
|
286
288
|
✨ Compiled Worker successfully"
|
|
@@ -289,12 +291,12 @@ export default {
|
|
|
289
291
|
// some values in workerBundleContents, such as the undici form boundary
|
|
290
292
|
// or the file hashes, are randomly generated. Let's replace them
|
|
291
293
|
// with static values so we can test the file contents
|
|
292
|
-
const workerBundleContents = readFileSync("_worker.
|
|
294
|
+
const workerBundleContents = readFileSync("_worker.bundle", "utf-8");
|
|
293
295
|
const workerBundleWithConstantData = replaceRandomWithConstantData(
|
|
294
296
|
workerBundleContents,
|
|
295
297
|
[
|
|
296
298
|
[/------formdata-undici-0.[0-9]*/g, "------formdata-undici-0.test"],
|
|
297
|
-
[/
|
|
299
|
+
[/functionsWorker-0.[0-9]*.js/g, "functionsWorker-0.test.js"],
|
|
298
300
|
[/[0-9a-z]*-greeting.wasm/g, "test-greeting.wasm"],
|
|
299
301
|
[/[0-9a-z]*-name.wasm/g, "test-name.wasm"],
|
|
300
302
|
]
|
|
@@ -305,7 +307,7 @@ export default {
|
|
|
305
307
|
`Content-Disposition: form-data; name="metadata"`
|
|
306
308
|
);
|
|
307
309
|
expect(workerBundleWithConstantData).toContain(
|
|
308
|
-
`{"main_module":"
|
|
310
|
+
`{"main_module":"functionsWorker-0.test.js"}`
|
|
309
311
|
);
|
|
310
312
|
|
|
311
313
|
// check we appended the wasm modules
|
|
@@ -321,7 +323,7 @@ export default {
|
|
|
321
323
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
322
324
|
});
|
|
323
325
|
|
|
324
|
-
it("should build _worker.js over /functions, if both are present
|
|
326
|
+
it("should build _worker.js over /functions, if both are present", async () => {
|
|
325
327
|
/* ---------------------------- */
|
|
326
328
|
/* Set up _worker.js */
|
|
327
329
|
/* ---------------------------- */
|
|
@@ -352,9 +354,7 @@ export default {
|
|
|
352
354
|
/* --------------------------------- */
|
|
353
355
|
/* Run cmd & make assertions */
|
|
354
356
|
/* --------------------------------- */
|
|
355
|
-
await runWrangler(
|
|
356
|
-
`pages functions build --outfile=public/_worker.bundle --experimental-worker-bundle=true`
|
|
357
|
-
);
|
|
357
|
+
await runWrangler(`pages functions build --outfile=public/_worker.bundle`);
|
|
358
358
|
|
|
359
359
|
expect(existsSync("public/_worker.bundle")).toBe(true);
|
|
360
360
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -370,7 +370,7 @@ export default {
|
|
|
370
370
|
workerBundleContents,
|
|
371
371
|
[
|
|
372
372
|
[/------formdata-undici-0.[0-9]*/g, "------formdata-undici-0.test"],
|
|
373
|
-
[/
|
|
373
|
+
[/functionsWorker-0.[0-9]*.js/g, "functionsWorker-0.test.js"],
|
|
374
374
|
]
|
|
375
375
|
);
|
|
376
376
|
|
|
@@ -378,9 +378,9 @@ export default {
|
|
|
378
378
|
"------formdata-undici-0.test
|
|
379
379
|
Content-Disposition: form-data; name=\\"metadata\\"
|
|
380
380
|
|
|
381
|
-
{\\"main_module\\":\\"
|
|
381
|
+
{\\"main_module\\":\\"functionsWorker-0.test.js\\"}
|
|
382
382
|
------formdata-undici-0.test
|
|
383
|
-
Content-Disposition: form-data; name=\\"
|
|
383
|
+
Content-Disposition: form-data; name=\\"functionsWorker-0.test.js\\"; filename=\\"functionsWorker-0.test.js\\"
|
|
384
384
|
Content-Type: application/javascript+module
|
|
385
385
|
|
|
386
386
|
// _worker.js
|
|
@@ -392,7 +392,6 @@ export default {
|
|
|
392
392
|
export {
|
|
393
393
|
worker_default as default
|
|
394
394
|
};
|
|
395
|
-
//# sourceMappingURL=bundledWorker-0.test.mjs.map
|
|
396
395
|
|
|
397
396
|
------formdata-undici-0.test--"
|
|
398
397
|
`);
|
|
@@ -415,16 +414,16 @@ export default {
|
|
|
415
414
|
);
|
|
416
415
|
|
|
417
416
|
await runWrangler(
|
|
418
|
-
`pages functions build --outfile=public/_worker.
|
|
417
|
+
`pages functions build --outfile=public/_worker.bundle --compatibility-flag=nodejs_compat`
|
|
419
418
|
);
|
|
420
419
|
|
|
421
|
-
expect(existsSync("public/_worker.
|
|
420
|
+
expect(existsSync("public/_worker.bundle")).toBe(true);
|
|
422
421
|
expect(std.out).toMatchInlineSnapshot(`
|
|
423
422
|
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
|
|
424
423
|
✨ Compiled Worker successfully"
|
|
425
424
|
`);
|
|
426
425
|
|
|
427
|
-
expect(readFileSync("public/_worker.
|
|
426
|
+
expect(readFileSync("public/_worker.bundle", "utf-8")).toContain(
|
|
428
427
|
`import { AsyncLocalStorage } from "node:async_hooks";`
|
|
429
428
|
);
|
|
430
429
|
});
|
|
@@ -444,7 +443,7 @@ export default {
|
|
|
444
443
|
);
|
|
445
444
|
|
|
446
445
|
await expect(
|
|
447
|
-
runWrangler(`pages functions build --outfile=public/_worker.
|
|
446
|
+
runWrangler(`pages functions build --outfile=public/_worker.bundle`)
|
|
448
447
|
).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
449
448
|
"Build failed with 1 error:
|
|
450
449
|
hello.js:2:36: ERROR: Could not resolve \\"node:async_hooks\\""
|