Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ commands:
# The timings manifest is derived from actual CI node run times; refresh it occasionally
# with: node scripts/generate-e2e-timings.js
command: 'cd bit && node scripts/split-e2e-tests.js | xargs npm run mocha-circleci << parameters.bit_bin >>'
no_output_timeout: '50m'
environment:
MOCHA_FILE: junit/e2e-test-results.xml
when: always
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (api) {
},
useBuiltIns: 'usage',
corejs: 3,
exclude: ['@babel/plugin-transform-dynamic-import'],
},
],
];
Expand Down
2 changes: 1 addition & 1 deletion components/legacy/e2e-helper/npm-ci-registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint no-console: 0 */
import { addUser, REGISTRY_MOCK_PORT, start as startRegistryMock, prepare } from '@pnpm/registry-mock';
import type { ChildProcess } from 'child_process';
import { fetch } from '@pnpm/fetch';
import fs from 'fs-extra';
import execa from 'execa';
import * as path from 'path';
Expand Down Expand Up @@ -79,6 +78,7 @@ export class NpmCiRegistry {
resolved = true;
let fetchResults;
try {
const { fetch } = await import('@pnpm/network.fetch');
fetchResults = await fetch(`http://localhost:${REGISTRY_MOCK_PORT}/is-odd`, {
retry: {
minTimeout: 1000,
Expand Down
25 changes: 17 additions & 8 deletions e2e/harmony/dependency-resolver.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import chai, { expect } from 'chai';
import path from 'path';
import fs from 'fs-extra';
import type { Modules } from '@pnpm/modules-yaml';
import { readModulesManifest } from '@pnpm/modules-yaml';
import yaml from 'js-yaml';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import rimraf from 'rimraf';
import { Extensions } from '@teambit/legacy.constants';
Expand All @@ -13,6 +13,11 @@ chai.use(chaiFs);

chai.use(assertArrays);

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}

describe('dependency-resolver extension', function () {
let helper: Helper;
this.timeout(0);
Expand Down Expand Up @@ -490,16 +495,20 @@ describe('dependency-resolver extension', function () {
it('should be able to install the env on a new workspace with no errors and install the latest of the pkg dep', () => {
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.command.install(helper.general.getPackageNameByCompName('empty-env'));

const envPkgJson = helper.fs.readJsonFile(
`node_modules/${helper.general.getPackageNameByCompName('empty-env')}/package.json`
);
const envPackageName = helper.general.getPackageNameByCompName('empty-env');
const envPkgJsonPath = `node_modules/${envPackageName}/package.json`;
const envPkgJson = helper.fs.readJsonFile(envPkgJsonPath);
expect(envPkgJson.dependencies[examplePkg]).to.equal('*');

const pkgJsonPath = path.join('node_modules', '.pnpm/@[email protected]/node_modules/@ci/lodash/package.json');
const pkgJson = helper.fs.readJsonFile(pkgJsonPath);
expect(pkgJson.version).to.equal('0.0.2');
const lockfile = yaml.load(fs.readFileSync(path.join(helper.scopes.localPath, 'pnpm-lock.yaml'), 'utf8')) as any;
const envSnapshot = Object.entries(lockfile.snapshots).find(([depPath]) =>
depPath.startsWith(`${envPackageName}@0.0.2`)
)?.[1] as any;
expect(lockfile.packages).to.have.property(`${examplePkg}@0.0.2`);
expect(envSnapshot?.dependencies?.[examplePkg]).to.equal('0.0.2');
});
});
});
Expand Down
14 changes: 6 additions & 8 deletions e2e/harmony/deps-graph-reimport.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ chai.use(chaiFs);
npmCiRegistry.configureCustomNameInPackageJsonHarmony(name);
await npmCiRegistry.init();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.env.setCustomNewEnv(
undefined,
undefined,
Expand Down Expand Up @@ -65,6 +66,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('rootComponents', true);
helper.command.import(`${helper.scopes.remote}/[email protected] ${helper.scopes.remote}/comp2@latest`);

Expand Down Expand Up @@ -96,6 +98,7 @@ chai.use(chaiFs);
npmCiRegistry.configureCustomNameInPackageJsonHarmony(name);
await npmCiRegistry.init();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.env.setCustomNewEnv(
undefined,
undefined,
Expand Down Expand Up @@ -128,6 +131,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.fs.createFile('foo', 'foo.js', `require("@pnpm.e2e/abc"); require("@ci/${randomStr}.bar");`);
helper.command.addComponent('foo');
helper.extensions.addExtensionToVariant('foo', `${helper.scopes.remote}/custom-env/[email protected]`, {});
Expand All @@ -143,6 +147,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.fs.createFile('baz', 'baz.js', `require("@pnpm.e2e/abc"); require("@ci/${randomStr}.bar");`);
helper.command.addComponent('baz');
helper.extensions.addExtensionToVariant('baz', `${helper.scopes.remote}/custom-env/[email protected]`, {});
Expand All @@ -153,6 +158,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.command.import(
`${helper.scopes.remote}/foo@latest ${helper.scopes.remote}/bar@latest ${helper.scopes.remote}/baz@latest`
);
Expand All @@ -171,13 +177,5 @@ chai.use(chaiFs);
expect(lockfile.packages).to.have.property('@pnpm.e2e/[email protected]');
expect(lockfile.packages).to.have.property('@pnpm.e2e/[email protected]');
});
// Documents a known limitation of the merge: highest-wins is applied only to the root
// edge. Transitive snapshots from lower-version graphs still reference the older
// versions of non-peer packages, so pnpm retains them in the lockfile. (Peer versions
// get reconciled across the workspace at install time, so they don't leak; regular
// dependencies do.)
it('currently leaves the lower version of non-peer transitives in the lockfile', () => {
expect(lockfile.packages).to.have.property('@pnpm.e2e/[email protected]');
});
});
});
3 changes: 3 additions & 0 deletions e2e/harmony/deps-graph.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ chai.use(chaiFs);
npmCiRegistry.configureCustomNameInPackageJsonHarmony(name);
await npmCiRegistry.init();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.env.setCustomNewEnv(
undefined,
undefined,
Expand Down Expand Up @@ -213,6 +214,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.fs.createFile('foo', 'foo.js', `require("@pnpm.e2e/abc"); require("@ci/${randomStr}.bar");`);
helper.command.addComponent('foo');
helper.extensions.addExtensionToVariant('foo', `${helper.scopes.remote}/custom-env/[email protected]`, {});
Expand All @@ -223,6 +225,7 @@ chai.use(chaiFs);
helper.scopeHelper.reInitWorkspace();
helper.scopeHelper.addRemoteScope();
npmCiRegistry.setRegistry();
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
helper.command.import(`${helper.scopes.remote}/foo@latest ${helper.scopes.remote}/bar@latest`);
});
let lockfile: any;
Expand Down
13 changes: 11 additions & 2 deletions e2e/harmony/install.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import stripAnsi from 'strip-ansi';
import path from 'path';
import fs from 'fs-extra';
import yaml from 'js-yaml';
import { addDistTag } from '@pnpm/registry-mock';
import { IssuesClasses } from '@teambit/component-issues';
import { getAnotherInstallRequiredOutput } from '@teambit/install';
Expand Down Expand Up @@ -156,6 +157,7 @@ describe('install generator configured envs', function () {
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } });
helper.scopeHelper.setWorkspaceWithRemoteScope();
helper.workspaceJsonc.setPackageManager(`teambit.dependencies/pnpm`);
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('minimumReleaseAge', 0);
npmCiRegistry = new NpmCiRegistry(helper);
await npmCiRegistry.init();

Expand All @@ -178,8 +180,15 @@ describe('install generator configured envs', function () {
expect(manifest.version).to.eq('100.1.0');
});
it('should update subdependency inside existing range', async () => {
const dirs = fs.readdirSync(path.join(helper.fixtures.scopes.localPath, 'node_modules/.pnpm'));
expect(dirs).to.include('@[email protected]');
const lockfile = yaml.load(
fs.readFileSync(path.join(helper.fixtures.scopes.localPath, 'pnpm-lock.yaml'), 'utf8')
) as any;
expect(lockfile.packages).to.have.property('@pnpm.e2e/[email protected]');
expect(
lockfile.snapshots?.['@pnpm.e2e/[email protected]']?.dependencies?.[
'@pnpm.e2e/pkg-with-1-dep'
]
).to.eq('100.1.0');
});
});
});
Expand Down
34 changes: 20 additions & 14 deletions e2e/harmony/pkg-manager-config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import path from 'path';
import chai, { expect } from 'chai';
import { readModulesManifest } from '@pnpm/modules-yaml';
import chaiString from 'chai-string';

import { Helper, NpmCiRegistry, supportNpmCiRegistryTesting } from '@teambit/legacy.e2e-helper';
import chaiFs from 'chai-fs';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { Helper, NpmCiRegistry, supportNpmCiRegistryTesting } from '@teambit/legacy.e2e-helper';

chai.use(chaiFs);
chai.use(chaiString);

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}

(supportNpmCiRegistryTesting ? describe : describe.skip)(
'package manager rc file is read from the workspace directory when installation is in a capsule',
'workspace package-manager config is read when installation is in a capsule',
function () {
Comment on lines 16 to 18
Comment on lines 16 to 18
Comment on lines 16 to 18
this.timeout(0);
Comment on lines 16 to 19
let helper: Helper;
Expand Down Expand Up @@ -67,26 +72,27 @@ chai.use(chaiString);
});
});
describe('using pnpm', () => {
before(() => {
helper.scopeHelper.reInitWorkspace({
npmrcConfig: {
'hoist-pattern[]': 'foo',
},
});
let modulesState: Modules | null;
before(async () => {
helper.scopeHelper.reInitWorkspace();
helper.fs.outputFile('pnpm-workspace.yaml', 'hoistPattern:\n - capsule-hoist-pattern\n');
helper.extensions.workspaceJsonc.addKeyValToDependencyResolver('packageManager', `teambit.dependencies/pnpm`);
helper.scopeHelper.addRemoteScope();
helper.workspaceJsonc.setupDefault();
helper.workspaceJsonc.addKeyValToWorkspace('resolveAspectsFromNodeModules', false);
helper.workspaceJsonc.addKeyValToWorkspace('resolveEnvsFromRoots', false);
helper.fixtures.populateComponents(1);
helper.extensions.addExtensionToVariant('comp1', `${envId1}@0.0.1`);
helper.capsules.removeScopeAspectCapsules();
helper.command.status(); // populate capsules.
});
it('workspace .npmrc is taken into account when running install in the capsule', async () => {

const { scopeAspectsCapsulesRootDir } = helper.command.capsuleListParsed();
const modulesState = await readModulesManifest(
modulesState = await readModulesManifest(
path.join(scopeAspectsCapsulesRootDir, `${helper.scopes.remote}[email protected]/node_modules`)
);
expect(modulesState?.hoistPattern?.[0]).to.eq('foo');
});
it('workspace pnpm config is taken into account when running install in the capsule', () => {
expect(modulesState?.hoistPattern).to.include('capsule-hoist-pattern');
});
});
after(() => {
Expand Down
8 changes: 6 additions & 2 deletions e2e/harmony/pnpm-default-hoisting.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { expect } from 'chai';
import path from 'path';
import type { Modules } from '@pnpm/modules-yaml';
import { readModulesManifest } from '@pnpm/modules-yaml';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { Helper } from '@teambit/legacy.e2e-helper';

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}

describe('pnpm install with default settings', function () {
let helper: Helper;
let modulesState: Modules | null;
Expand Down
11 changes: 3 additions & 8 deletions e2e/harmony/tsconfig-env-mismatch.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('tsconfig env mismatch between check-types and build', function () {
describe('component with permissive tsconfig imported by env with strict tsconfig', () => {
before(() => {
helper.scopeHelper.setWorkspaceWithRemoteScope();
helper.command.install('@teambit/[email protected] @teambit/compiler @teambit/builder');

// Create permissive tsconfig (no strict mode)
const permissiveTsconfig = JSON.stringify(
Expand Down Expand Up @@ -196,7 +197,6 @@ export function getDefaultTheme() {
helper.command.setEnv('consumer', 'strict-env');

helper.command.link();
helper.command.install('@teambit/typescript.typescript-compiler @teambit/builder');
helper.command.compile();
});

Expand All @@ -208,7 +208,7 @@ export function getDefaultTheme() {
expect(output).to.not.have.string("possibly 'null'");
});

it('bit build should pass without strict mode errors (each component uses its own tsconfig)', () => {
it('bit build should pass with each component using its own tsconfig', () => {
// This test verifies the fix: each component should be compiled with its own env's tsconfig.
// Theme component uses permissive-env (no strict), consumer uses strict-env (strict).
// With proper project references, TypeScript respects each component's tsconfig settings.
Expand All @@ -219,12 +219,7 @@ export function getDefaultTheme() {
//
// After the fix (typescript-compiler using graphCapsules):
// - Build passes because theme uses its own permissive-env's tsconfig
const output = helper.general.runWithTryCatch('bit build');
// Should NOT have any strict mode errors
expect(output).to.not.have.string('TS18047');
expect(output).to.not.have.string('TS2531');
expect(output).to.not.have.string('TS7053');
expect(output).to.not.have.string("possibly 'null'");
expect(() => helper.command.build()).to.not.throw();
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "Apache-2.0",
"private": true,
"engines": {
"node": ">=12.22.0"
"node": ">=22.13.0"
},
"lint-staged": {
"**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue,astro,svelte}": "oxlint --deny-warnings",
Expand Down
Loading