Skip to content

Commit

Permalink
polish: add a deprecation warning to --inspect on dev (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
threepointone authored May 6, 2022
1 parent 90425e2 commit dfeed74
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/loud-wombats-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

polish: add a deprecation warning to `--inspect` on `dev`

We have a blogposts and docs that says you need to pass `--inspect` to use devtools and/or profile your Worker. In wrangler v2, we don't need to pass the flag anymore. Using it right now will throw an error, so this patch makes it a simple warning instead.
20 changes: 19 additions & 1 deletion packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,10 @@ describe("wrangler dev", () => {
--jsx-fragment The function that is called for each JSX fragment [string]
--tsconfig Path to a custom tsconfig.json file [string]
-l, --local Run on my machine [boolean] [default: false]
--experimental-enable-local-persistence Enable persistence for this session (only for local mode) [boolean]
--minify Minify the script [boolean]
--node-compat Enable node.js compatibility [boolean]
--experimental-enable-local-persistence Enable persistence for this session (only for local mode) [boolean]
--inspect Enable dev tools [deprecated] [boolean]
X [ERROR] Not enough arguments following: site
",
Expand All @@ -727,6 +728,23 @@ describe("wrangler dev", () => {
`);
});
});

describe("--inspect", () => {
it("should warn if --inspect is used", async () => {
fs.writeFileSync("index.js", `export default {};`);
await runWrangler("dev index.js --inspect");
expect(std).toMatchInlineSnapshot(`
Object {
"debug": "",
"err": "",
"out": "",
"warn": "▲ [WARNING] Passing --inspect is unnecessary, now you can always connect to devtools.
",
}
`);
});
});
});

function mockGetZones(domain: string, zones: { id: string }[] = []) {
Expand Down
19 changes: 15 additions & 4 deletions packages/wrangler/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -753,17 +753,22 @@ export async function main(argv: string[]): Promise<void> {
type: "boolean",
default: false, // I bet this will a point of contention. We'll revisit it.
})
.option("experimental-enable-local-persistence", {
describe: "Enable persistence for this session (only for local mode)",
type: "boolean",
})
.option("minify", {
describe: "Minify the script",
type: "boolean",
})
.option("node-compat", {
describe: "Enable node.js compatibility",
type: "boolean",
})
.option("experimental-enable-local-persistence", {
describe: "Enable persistence for this session (only for local mode)",
type: "boolean",
})
.option("inspect", {
describe: "Enable dev tools",
type: "boolean",
deprecated: true,
});
},
async (args) => {
Expand All @@ -774,6 +779,12 @@ export async function main(argv: string[]): Promise<void> {
const config = readConfig(configPath, args);
const entry = await getEntry(args, config, "dev");

if (args.inspect) {
logger.warn(
"Passing --inspect is unnecessary, now you can always connect to devtools."
);
}

if (args["experimental-public"]) {
logger.warn(
"The --experimental-public field is experimental and will change in the future."
Expand Down

0 comments on commit dfeed74

Please sign in to comment.