Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
151bf9b
import all core aspects main runtimes to make sure it's part of the b…
GiladShoham Jan 19, 2023
fbaedad
now that we import all the core aspect main runtimes we don't need to…
GiladShoham Jan 19, 2023
613ee4e
require yargs instead of import it as it causes bundling issues
GiladShoham Jan 19, 2023
b053368
WIP - first bundling script (with hard coded stuff)
GiladShoham Jan 19, 2023
83935fc
externals updates
GiladShoham Jan 19, 2023
95b3f0d
remove tsconfig from eslint config (it will anyway generated on runtime)
GiladShoham Jan 19, 2023
3d174e4
update externals
GiladShoham Jan 19, 2023
cadc837
move imports
GiladShoham Jan 19, 2023
e861f01
Merge branch 'master' into bit-bundle
GiladShoham Mar 21, 2023
9589d7c
add esbuild plugins to policy
GiladShoham Mar 26, 2023
2484fe6
adjust bundle script
GiladShoham Mar 26, 2023
8e37f88
Merge branch 'master' into bit-bundle
GiladShoham Jul 16, 2023
dba67b1
Merge branch 'master' into bit-bundle
GiladShoham Jul 16, 2023
0009c69
fixes
GiladShoham Jul 16, 2023
96a78d7
Merge branch 'master' into bit-bundle
GiladShoham Jul 20, 2023
e34dc54
manifests fixes
GiladShoham Jul 20, 2023
6dd2505
move jest config inside instead of top
GiladShoham Jul 20, 2023
1dbdd6d
expose manifests map as a function (to support the bundling hoisting …
GiladShoham Jul 20, 2023
1b0549f
add more ignores
GiladShoham Jul 20, 2023
5614efc
fix config aspect instances
GiladShoham Jul 20, 2023
2b6c8ea
restructure bundle files and add readme
GiladShoham Jul 23, 2023
5ecf019
restore core aspects to manifests
GiladShoham Jul 23, 2023
76b3e02
bundle - generateCoreAspectsBarrelFile
GiladShoham Jul 23, 2023
f91bf9e
ignore bundle outputs
GiladShoham Jul 23, 2023
18c027b
generate core aspects modules
GiladShoham Jul 23, 2023
8c7b59b
export from generate core aspects barrel file
GiladShoham Jul 23, 2023
0d51e30
handle exports / modules for harmony / legacy
GiladShoham Jul 23, 2023
52b88a6
fix generated modules path
GiladShoham Jul 23, 2023
c1db47a
do not load core aspects defs when exclude core is true
GiladShoham Jul 23, 2023
b1b40b2
add todo about sourcemaps
GiladShoham Jul 23, 2023
3a87c27
fix gitignore
GiladShoham Jul 23, 2023
52a6fe1
update core aspects exports
GiladShoham Jul 23, 2023
10076bd
do not add core envs aspect defs to env runtime
GiladShoham Jul 23, 2023
942d6c9
add esbuild config files plugin
GiladShoham Jul 24, 2023
9162021
esbuild plugin handle module paths config files
GiladShoham Jul 24, 2023
abe239f
handle more files to copy
GiladShoham Jul 24, 2023
7fe2467
improve config files esbuild plugin
GiladShoham Jul 24, 2023
78eac1c
handle more config files (also from node_modules)
GiladShoham Jul 24, 2023
cf83bdb
externalize more packages
GiladShoham Jul 24, 2023
dcbfbac
remove file extensions from jest config
GiladShoham Jul 24, 2023
5efed4e
force some react env jest config bundling (hack)
GiladShoham Jul 24, 2023
d0d7e29
Merge branch 'master' into bit-bundle
GiladShoham Jul 25, 2023
1706167
Merge branch 'master' into bit-bundle
GiladShoham Jul 26, 2023
d9743e5
Merge branch 'master' into bit-bundle
GiladShoham Jul 26, 2023
d2ba72d
clean logs
GiladShoham Jul 26, 2023
f6315f3
output esbuild duration
GiladShoham Jul 26, 2023
465b11d
create package.json with external deps
GiladShoham Jul 26, 2023
1775e68
generate npmrc with bit's registry
GiladShoham Jul 26, 2023
4a342a6
copy pacakge.json of core aspects
GiladShoham Jul 26, 2023
8cdda40
move externals to a dedicated file
GiladShoham Jul 26, 2023
a640fa5
update main flow
GiladShoham Jul 26, 2023
ed4c523
update readme
GiladShoham Jul 26, 2023
d0b7dcb
add missing core aspects
GiladShoham Jul 26, 2023
c0c702a
add bundle script
GiladShoham Jul 27, 2023
a266483
Merge branch 'master' into bit-bundle
GiladShoham Aug 7, 2023
9d05d28
Merge branch 'master' into bit-bundle
GiladShoham Aug 7, 2023
798d9c8
trying tsup
GiladShoham Aug 7, 2023
c41f2e6
ensure folder exists
GiladShoham Aug 7, 2023
2b98ada
Merge branch 'master' into bit-bundle
GiladShoham Aug 10, 2023
ced0b86
move back to esbuild
GiladShoham Aug 13, 2023
7e0759d
Merge branch 'master' into bit-bundle
GiladShoham Aug 14, 2023
a08f376
add more externals
GiladShoham Aug 14, 2023
e707df9
update browserslist version
GiladShoham Aug 14, 2023
953986c
add copy files of core aspects
GiladShoham Aug 14, 2023
34490c3
improve copy files for core aspects
GiladShoham Aug 14, 2023
dc2b486
improve copy files
GiladShoham Aug 14, 2023
5c6bd02
improve core aspect path calc
GiladShoham Aug 14, 2023
540b342
derefrence copied files
GiladShoham Aug 14, 2023
d68863e
readability
GiladShoham Aug 14, 2023
58d7751
add more externals required for tests (jest config)
GiladShoham Aug 14, 2023
160f6fa
handle asset.d.ts and style.d.ts files
GiladShoham Aug 15, 2023
1f1f621
copy ts d.ts files
GiladShoham Aug 15, 2023
7b80033
add minify in comment
GiladShoham Aug 15, 2023
bf82ed9
Merge branch master into bit-bundle
GiladShoham Jan 21, 2024
e29685b
Merge branch 'master' into bit-bundle
GiladShoham Jan 21, 2024
5836d5d
remove elements leftovers
GiladShoham Jan 21, 2024
f0969a4
improve config files esbuild plugin resolution
GiladShoham Jan 21, 2024
53237f9
remove elements left overs
GiladShoham Jan 21, 2024
2b09cea
add missing exports in esm files
GiladShoham Jan 28, 2024
f97c391
Merge branch 'master' into bit-bundle
GiladShoham Jan 28, 2024
5a8e42e
Merge branch 'master' into bit-bundle
GiladShoham Feb 13, 2024
296c48a
add missing export in merging esm.mjs
GiladShoham Feb 13, 2024
74494ad
add missing externals
GiladShoham Feb 13, 2024
b42c56a
handle jest cjs transformer
GiladShoham Feb 13, 2024
946cfc9
fixes for workspace config proto
GiladShoham Feb 19, 2024
212e41a
Merge branch 'master' into bit-bundle
GiladShoham Feb 19, 2024
cf98ad4
refactor(core-aspects) - use named import to import aspects manifests
GiladShoham Feb 20, 2024
5089cdb
add config merger aspect to core ids
GiladShoham Feb 21, 2024
edb0d68
esm fixes on package.json and esm.mjs file copy
GiladShoham Feb 21, 2024
5f27727
improve core aspect loading when using bundle
GiladShoham Feb 21, 2024
d9dea87
generate sea and pkg configs (WIP)
GiladShoham Feb 29, 2024
0e7feeb
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Feb 29, 2024
1473cf0
bump esbuild
GiladShoham Feb 29, 2024
3558b09
add binary script to readme
GiladShoham Mar 4, 2024
c4e190e
generate esbuild metafile for bundle analysis
GiladShoham Mar 5, 2024
0b6cbfd
Merge branch 'master' into bit-bundle
GiladShoham Mar 7, 2024
08a26da
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Mar 10, 2024
4858ce2
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Mar 10, 2024
59a2528
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Mar 12, 2024
6b0771d
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Mar 12, 2024
61bb165
Merge branch 'master' into bit-bundle
GiladShoham May 15, 2024
0f7aaf5
fix getting bit version from bundle
GiladShoham May 16, 2024
2b5b9c1
Merge commit 'b01aa9901ad7937cdb18c9142f48a4e7edb93b71' into bit-bundle
GiladShoham May 16, 2024
195bd58
Merge branch 'master' into bit-bundle
GiladShoham Dec 16, 2024
3d2a32a
update esbuild
GiladShoham Dec 16, 2024
417c9f3
remove old file
GiladShoham Dec 16, 2024
07d43f0
remove react-native
GiladShoham Dec 16, 2024
62a8ef6
fixes
GiladShoham Dec 16, 2024
6217a28
fixes
GiladShoham Dec 16, 2024
c2a9e53
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Dec 17, 2024
1b2c3a6
remove react native
GiladShoham Dec 17, 2024
de8b463
replace getConsumerInfo with getWorkspaceInfo
GiladShoham Dec 17, 2024
b65b4d1
Merge branch 'master' of https://github.com/teambit/bit into bit-bundle
GiladShoham Dec 17, 2024
0f7240a
fixes
GiladShoham Dec 17, 2024
43c0aab
more fixes
GiladShoham Dec 17, 2024
2ea0c3c
update manifests file
GiladShoham Dec 17, 2024
3c2ebb6
remove hard-coded paths
davidfirst Sep 15, 2025
d6306ae
fix: resolve @teambit package paths correctly in bundler
davidfirst Sep 15, 2025
2f1732f
merge: resolve conflicts from merging master into bit-bundle
davidfirst Sep 15, 2025
dcc16be
fix: restore bundling-specific changes after merge
davidfirst Sep 16, 2025
9a93c7b
feat: add ESM bridge files for bundling compatibility
davidfirst Sep 16, 2025
6ec1cb6
fix: add missing core aspects to bundling system
davidfirst Sep 16, 2025
3478c34
feat: add ESM bridge files for new core aspects
davidfirst Sep 16, 2025
fe0da9c
some more fixes
davidfirst Sep 26, 2025
1c45e76
change it back to harmony.run(), same as it was in the original branch
davidfirst Sep 29, 2025
5dc844e
add main-runtime to the manifest file, add missing esm.mjs
davidfirst Oct 2, 2025
bdb0dda
downgrade babel-mocha to avoid esm.mjs files for this env
davidfirst Oct 2, 2025
5cbd18c
update all esm.mjs files
davidfirst Oct 2, 2025
c3630b1
bundle is now working with --version flag
davidfirst Oct 2, 2025
dc16625
now the --help is working!!
davidfirst Oct 2, 2025
36e50cb
remove the bit_log env var for now
davidfirst Oct 2, 2025
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
576 changes: 504 additions & 72 deletions .bitmap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ package-lock.json
!.yarn/sdks
!.yarn/versions

# bundle output
/bundle

# Claude Code files
.claude/
7 changes: 7 additions & 0 deletions components/bit/get-bit-version/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const getBitVersion = cjsModule.getBitVersion;
export const getBitVersionGracefully = cjsModule.getBitVersionGracefully;

export default cjsModule;
24 changes: 19 additions & 5 deletions components/bit/get-bit-version/get-bit-version.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { join } from 'path';
import { existsSync } from 'fs-extra';

export function getBitVersion(): string {
const teambitBit = require.resolve('@teambit/bit');
// eslint-disable-next-line
const packageJson = require(join(teambitBit, '../..', 'package.json'));
if (packageJson.version) return packageJson.version;
throw new Error(`unable to find Bit version`);
const teambitBit = require.resolve('@teambit/bit');
// For bundle cases, the teambitBit point to a flat folder that contains the package.json
let packageJsonPath = join(teambitBit, '../', 'package.json');
if (!existsSync(packageJsonPath)) {
// for dev cases, the teambitBit point to the dist folder that doesn't contains the package.json
packageJsonPath = join(teambitBit, '../..', 'package.json');
}
if (!existsSync(packageJsonPath)) {
throw new Error('unable to find Bit version (package.json not found)');
}
// eslint-disable-next-line
const packageJson = require(packageJsonPath);
if (packageJson.version) return packageJson.version;
// this is running locally
if (packageJson.componentId && packageJson.componentId.version) {
return packageJson.componentId.version || `last-tag ${packageJson.componentId.version}`;
}
throw new Error('unable to find Bit version (version not found in package.json)');
}

export function getBitVersionGracefully(): string | null {
Expand Down
12 changes: 12 additions & 0 deletions components/config-store/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const ConfigStoreAspect = cjsModule.ConfigStoreAspect;
export const getConfig = cjsModule.getConfig;
export const getNumberFromConfig = cjsModule.getNumberFromConfig;
export const listConfig = cjsModule.listConfig;
export const Store = cjsModule.Store;
export const setGlobalConfig = cjsModule.setGlobalConfig;
export const delGlobalConfig = cjsModule.delGlobalConfig;

export default cjsModule;
7 changes: 7 additions & 0 deletions components/legacy/analytics/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const Analytics = cjsModule.Analytics;
export const LEVEL = cjsModule.LEVEL;

export default cjsModule;
41 changes: 41 additions & 0 deletions components/legacy/constants/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './constants.js';

// Export all named exports
export const {
ACCEPTABLE_NPM_VERSIONS,
ANGULAR_BIT_ENTRY_POINT_FILE,
ANGULAR_PACKAGE_IDENTIFIER,
AUTO_GENERATED_MSG,
AUTO_GENERATED_STAMP,
AUTO_SNAPPED_MSG,
BASE_COMMUNITY_DOMAIN,
BASE_DOCS_DOMAIN,
BASE_LEGACY_DOCS_DOMAIN,
BASE_WEB_DOMAIN,
BITMAP_PREFIX_MESSAGE,
BITS_DIRNAME,
BIT_CACHE_DIRNAME,
BIT_GIT_DIR,
BIT_HIDDEN_DIR,
BIT_JSON,
BIT_MAP,
BIT_REGISTRY,
BIT_ROOTS_DIR,
BIT_SOURCES_DIRNAME,
BIT_TMP_DIRNAME,
BIT_USAGE,
BIT_WORKSPACE_TMP_DIRNAME,
BuildStatus,
CACHE_GLOBALS_ENV,
CACHE_ROOT,
CENTRAL_BIT_HUB_NAME,
CENTRAL_BIT_HUB_URL,
CENTRAL_BIT_HUB_URL_IMPORTER,
CENTRAL_BIT_HUB_URL_IMPORTER_V2,
GLOBAL_CONFIG,
GLOBAL_LOGS,
// Add other constants as needed...
} = cjsModule;

export default cjsModule;
25 changes: 25 additions & 0 deletions components/legacy/consumer-component/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const CURRENT_SCHEMA = cjsModule.CURRENT_SCHEMA;
export const ComponentLoadOptions = cjsModule.ComponentLoadOptions;
export const ComponentLoader = cjsModule.ComponentLoader;
export const ComponentNotFoundInPath = cjsModule.ComponentNotFoundInPath;
export const ConsumerComponent = cjsModule.ConsumerComponent;
export const DEPENDENCIES_TYPES = cjsModule.DEPENDENCIES_TYPES;
export const DEPENDENCIES_TYPES_UI_MAP = cjsModule.DEPENDENCIES_TYPES_UI_MAP;
export const Dependencies = cjsModule.Dependencies;
export const Dependency = cjsModule.Dependency;
export const DependencyLoaderOpts = cjsModule.DependencyLoaderOpts;
export const IgnoredDirectory = cjsModule.IgnoredDirectory;
export const ImportSpecifier = cjsModule.ImportSpecifier;
export const InvalidComponent = cjsModule.InvalidComponent;
export const LoadManyResult = cjsModule.LoadManyResult;
export const ManuallyChangedDependencies = cjsModule.ManuallyChangedDependencies;
export const RelativePath = cjsModule.RelativePath;
export const SchemaFeature = cjsModule.SchemaFeature;
export const SchemaName = cjsModule.SchemaName;
export const Specifier = cjsModule.Specifier;
export const isSchemaSupport = cjsModule.isSchemaSupport;

export default cjsModule;
17 changes: 17 additions & 0 deletions components/legacy/consumer-config/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const ComponentConfig = cjsModule.ComponentConfig;
export const ComponentConfigLoadOptions = cjsModule.ComponentConfigLoadOptions;
export const ComponentOverrides = cjsModule.ComponentOverrides;
export const ComponentOverridesData = cjsModule.ComponentOverridesData;
export const DependenciesOverridesData = cjsModule.DependenciesOverridesData;
export const ILegacyWorkspaceConfig = cjsModule.ILegacyWorkspaceConfig;
export const LegacyWorkspaceConfig = cjsModule.LegacyWorkspaceConfig;
export const LegacyWorkspaceConfigProps = cjsModule.LegacyWorkspaceConfigProps;
export const WorkspaceConfigLoadFunction = cjsModule.WorkspaceConfigLoadFunction;
export const componentOverridesForbiddenFields = cjsModule.componentOverridesForbiddenFields;
export const getBindingPrefixByDefaultScope = cjsModule.getBindingPrefixByDefaultScope;
export const nonPackageJsonFields = cjsModule.nonPackageJsonFields;

export default cjsModule;
12 changes: 12 additions & 0 deletions components/legacy/extension-data/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const ExtensionDataEntry = cjsModule.ExtensionDataEntry;
export const ExtensionDataList = cjsModule.ExtensionDataList;
export const REMOVE_EXTENSION_SPECIAL_SIGN = cjsModule.REMOVE_EXTENSION_SPECIAL_SIGN;
export const ValidateBeforePersistResult = cjsModule.ValidateBeforePersistResult;
export const configEntryToDataEntry = cjsModule.configEntryToDataEntry;
export const getCompareExtPredicate = cjsModule.getCompareExtPredicate;
export const removeInternalConfigFields = cjsModule.removeInternalConfigFields;

export default cjsModule;
6 changes: 6 additions & 0 deletions components/legacy/loader/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const loader = cjsModule.loader;

export default cjsModule;
12 changes: 12 additions & 0 deletions components/legacy/logger/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const IBitLogger = cjsModule.IBitLogger;
export const ServerSendOutStream = cjsModule.ServerSendOutStream;
export const getLevelFromArgv = cjsModule.getLevelFromArgv;
export const logger = cjsModule.logger;
export const printWarning = cjsModule.printWarning;
export const shouldDisableConsole = cjsModule.shouldDisableConsole;
export const shouldDisableLoader = cjsModule.shouldDisableLoader;

export default cjsModule;
17 changes: 17 additions & 0 deletions components/legacy/scope-api/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const CURRENT_FETCH_SCHEMA = cjsModule.CURRENT_FETCH_SCHEMA;
export const ExternalActions = cjsModule.ExternalActions;
export const FETCH_OPTIONS = cjsModule.FETCH_OPTIONS;
export const LaneNotFound = cjsModule.LaneNotFound;
export const PushOptions = cjsModule.PushOptions;
export const action = cjsModule.action;
export const fetch = cjsModule.fetch;
export const initScope = cjsModule.initScope;
export const latestVersions = cjsModule.latestVersions;
export const put = cjsModule.put;
export const remove = cjsModule.remove;
export const scopeConfig = cjsModule.scopeConfig;

export default cjsModule;
2 changes: 1 addition & 1 deletion components/legacy/scope-api/lib/latest-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ComponentID } from '@teambit/component-id';
import type { Scope } from '@teambit/legacy.scope';
import { loadScope } from '@teambit/legacy.scope';

export default (async function latestVersions(path: string, componentIdsStr: string[]): Promise<string[]> {
export default (async function (path: string, componentIdsStr: string[]): Promise<string[]> {
const scope: Scope = await loadScope(path);
const bitIds: ComponentID[] = await Promise.all(componentIdsStr.map((id) => scope.getParsedId(id)));
const componentsIds = await scope.latestVersions(bitIds);
Expand Down
6 changes: 6 additions & 0 deletions components/modules/find-scope-path/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-unresolved
import cjsModule from './index.js';

export const findScopePath = cjsModule.findScopePath;

export default cjsModule;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"performance-test:debug": "npm run performance-test --debug",
"performance-test-circle": "mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/performance/*.performance*.ts",
"bit-hub-test-circle": "mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/bit-hub/*.ts",
"bundle": "node node_modules/@teambit/bit/dist/bundle/bundle.js",
"clean-node-modules": "find . -type d -name node_modules -prune -exec rm -rf '{}' +",
"setup": "bit install && bit compile",
"full-setup": "rm -rf node_modules/.bin/bit && bit install && husky && bit compile",
Expand Down
3 changes: 3 additions & 0 deletions scopes/compilation/bundler/esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import cjsModule from './index.js';

export const BundlerAspect = cjsModule.BundlerAspect;
export const ComponentServer = cjsModule.ComponentServer;
export const ComponentServerStartedEvent = cjsModule.ComponentServerStartedEvent;
export const ComponentsServerStartedEvent = cjsModule.ComponentsServerStartedEvent;
export const NewDevServersCreatedEvent = cjsModule.NewDevServersCreatedEvent;

export default cjsModule;
12 changes: 11 additions & 1 deletion scopes/defender/jest/jest.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ export class JestMain {

static async provider([worker, loggerAspect]: [WorkerMain, LoggerMain]) {
const logger = loggerAspect.createLogger(JestAspect.id);
const jestWorker = worker.declareWorker<JestWorker>(WORKER_NAME, require.resolve('./jest.worker'));
// When bundled, worker files are copied to a separate directory
let workerPath: string;
try {
workerPath = require.resolve('./jest.worker');
} catch {
// Fallback for bundled version where worker is in a separate directory
// Use dynamic path construction to avoid esbuild resolving at build time
const defenderPath = './defender' + '.jest/dist/jest.worker';
workerPath = require.resolve(defenderPath);
}
const jestWorker = worker.declareWorker<JestWorker>(WORKER_NAME, workerPath);
return new JestMain(jestWorker, logger);
}
}
Expand Down
1 change: 1 addition & 0 deletions scopes/dependencies/dependency-resolver/esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const DependencyList = cjsModule.DependencyList;
export const BaseDependency = cjsModule.BaseDependency;
export const ComponentDependency = cjsModule.ComponentDependency;
export const KEY_NAME_BY_LIFECYCLE_TYPE = cjsModule.KEY_NAME_BY_LIFECYCLE_TYPE;
export const COMPONENT_DEP_TYPE = cjsModule.COMPONENT_DEP_TYPE;
export const WorkspacePolicy = cjsModule.WorkspacePolicy;
export const VariantPolicy = cjsModule.VariantPolicy;
export const EnvPolicy = cjsModule.EnvPolicy;
Expand Down
3 changes: 2 additions & 1 deletion scopes/envs/envs/environments.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,8 @@ if needed, use "bit env set" command to align the env id`;
);
}

private async getEnvAspectDef(envId: string): Promise<AspectDefinition> {
private async getEnvAspectDef(envId: string): Promise<AspectDefinition | undefined> {
if (this.isCoreEnv(envId)) return undefined;
const host = this.componentMain.getHost();
const id = await host.resolveComponentId(envId);
// We don't want to filter by runtime here as we want to also get envs that configured as plugins. so they don't
Expand Down
2 changes: 1 addition & 1 deletion scopes/envs/envs/runtime/env-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export class EnvRuntime {
/**
* Aspect definition of the env.
*/
readonly envAspectDefinition: AspectDefinition
readonly envAspectDefinition?: AspectDefinition
) {}
}
3 changes: 3 additions & 0 deletions scopes/git/ci/esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import cjsModule from './index.js';
export const CiAspect = cjsModule.CiAspect;
export default cjsModule;
27 changes: 21 additions & 6 deletions scopes/harmony/aspect-loader/core-aspects.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { BitError } from '@teambit/bit-error';
import { existsSync, readdir } from 'fs-extra';
import { existsSync, pathExists, readdir } from 'fs-extra';
import { join, resolve } from 'path';
import { Config } from '@teambit/bvm.config';
import { findCurrentBvmDir } from '@teambit/bvm.path';
import findRoot from 'find-root';

let _bvmConfig;

Expand Down Expand Up @@ -75,7 +76,13 @@ export function getAspectDir(id: string, isCore = true): string {
dirPath = resolve(__dirname, '../..', aspectName, 'dist');
}
if (!existsSync(dirPath)) {
throw new Error(`unable to find ${aspectName} in ${dirPath}`);
// Maybe it's bundle
const aspectPackage = getCoreAspectPackageName(id);
try {
dirPath = findRoot(require.resolve(aspectPackage));
} catch {
throw new Error(`unable to find ${aspectName}`);
}
}
return dirPath;
}
Expand Down Expand Up @@ -120,7 +127,9 @@ export function getAspectDirFromBvm(id: string, bvmDirOptions?: BvmDirOptions):
}

export function getAspectDistDir(id: string, isCore = true) {
return resolve(`${getAspectDir(id, isCore)}/dist`);
const aspectDir = getAspectDir(id, isCore);
// When running from bundle there won't be a dist folder
return resolve(`${aspectDir}/dist`);
}

export function getCoreAspectName(id: string): string {
Expand All @@ -146,9 +155,15 @@ function getNonCorePackageName(id: string): string {
}

export async function getAspectDef(aspectName: string, runtime?: string) {
const dirPath = getAspectDistDir(aspectName);
let dirPath = getAspectDir(aspectName);
const distDirPath = getAspectDistDir(aspectName);
const isDistDirExists = await pathExists(distDirPath);
if (distDirPath && isDistDirExists) {
dirPath = join(dirPath, '..');
}

const files = await readdir(dirPath);
const filesDir = distDirPath && isDistDirExists ? distDirPath : dirPath;
const files = await readdir(filesDir);
let runtimeFile;
if (runtime) {
runtimeFile = files.find((file) => file.includes(`.${runtime}.runtime.js`)) || null;
Expand All @@ -157,7 +172,7 @@ export async function getAspectDef(aspectName: string, runtime?: string) {

return {
id: aspectName,
aspectPath: join(dirPath, '..'),
aspectPath: dirPath,
aspectFilePath: aspectFile ? resolve(`${dirPath}/${aspectFile}`) : null,
runtimePath: runtimeFile ? resolve(`${dirPath}/${runtimeFile}`) : null,
};
Expand Down
Loading