denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.66k stars 5.25k forks source link

Unstable property in deno.json not working with npm workspaces in v1.45.0 #24531

Closed andyjp closed 2 months ago

andyjp commented 2 months ago

Version: Deno 1.45.0

When upgrading to 1.45.0, I noticed that the Deno.cron function wasn't getting added anymore in our deno app inside a npm workspace when defining the cron unstable flag in deno.json.

Here is a reproducible example:

package.json located at ~/workspaces/package.json

{
  "name": "workspace",
  "workspaces": [],
  "version": "1.0.0"
}

deno.json located at ~/workspaces/app/deno.json

{
  "tasks": {
    "testcron": "deno eval 'console.log(Deno.cron)'"
  },
  "unstable": ["cron"]
}

Deno.cron is undefined

~/workspace/app deno task testcron
Task testcron deno eval 'console.log(Deno.cron)'
undefined

Deno.cron is defined if using version 1.44.4 or when removing "workspaces": [] from the package.json

Output when using 1.44.4

~/workspace/app deno task testcron
Task testcron deno eval 'console.log(Deno.cron)'
[Function: cron]
dsherret commented 2 months ago

As a temporary workaround, you can add a deno.json at ~/workspaces/deno.json with the following:

{
  "workspace": {
    "members": ["./app"]
  },
  "unstable": ["cron"]
}

That will merge with the npm workspace. I'm working on a fix right now though.

dsherret commented 2 months ago

Should be fixed and released in 1.45.1

dsherret commented 2 months ago

By the way, if there's no package.json not part of the workspace beside the deno.json, then this is a regression in Deno 1.45. I opened https://github.com/denoland/deno/issues/24554