Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno publish should be more lenient with calls to require functions #27986

Open
nicolo-ribaudo opened this issue Feb 6, 2025 · 0 comments
Open
Labels
publish Related to "deno publish" subcommand

Comments

@nicolo-ribaudo
Copy link

Version: Deno 2.1.7

I'm trying to publish some packages to JSR, and I have

  • @babel-test-6ae45912/preset-typescript that depends on @babel-test-6ae45912/helper-plugin-utils
  • @babel-test-6ae45912/helper-plugin-utils that depends on @babel-test-6ae45912/core
  • @babel-test-6ae45912/core that contains the file below:
// ...

function require(x) {
  throw Object.assign(new Error(), { code: "MODULE_NOT_FOUND" });
}

// ...

function getTSPreset(filepath) {
  try {
    return require("@babel-test-6ae45912/preset-typescript");
  } catch (error) {
    // ...
  }
}

Deno/JSR detects this file as depending on @babel-test-6ae45912/preset-typescript, and thus the publishing process fails with error: Circular package dependency detected: @babel-test-6ae45912/core -> @babel-test-6ae45912/preset-typescript -> @babel-test-6ae45912/helper-plugin-utils -> @babel-test-6ae45912/core.

In the cycles detection logic, it should probably either:

  • exclude require() calls in ESM files, since ESM does not have the "global" CJS require()
  • exclude require() calls that are calling functions named require declared in scope, since they are not the "global" CJS require()
  • just ignore all require() calls, since JSR does not support CJS anyway and it will already throw an error when you try to publish a CJS file
@crowlKats crowlKats added the publish Related to "deno publish" subcommand label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
publish Related to "deno publish" subcommand
Projects
None yet
Development

No branches or pull requests

2 participants