-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[DRAFT] feat: bun support #32580
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
base: develop
Are you sure you want to change the base?
[DRAFT] feat: bun support #32580
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1692,6 +1692,7 @@ enum OverLimitActionTypeEnum { | |
} | ||
|
||
enum PackageManagerEnum { | ||
bun | ||
npm | ||
pnpm | ||
yarn | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'path' | ||
import tempDir from 'temp-dir' | ||
import { homedir } from 'os' | ||
|
||
export function getBunCommand (opts: { | ||
updateLockFile: boolean | ||
isCI: boolean | ||
runScripts: boolean | ||
}): string { | ||
let cmd = 'bun install' | ||
|
||
if (!opts.runScripts) cmd += ' --ignore-scripts' | ||
|
||
if (!opts.updateLockFile) cmd += ' --frozen-lockfile' | ||
|
||
// Bun uses different cache structure than npm/yarn | ||
if (opts.isCI) cmd += ` --cache=${homedir()}/.bun/install/cache` | ||
else cmd += ` --cache=${path.join(tempDir, 'cy-system-tests-bun-cache', String(Date.now()))}` | ||
|
||
return cmd | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import path from 'path' | ||
import tempDir from 'temp-dir' | ||
import { homedir } from 'os' | ||
|
||
export function getPnpmCommand (opts: { | ||
yarnV311: boolean | ||
updateLockFile: boolean | ||
isCI: boolean | ||
runScripts: boolean | ||
}): string { | ||
let cmd = 'pnpm install' | ||
|
||
if (opts.yarnV311) throw new Error('_cyYarnV311 is not supported with PNPM.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Irrelevant Parameter Causes Command FailuresThe Additional Locations (1) |
||
|
||
if (!opts.runScripts) cmd += ' --ignore-scripts' | ||
|
||
if (!opts.updateLockFile) cmd += ' --frozen-lockfile' | ||
|
||
if (opts.isCI) cmd += ` --store-dir=${homedir()}/.pnpm-store` | ||
else cmd += ` --store-dir=${path.join(tempDir, 'cy-system-tests-pnpm-store', String(Date.now()))}` | ||
|
||
return cmd | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"lockfileVersion": 1, | ||
"workspaces": { | ||
"": { | ||
"name": "bun-component-testing", | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.0", | ||
"@types/react-dom": "^18.2.0", | ||
"typescript": "^5.6.3", | ||
}, | ||
}, | ||
}, | ||
"packages": { | ||
"@types/prop-types": ["@types/prop-types@15.7.15", "", {}, "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw=="], | ||
|
||
"@types/react": ["@types/react@18.3.24", "", { "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" } }, "sha512-0dLEBsA1kI3OezMBF8nSsb7Nk19ZnsyE1LLhB8r27KbgU5H4pvuqZLdtE+aUkJVoXgTVuA+iLIwmZ0TuK4tx6A=="], | ||
|
||
"@types/react-dom": ["@types/react-dom@18.3.7", "", { "peerDependencies": { "@types/react": "^18.0.0" } }, "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ=="], | ||
|
||
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], | ||
|
||
"js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="], | ||
|
||
"loose-envify": ["loose-envify@1.4.0", "", { "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, "bin": { "loose-envify": "cli.js" } }, "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q=="], | ||
|
||
"react": ["react@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ=="], | ||
|
||
"react-dom": ["react-dom@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" }, "peerDependencies": { "react": "^18.3.1" } }, "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw=="], | ||
|
||
"scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="], | ||
|
||
"typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
component: { | ||
devServer: { | ||
framework: 'react', | ||
bundler: 'webpack', | ||
}, | ||
}, | ||
e2e: { | ||
baseUrl: 'http://localhost:5000', | ||
}, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import { mount } from '@cypress/react' | ||
|
||
describe('Bun Component Test', () => { | ||
it('should render a simple React component', () => { | ||
const TestComponent = () => ( | ||
<div> | ||
<h1>Hello from Bun!</h1> | ||
<p>This component is tested using Bun package manager</p> | ||
</div> | ||
) | ||
|
||
mount(<TestComponent />) | ||
cy.contains('Hello from Bun!').should('be.visible') | ||
cy.contains('This component is tested using Bun package manager').should('be.visible') | ||
}) | ||
|
||
it('should work with TypeScript', () => { | ||
interface Props { | ||
message: string | ||
} | ||
|
||
const TypeScriptComponent: React.FC<Props> = ({ message }) => ( | ||
<div> | ||
<h2>TypeScript Component</h2> | ||
<p>{message}</p> | ||
</div> | ||
) | ||
|
||
mount(<TypeScriptComponent message="Bun + TypeScript + Cypress" />) | ||
cy.contains('TypeScript Component').should('be.visible') | ||
cy.contains('Bun + TypeScript + Cypress').should('be.visible') | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "es6"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx" | ||
}, | ||
"include": [ | ||
"**/*" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "bun-component-testing", | ||
"version": "0.0.0-test", | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.0", | ||
"@types/react-dom": "^18.2.0", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "es6"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx" | ||
}, | ||
"include": [ | ||
"cypress/**/*" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"lockfileVersion": 1, | ||
"workspaces": { | ||
"": { | ||
"name": "bun-with-deps", | ||
"dependencies": { | ||
"lodash": "^4.17.21", | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.225", | ||
"typescript": "^5.6.3", | ||
}, | ||
}, | ||
}, | ||
"packages": { | ||
"@types/lodash": ["@types/lodash@4.17.20", "", {}, "sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA=="], | ||
|
||
"lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="], | ||
|
||
"typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe('Bun E2E Test', () => { | ||
it('should work with bun package manager', () => { | ||
cy.visit('/cypress/fixtures/bun-test.html') | ||
cy.contains('Bun Test Page').should('be.visible') | ||
}) | ||
|
||
it('should be able to use lodash imported via bun', () => { | ||
// This test verifies that dependencies installed via bun are available | ||
const _ = require('lodash') | ||
|
||
expect(_.isArray).to.be.a('function') | ||
expect(_.isArray([])).to.be.true | ||
expect(_.isArray({})).to.be.false | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bun Test Page</title> | ||
</head> | ||
<body> | ||
<h1>Bun Test Page</h1> | ||
<p>This page is used for testing Bun package manager integration with Cypress.</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "bun-with-deps", | ||
"version": "0.0.0-test", | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.225", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"lockfileVersion": 1, | ||
"workspaces": { | ||
"": { | ||
"name": "bun-workspace", | ||
"devDependencies": { | ||
"typescript": "^5.6.3", | ||
}, | ||
}, | ||
"packages/app": { | ||
"name": "@bun-workspace/app", | ||
"version": "0.0.0-test", | ||
"dependencies": { | ||
"@bun-workspace/shared": "workspace:*", | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.6.3", | ||
}, | ||
}, | ||
"packages/shared": { | ||
"name": "@bun-workspace/shared", | ||
"version": "0.0.0-test", | ||
"dependencies": { | ||
"lodash": "^4.17.21", | ||
}, | ||
}, | ||
}, | ||
"packages": { | ||
"@bun-workspace/app": ["@bun-workspace/app@workspace:packages/app"], | ||
|
||
"@bun-workspace/shared": ["@bun-workspace/shared@workspace:packages/shared"], | ||
|
||
"lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="], | ||
|
||
"typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe('Bun Workspace Test', () => { | ||
it('should work with bun workspace dependencies', () => { | ||
cy.visit('/cypress/fixtures/workspace-test.html') | ||
cy.contains('Workspace Test Page').should('be.visible') | ||
}) | ||
|
||
it('should be able to import workspace packages', () => { | ||
// This test verifies that workspace dependencies are properly resolved | ||
const { sharedFunction, useLodash } = require('@bun-workspace/shared') | ||
|
||
expect(sharedFunction).to.be.a('function') | ||
expect(sharedFunction()).to.equal('Hello from shared package!') | ||
expect(useLodash).to.be.a('function') | ||
expect(useLodash()).to.equal('Lodash is available') | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Parameter Causes TypeScript Error
The
getBunCommand
function's signature doesn't include theyarnV311
parameter, which is passed by the caller. This causes a TypeScript compilation error. It also silently ignores the_cyYarnV311
flag, unlike other package managers that explicitly error when this unsupported option is present.Additional Locations (1)
system-tests/lib/dep-installer/index.ts#L244-L250