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

Implement text-based lockfile #15705

Merged
merged 25 commits into from
Dec 11, 2024
Merged

Implement text-based lockfile #15705

merged 25 commits into from
Dec 11, 2024

Conversation

dylan-conway
Copy link
Member

@dylan-conway dylan-conway commented Dec 11, 2024

What does this PR do?

Adds support for bun.lock. With the following package.json:

{
  "name": "pkg",
  "version": "2.2.2",
  "dependencies": {
    "is-number": "1.0.0",
    "is-odd": "^3.0.1"
  }
}

A JSON with trailing commas bun.lock file is created:

{
  "lockfileVersion": 0,
  "workspaces": {
    "": {
      "dependencies": {
        "is-number": "1.0.0",
        "is-odd": "^3.0.1",
      }
    }
  },
  "packages": {
    "is-number": ["is-number@1.0.0", "", {}, "sha512-chlxkgJp4PZIiff6kUe/MWLp5+soELWNYA2IsOTus1YwKj8d9JZS6QsU7Ryqwhb1f4i0nQ5SsoUj6d5kGgq0KQ=="],
    "is-odd": ["is-odd@3.0.1", "", { "dependencies": { "is-number": "^6.0.0" } }, "sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA=="],
    "is-odd/is-number": ["is-number@6.0.0", "", {}, "sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg=="],
  }
}

closes #11863
closes #5486

Currently, if bun.lockb exists and bun.lock does not, or no lockfile exists, bun will still use the binary format. Running bun install --save-text-lockfile will produce bun.lock. Bun will choose bun.lock over bun.lockb if both exist.

How did you verify your code works?

Testing is ongoing. Currently there is code for converting bun.lockb to bun.lock in memory then re-parsing it before installing.

@robobun
Copy link

robobun commented Dec 11, 2024

@dylan-conway, your commit 06690a5 has 12 failures in #7791:

  • test/js/node/test/parallel/test-worker-process-exit-async-module.js - code 1 on 🐧 3.20 x64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 12 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 3.20 aarch64
  • test/regression/issue/09041.test.ts - 1 failing on 🐧 22.04 x64
  • test/js/bun/css/doesnt_crash.test.ts - 1 failing on 🐧 24.04 aarch64
  • test/js/bun/css/doesnt_crash.test.ts - timeout on 🐧 12 aarch64
  • test/js/deno/performance/performance.test.ts - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 12 aarch64
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 12 x64
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 12 x64-baseline
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 3.20 aarch64
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 3.20 x64-baseline
  • test/js/node/test/parallel/test-net-sync-cork.js - code 1 on 🐧 3.20 x64
  • test/cli/run/filter-workspace.test.ts - 1 failing on 🐧 20.04 aarch64
  • test/js/node/fs/fs.test.ts - timeout on 🪟 2019 x64-baseline
  • test/js/node/fs/fs.test.ts - timeout on 🪟 2019 x64
  • test/js/node/watch/fs.watchFile.test.ts - 1 failing on 🪟 2019 x64
  • test/js/bun/http/serve-body-leak.test.ts - 1 failing on 🪟 2019 x64
  • test/integration/next-pages/test/dev-server-ssr-100.test.ts - 1 failing on 🪟 2019 x64
  • test/integration/next-pages/test/dev-server-ssr-100.test.ts - 1 failing on 🪟 2019 x64-baseline
  • @Jarred-Sumner Jarred-Sumner merged commit b55ca42 into main Dec 11, 2024
    61 checks passed
    @Jarred-Sumner Jarred-Sumner deleted the dylan/text-migration branch December 11, 2024 13:05
    @benpsnyder
    Copy link

    Failing bun install --frozen-lockfile after switching

    @Gobd
    Copy link
    Contributor

    Gobd commented Dec 12, 2024

    Also failing frozen install. Also the file is not valid JSON but maybe it's not intended to be. If it is supposed to be JSON it'd be nice if the extension was json. Has issues like ",eslint-config-prettier ", that shouldn't have that trailing comma, and the ", and trailing space are weird. All of the JSON issues for me appear in the optionalPeers section of the file. The trailing commas are annoying because it makes the JSON difficult to diff using existing JSON diff tools.

    Fixing up the JSON and diffing it actually seems like maybe the only changes are the order of things in the packages object.

    Why doesn't this just use the output of bun bun.lockb?

    @tuyen-at-work
    Copy link

    In real project where each installed package have a long list of dependencies, the single line of dependencies approach would make it hard for versioning, as when we update the packages there will be a lot of change in single line and it'll feel clutered for reviewing.

    I suggest use multiple line, or adopt or format like YAML so we can achieve both consise and versioning-friendly purpose.

    remcohaszing added a commit to remcohaszing/vscode that referenced this pull request Dec 12, 2024
    Bun added support for a new lockfile format using the jsonc language. It
    uses an unconventional file extension, but it would be nice if VSCode
    understands it by default anyway.
    
    See oven-sh/bun#15705
    @Sherefedinagri
    Copy link

    Me

    jake8655 added a commit to jake8655/dotfiles that referenced this pull request Dec 20, 2024
    probably-neb pushed a commit to probably-neb/bun that referenced this pull request Jan 7, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    7 participants