diff --git a/.gitignore b/.gitignore index 4fd5a1c3ee84..30cac836dce1 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ package-lock.json !.yarn/plugins !.yarn/sdks !.yarn/versions + +# bundle output +/bundle diff --git a/components/bit/get-bit-version/get-bit-version.ts b/components/bit/get-bit-version/get-bit-version.ts index 308007191402..2b7945c66517 100644 --- a/components/bit/get-bit-version/get-bit-version.ts +++ b/components/bit/get-bit-version/get-bit-version.ts @@ -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 { diff --git a/components/legacy/scope-api/lib/latest-versions.ts b/components/legacy/scope-api/lib/latest-versions.ts index 3631ad5ca7c9..a3abd0f555c1 100644 --- a/components/legacy/scope-api/lib/latest-versions.ts +++ b/components/legacy/scope-api/lib/latest-versions.ts @@ -1,7 +1,7 @@ import { ComponentID } from '@teambit/component-id'; import { loadScope, Scope } from '@teambit/legacy.scope'; -export default (async function latestVersions(path: string, componentIdsStr: string[]): Promise { +export default (async function (path: string, componentIdsStr: string[]): Promise { const scope: Scope = await loadScope(path); const bitIds: ComponentID[] = await Promise.all(componentIdsStr.map((id) => scope.getParsedId(id))); const componentsIds = await scope.latestVersions(bitIds); diff --git a/package.json b/package.json index e27e1ce632bc..e0c5816b130d 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "performance-test:debug": "npm run performance-test --debug --keep-envs", "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", "setup": "bit install && bit compile", "full-setup": "rm -rf node_modules/.bin/bit && bit install && husky install && bit compile", "full-setup:bbit": "rm -rf node_modules/.bin/bbit && bbit install && husky install && bbit compile", diff --git a/scopes/envs/envs/environments.main.runtime.ts b/scopes/envs/envs/environments.main.runtime.ts index 8d5a33212061..060da003da93 100644 --- a/scopes/envs/envs/environments.main.runtime.ts +++ b/scopes/envs/envs/environments.main.runtime.ts @@ -1129,7 +1129,8 @@ export class EnvsMain { ); } - private async getEnvAspectDef(envId: string): Promise { + private async getEnvAspectDef(envId: string): Promise { + 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 diff --git a/scopes/envs/envs/runtime/env-runtime.ts b/scopes/envs/envs/runtime/env-runtime.ts index e1e2a9003796..ff149fa8ee3c 100644 --- a/scopes/envs/envs/runtime/env-runtime.ts +++ b/scopes/envs/envs/runtime/env-runtime.ts @@ -26,6 +26,6 @@ export class EnvRuntime { /** * Aspect definition of the env. */ - readonly envAspectDefinition: AspectDefinition + readonly envAspectDefinition?: AspectDefinition ) {} } diff --git a/scopes/harmony/aspect-loader/core-aspects.ts b/scopes/harmony/aspect-loader/core-aspects.ts index 1fa46169a938..4c8ef5cb1066 100644 --- a/scopes/harmony/aspect-loader/core-aspects.ts +++ b/scopes/harmony/aspect-loader/core-aspects.ts @@ -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; @@ -75,7 +76,13 @@ export function getAspectDir(id: string): 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; } @@ -119,8 +126,23 @@ export function getAspectDirFromBvm(id: string, bvmDirOptions?: BvmDirOptions): return getAspectDirFromPath(id, [versionDir]); } +// function getCoreAspectDirFromPath(resolvedModulesPath: string): string { +// if (!resolvedModulesPath.includes('@teambit')) { +// throw new Error(`unable to find core aspect in ${resolvedModulesPath}`); +// } +// let currentDir = resolvedModulesPath; +// let parentDir = dirname(currentDir); +// while (basename(parentDir) !== '@teambit') { +// currentDir = parentDir; +// parentDir = dirname(currentDir); +// } +// return currentDir; +// } + export function getAspectDistDir(id: string) { - return resolve(`${getAspectDir(id)}/dist`); + const aspectDir = getAspectDir(id); + // When running from bundle there won't be a dist folder + return resolve(`${aspectDir}/dist`); } export function getCoreAspectName(id: string): string { @@ -135,9 +157,15 @@ export function getCoreAspectPackageName(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; @@ -146,7 +174,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, }; diff --git a/scopes/harmony/bit/app.ts b/scopes/harmony/bit/app.ts index 53c0aecae1cc..131d7249745b 100644 --- a/scopes/harmony/bit/app.ts +++ b/scopes/harmony/bit/app.ts @@ -23,6 +23,9 @@ if (process.argv.includes('--get-yargs-completions')) { process.exit(0); } +// Export APIs from all core aspects to be used in the bundled app +export * from './core-aspects-exports'; + if (process.argv.includes('server-forever')) { spawnPTY(); } else if (shouldUseBitServer()) { diff --git a/scopes/harmony/bit/bit.main.runtime.ts b/scopes/harmony/bit/bit.main.runtime.ts index a79d638c704b..605495c64bad 100644 --- a/scopes/harmony/bit/bit.main.runtime.ts +++ b/scopes/harmony/bit/bit.main.runtime.ts @@ -3,19 +3,23 @@ import { ExtensionDataList } from '@teambit/legacy.extension-data'; import { BitAspect } from './bit.aspect'; import { provideBit } from './bit.provider'; -import { manifestsMap } from './manifests'; +import { getManifestsMap } from './manifests'; -const manifests = Object.values(manifestsMap); +const manifestsMap = getManifestsMap(); export function registerCoreExtensions() { const allCoreExtensionsNames = Object.keys(manifestsMap); ExtensionDataList.registerManyCoreExtensionNames(allCoreExtensionsNames); } +function getDeps() { + return Object.values(manifestsMap); +} + export const BitMain = { name: 'bit', runtime: MainRuntime, - dependencies: manifests, + dependencies: getDeps(), provider: provideBit, }; diff --git a/scopes/harmony/bit/bit.provider.ts b/scopes/harmony/bit/bit.provider.ts index f321779232e0..8e0e3a675bd2 100644 --- a/scopes/harmony/bit/bit.provider.ts +++ b/scopes/harmony/bit/bit.provider.ts @@ -1,4 +1,4 @@ -import { manifestsMap } from './manifests'; +import { getManifestsMap } from './manifests'; export type BitDeps = []; @@ -16,6 +16,6 @@ export type BitConfig = { export async function provideBit() { return { - manifestsMap, + manifestsMap: getManifestsMap(), }; } diff --git a/scopes/harmony/bit/bundle/bundle.ts b/scopes/harmony/bit/bundle/bundle.ts new file mode 100644 index 000000000000..2f3bf735d6f4 --- /dev/null +++ b/scopes/harmony/bit/bundle/bundle.ts @@ -0,0 +1,37 @@ +import fs from 'fs-extra'; +import { omit } from 'lodash'; +import { runEsbuild } from './esbuild'; +import { generateCoreAspectsBarrelFile } from './generate-core-aspects-exports'; +import { generateCoreAspectsModules } from './generate-core-aspects-modules'; +import { generatePackageJson } from './create-package-json'; +import { generateNpmrc } from './generate-npmrc'; +// import { runTsup } from './tsup'; +import { copyFilesOfCoreAspects } from './copy-files-of-core-aspects'; +import { copyOtherFiles } from './copy-other-files'; +import { generateSeaConfig } from './generate-sea-config'; + +// const rootOutDir = '/Users/giladshoham/dev/bit/bit/bundle'; +const rootOutDir = '/tmp/bit-bundle'; +const bundleDirName = 'bundle'; +const bundleDir = `${rootOutDir}/${bundleDirName}`; +const appFileBaseName = 'bit.app'; +const jsAppFile = `${appFileBaseName}.js`; +const blobAppFile = `${appFileBaseName}.blob`; + +async function runBundle() { + const esbuildRes = await runEsbuild(bundleDir, jsAppFile); + // const tsupRes = await runTsup(bundleDir, jsAppFile); + await generateCoreAspectsModules(rootOutDir, jsAppFile); + await copyFilesOfCoreAspects(rootOutDir, bundleDir); + await copyOtherFiles(bundleDir); + generateNpmrc(rootOutDir); + await generatePackageJson(rootOutDir, bundleDirName, jsAppFile); + await generateCoreAspectsBarrelFile(); + await generateSeaConfig(bundleDir, jsAppFile, blobAppFile); + const metafile = esbuildRes.metafile; + await fs.writeJSON(`${bundleDir}/metafile.json`, metafile, { spaces: 2 }); + return omit(esbuildRes, ['metafile']); + // return tsupRes; +} + +runBundle().then((res) => console.log(JSON.stringify(res, null, 2))); diff --git a/scopes/harmony/bit/bundle/config-files-esbuild-plugin.ts b/scopes/harmony/bit/bundle/config-files-esbuild-plugin.ts new file mode 100644 index 000000000000..531d40a0cd05 --- /dev/null +++ b/scopes/harmony/bit/bundle/config-files-esbuild-plugin.ts @@ -0,0 +1,204 @@ +import { basename, dirname, join, parse } from 'path'; +import { OnResolveArgs } from 'esbuild'; +import fs from 'fs-extra'; + +type ParsedArgs = { + scopeName: string; + componentName: string; + relativePath: string; +}; + +function handleConfigFile(args: OnResolveArgs, bundleDir: string) { + if ( + args.kind === 'require-resolve' && + (args.importer.includes('/scopes/') || args.importer.includes('node_modules/@teambit')) && + // ignore templates we want to keep it as is + !args.importer.includes('/templates/') + ) { + if (args.path.startsWith('@teambit')) { + return handleModulePath(args, bundleDir); + } + if (args.path.startsWith('.')) { + return handleRelativePath(args, bundleDir); + } + } + return undefined; +} + +function resolveRelativePath(filePath: string) { + try { + const resolvedFilePath = require.resolve(filePath); + return resolvedFilePath; + } catch { + const resolvedFilePath = require.resolve(`${filePath}.js`); + return resolvedFilePath; + } +} + +async function handleRelativePath(args: OnResolveArgs, bundleDir: string) { + // const parsed = parse(args.path); + const { componentName, relativePath, scopeName } = await parseArgs(args); + // const packageDirName = getPackageDirName(args.resolveDir); + const packageDirName = `@teambit/${componentName}`; + // const origFilePath = join(args.resolveDir, args.path); + // const relativePath = getFilePathRelativeToPackage(args.resolveDir, args.path); + const origFilePath = join(packageDirName, relativePath); + // const targetDirName = getTargetDirName(args.resolveDir); + const targetDirName = `${scopeName}.${componentName}`; + // const targetDir = join(bundleDir, targetDirName, parsed.dir); + const targetDir = join(bundleDir, targetDirName, dirname(relativePath)); + await fs.ensureDir(targetDir); + const resolvedFilePath = resolveRelativePath(origFilePath); + const copyTarget = join(targetDir, basename(resolvedFilePath)); + await fs.copyFile(resolvedFilePath, copyTarget); + // const newPath = replaceRelativePath(targetDirName, parsed); + const newPath = `./${targetDirName}/${relativePath}`; + return { + path: newPath, + namespace: 'bit-config-file', + external: true, + }; +} + +async function parseArgs(args: OnResolveArgs): Promise { + if (args.resolveDir.includes('/scopes/')) { + return parseArgsFromSrc(args); + } + return parseArgsFromNodeModules(args); +} +async function parseArgsFromNodeModules(args: OnResolveArgs): Promise { + const resolveDir = args.resolveDir; + const filePath = args.path; + const parts = resolveDir.split('/@teambit/'); + const idParts = parts[1].split('/'); + const componentName = idParts[0]; + const componentDir = join(parts[0], '@teambit', componentName); + const relativeResolvedDir = resolveDir.replace(`${componentDir}/`, ''); + const relativePath = join(relativeResolvedDir, filePath.replace('./', '')); + const packageJsonPath = join(componentDir, 'package.json'); + const jsonValue = await fs.readJson(packageJsonPath); + const scopeName = jsonValue.componentId.scope.replace('teambit.', ''); + return { + scopeName, + componentName, + relativePath, + }; +} + +function parseArgsFromSrc(args: OnResolveArgs): ParsedArgs { + const resolveDir = args.resolveDir; + const filePath = args.path; + const parts = resolveDir.split('/scopes/'); + if (parts.length !== 2) { + throw new Error('unable to find scopes dir'); + } + const idParts = parts[1].split('/'); + const scopeName = idParts[0]; + const componentName = idParts[1]; + let relativePath = filePath; + if (idParts.length > 2) { + relativePath = join(idParts.slice(2).join('/'), filePath); + } + return { + scopeName, + componentName, + relativePath: relativePath.replace('./', ''), + }; +} + +async function handleModulePath(args: OnResolveArgs, bundleDir: string) { + const resolvedFilePath = require.resolve(args.path); + const parsed = parse(args.path); + const targetDir = join(bundleDir, 'node_modules', parsed.dir); + await fs.ensureDir(targetDir); + await fs.copyFile(resolvedFilePath, join(targetDir, basename(resolvedFilePath))); + return { + // Keep the path as-is + path: args.path, + namespace: 'bit-config-file', + external: true, + }; +} + +export const configFilesEsbuildPlugin = (bundleDir: string) => { + return { + name: 'config-files', + setup(build) { + // Intercept import paths starting with "http:" and "https:" so + // esbuild doesn't attempt to map them to a file system location. + // Tag them with the "http-url" namespace to associate them with + // this plugin. + build.onResolve({ filter: /jest.config$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /jest.cjs.config$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /jest.base.config$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + + build.onResolve({ filter: /jest.worker$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + + build.onResolve({ filter: /eslintrc.js$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + + build.onResolve({ filter: /prettier.config.js$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + + build.onResolve({ filter: /asset.d.ts$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /style.d.ts$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + + build.onResolve({ filter: /tsconfig.json$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /tsconfig.cjs.json$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /refreshOverlayInterop$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /webpackHotDevClient$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /mount$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /html-docs-app$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /\/preview.preview.runtime$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /setupTests$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /css-transform$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /file-transform$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /cjs-transformer$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /esm-transformer$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /svg-transformer$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + build.onResolve({ filter: /file-mock.js$/ }, (args) => { + return handleConfigFile(args, bundleDir); + }); + }, + }; +}; diff --git a/scopes/harmony/bit/bundle/copy-files-of-core-aspects.ts b/scopes/harmony/bit/bundle/copy-files-of-core-aspects.ts new file mode 100644 index 000000000000..40b6f21530cd --- /dev/null +++ b/scopes/harmony/bit/bundle/copy-files-of-core-aspects.ts @@ -0,0 +1,84 @@ +import { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator'; +import { getCoreAspectPackageName } from '@teambit/aspect-loader'; +import fs from 'fs-extra'; +import { join } from 'path'; + +type Item = { + paths: string[]; + targets: string[]; +}; + +const FILES_TO_COPY = { + 'teambit.react/react': [ + { + paths: ['jest'], + // package - copy to "rootOutDir/node_modules/packageName" + // configs-dir - "rootOutDir/bundle-dir/{scopeName}.{aspectName}" + targets: ['package', 'configs-dir'], + }, + ], +}; + +let wsRootDir: string; + +async function loadWsRootDir() { + const consumerInfo = await getWorkspaceInfo(process.cwd()); + if (!consumerInfo) throw new Error('unable to find consumer'); + wsRootDir = consumerInfo.path; + return consumerInfo.path; +} + +export async function copyFilesOfCoreAspects(rootOutDir: string, bundleDir: string) { + await loadWsRootDir(); + const coreAspectsIds = Object.keys(FILES_TO_COPY); + const generateOneAspectP = coreAspectsIds.map((id) => { + const packageName = getCoreAspectPackageName(id); + return handleOneAspect(id, rootOutDir, bundleDir, packageName); + }); + return Promise.all(generateOneAspectP); +} + +async function handleOneAspect(aspectId: string, rootOutDir: string, bundleDir: string, packageName: string) { + const items = FILES_TO_COPY[aspectId]; + const srcDir = join(wsRootDir, 'node_modules', packageName); + const packageTargetDir = join(rootOutDir, 'node_modules', packageName); + const configDirName = getConfigDirName(aspectId); + const configDirTargetDir = join(bundleDir, configDirName); + await Promise.all( + items.map(async (item) => { + return handleOneItem(item, srcDir, packageTargetDir, configDirTargetDir); + }) + ); +} + +function getConfigDirName(aspectId: string): string { + const parts = aspectId.split('/'); + const [, scopeName] = parts[0].split('.'); + return `${scopeName}.${parts[1]}`; +} + +async function handleOneItem(item: Item, srcDir: string, packageTargetDir: string, configDirTargetDir: string) { + const { paths, targets } = item; + const copyP = paths.flatMap((path) => { + return targets.map((target) => { + if (target === 'package') { + return handleOnePath(srcDir, packageTargetDir, path); + } + if (target === 'configs-dir') { + return handleOnePath(srcDir, configDirTargetDir, path); + } + return Promise.reject(new Error(`unknown target ${target}`)); + }); + }); + return Promise.all(copyP); +} + +async function handleOnePath(srcDir: string, targetDir: string, path: string) { + const srcPath = join(srcDir, path); + const targetPath = join(targetDir, path); + const exists = await fs.pathExists(targetPath); + if (exists) { + await fs.remove(targetPath); + } + return fs.copy(srcPath, targetPath, { dereference: true }); +} diff --git a/scopes/harmony/bit/bundle/copy-other-files.ts b/scopes/harmony/bit/bundle/copy-other-files.ts new file mode 100644 index 000000000000..478467c1ffee --- /dev/null +++ b/scopes/harmony/bit/bundle/copy-other-files.ts @@ -0,0 +1,42 @@ +import { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator'; +import fs from 'fs-extra'; +import { basename, join } from 'path'; +import globby from 'globby'; + +const PATTERNS_TO_COPY = ['node_modules/typescript/lib/*.d.ts']; + +let wsRootDir: string; + +async function loadWsRootDir() { + const consumerInfo = await getWorkspaceInfo(process.cwd()); + if (!consumerInfo) throw new Error('unable to find consumer'); + wsRootDir = consumerInfo.path; + return consumerInfo.path; +} + +export async function copyOtherFiles(bundleDir: string) { + await loadWsRootDir(); + const copyP = PATTERNS_TO_COPY.map((file) => { + return handleOnePattern(wsRootDir, bundleDir, file); + }); + return Promise.all(copyP); +} + +async function handleOnePattern(srcDir: string, targetDir: string, pattern: string) { + const files = await globby(pattern, { cwd: srcDir }); + return Promise.all( + files.map((file) => { + return handleOnePath(srcDir, targetDir, file); + }) + ); +} + +async function handleOnePath(srcDir: string, targetDir: string, path: string) { + const srcPath = join(srcDir, path); + const targetPath = join(targetDir, basename(path)); + const exists = await fs.pathExists(targetPath); + if (exists) { + await fs.remove(targetPath); + } + return fs.copy(srcPath, targetPath, { dereference: true }); +} diff --git a/scopes/harmony/bit/bundle/create-package-json.ts b/scopes/harmony/bit/bundle/create-package-json.ts new file mode 100644 index 000000000000..b9c2ede25fcb --- /dev/null +++ b/scopes/harmony/bit/bundle/create-package-json.ts @@ -0,0 +1,145 @@ +import findUp from 'find-up'; +import { join } from 'path'; +import { get } from 'lodash'; +import fs from 'fs-extra'; +import { parse } from 'comment-json'; +import { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator'; +import { externals } from './externals'; + +let wsJsonc: any; +let packageJson: any; + +async function getWsRootDir() { + const consumerInfo = await getWorkspaceInfo(process.cwd()); + if (!consumerInfo) throw new Error('unable to find consumer'); + return consumerInfo.path; +} + +function getPackageJsonPath(wsRootDir: string) { + return join(wsRootDir, 'package.json'); +} + +function getWorkspaceJsoncPath(wsRootDir: string) { + return join(wsRootDir, 'workspace.jsonc'); +} + +function loadPackageJson(wsRootDir: string) { + const packageJsonPath = getPackageJsonPath(wsRootDir); + // eslint-disable-next-line import/no-dynamic-require, global-require + const pkgJson = require(packageJsonPath); + packageJson = pkgJson; +} + +function loadWsJsonc(wsRootDir: string) { + const wsJsoncPath = getWorkspaceJsoncPath(wsRootDir); + // eslint-disable-next-line import/no-dynamic-require, global-require + const content = fs.readFileSync(wsJsoncPath, 'utf8'); + const parsed = parse(content); + wsJsonc = parsed; +} + +function resolveFromWsJsonc(packageName: string): string | undefined { + const wsJsoncPolicy = wsJsonc['teambit.dependencies/dependency-resolver'].policy; + const wsJsoncDependencies = wsJsoncPolicy.dependencies; + const wsJsoncPeerDependencies = wsJsoncPolicy.peerDependencies; + if (!wsJsoncPolicy) return undefined; + const val = wsJsoncDependencies[packageName] || wsJsoncPeerDependencies[packageName]; + if (!val) return undefined; + const packageVersion = typeof val === 'string' ? val : val.version; + return packageVersion; +} + +function resolveFromPackageJson(packageName: string): string | undefined { + const packageVersion = + get(packageJson, ['dependencies', packageName]) || + get(packageJson, ['devDependencies', packageName]) || + get(packageJson, ['peerDependencies', packageName]); + return packageVersion; +} + +async function resolveFromNodeModules(packageName: string): Promise { + try { + const resolvedPath = require.resolve(packageName); + if (!resolvedPath) return undefined; + const packageJsonPath = findUp.sync('package.json', { cwd: resolvedPath }); + if (!packageJsonPath) return undefined; + // eslint-disable-next-line import/no-dynamic-require, global-require + const pkgJson = require(packageJsonPath); + if (pkgJson.name !== packageName) return undefined; + return pkgJson.version; + } catch { + return undefined; + } +} + +function resolveHardCoded(packageName: string): string | undefined { + // TODO: resolve this in a better way + const hardCoded = { + assert: '2.0.0', + util: '0.12.3', + url: '0.11.0', + string_decoder: '1.3.0', + punycode: '2.1.1', + 'react-app-polyfill': '1.0.6', + 'identity-obj-proxy': '3.0.0', + uuid: '^10.0.0', + 'babel-preset-jest': '29.2.0', + espree: '9.6.1', + '@bitdev/react.webpack.refresh-overlay': '0.0.2', + '@surma/rollup-plugin-off-main-thread': '2.2.3', + }; + return hardCoded[packageName]; +} + +async function resolveExternalVersion(packageName: string) { + const hardCodedVersion = resolveHardCoded(packageName); + if (hardCodedVersion) return hardCodedVersion; + const wsJsoncVersion = resolveFromWsJsonc(packageName); + if (wsJsoncVersion) return wsJsoncVersion; + const packageJsonVersion = resolveFromPackageJson(packageName); + if (packageJsonVersion) return packageJsonVersion; + const nodeModulesVersion = await resolveFromNodeModules(packageName); + if (nodeModulesVersion) return nodeModulesVersion; + return undefined; +} + +const getPackageName = (packageName: string) => { + const parts = packageName.split('/'); + if (parts.length === 1) return parts[0]; + if (!parts[0].startsWith('@')) return parts[0]; + return `${parts[0]}/${parts[1]}`; +}; + +// function getPkgConfig() { +// const pkgConfig = { +// scripts: 'build/**/*.js', +// assets: 'views/**/*', +// targets: ['latest-macos-arm64'], +// outputPath: 'pkg-bundle', +// }; +// return pkgConfig; +// } + +export async function generatePackageJson(bundleDir: string, _bundleDirName: string, _jsAppFile: string) { + const wsRootDir = await getWsRootDir(); + loadPackageJson(wsRootDir); + loadWsJsonc(wsRootDir); + const deps = {}; + const depsP = externals.map(async (packageName) => { + const name = getPackageName(packageName); + const version = await resolveExternalVersion(name); + if (!version) { + console.log(`unable to resolve version for ${name}`); + return; + } + deps[name] = version; + }); + await Promise.all(depsP); + const finalPackageJson = { + name: 'bundle', + version: '0.0.0', + dependencies: deps, + }; + const packageJsonPath = join(bundleDir, 'package.json'); + fs.writeFileSync(packageJsonPath, JSON.stringify(finalPackageJson, null, 2)); +} diff --git a/scopes/harmony/bit/bundle/esbuild-plugin-time.ts b/scopes/harmony/bit/bundle/esbuild-plugin-time.ts new file mode 100644 index 000000000000..ade1178ff04d --- /dev/null +++ b/scopes/harmony/bit/bundle/esbuild-plugin-time.ts @@ -0,0 +1,28 @@ +// Based on https://github.com/DasRed/esbuild-plugin-time/blob/main/src/index.js +import chalk from 'chalk'; + +export const timeEsbuildPlugin = (name) => { + return { + name: 'Log', + setup(build) { + let time; + + build.onStart(() => { + time = new Date(); + if (name) { + console.log(`Build started for ${chalk.green(name)}`); + } else { + console.log(`Build started`); + } + }); + + build.onEnd(() => { + if (name) { + console.log(`Build ended ${chalk.green(name)}: ${chalk.yellow(`${new Date() - time}ms`)}`); + } else { + console.log(`Build ended: ${chalk.yellow(`${new Date() - time}ms`)}`); + } + }); + }, + }; +}; diff --git a/scopes/harmony/bit/bundle/esbuild.ts b/scopes/harmony/bit/bundle/esbuild.ts new file mode 100644 index 000000000000..56fd3e6c87c4 --- /dev/null +++ b/scopes/harmony/bit/bundle/esbuild.ts @@ -0,0 +1,86 @@ +import { build } from 'esbuild'; +import ignorePlugin from 'esbuild-plugin-ignore'; +import { join } from 'path'; +import { configFilesEsbuildPlugin } from './config-files-esbuild-plugin'; +import { timeEsbuildPlugin } from './esbuild-plugin-time'; +import { externals } from './externals'; + +export function runEsbuild(outDir: string, appFile: string) { + // const _outfile = join('/Users/giladshoham/dev/temp/bundle-bit/output', `${appFile}.js`); + const _outfile = join(outDir, appFile); + // const _outfile = join('/Users/giladshoham/dev/temp/bundle-bit/output', `test-app.js`); + return build({ + define: { + // 'process.env.JSON_LOGS': 'true', + 'process.env.BIT_LOG': `'debug'`, + // 'import_meta_url': 'import_meta_url', + // 'import_meta.url': 'import_meta_url', + }, + entryPoints: ['/Users/giladshoham/dev/bit/bit/scopes/harmony/bit/app.ts'], + // entryPoints: ['/Users/giladshoham/dev/bit/bit/node_modules/@teambit/bit/dist/app.js'], + // entryPoints: ['/Users/giladshoham/dev/temp/bundle-bit/node_modules/@my-scope/bit-bundle/dist/test-app.js'], + // entryPoints: ['/Users/giladshoham/dev/temp/bundle-bit/my-scope/bit-bundle/test-app.ts'] + bundle: true, + logLevel: 'error', + platform: 'node', + // minify: true, + metafile: true, + // TODO: maybe enable sourcemap later + // sourcemap: true, + mainFields: ['main', 'module'], + format: 'cjs', + keepNames: true, + outfile: _outfile, + // inject: [join(__dirname, './import-meta-url.js')], + + external: externals, + plugins: [ + // sassPlugin(), + ignorePlugin([ + // { resourceRegExp: /(.*)\.ui\.runtime\.*/g }, + { resourceRegExp: /\.(s[ac]ss|css)$/ }, + { resourceRegExp: /\.(mdx)$/ }, + { resourceRegExp: /\.(md)$/ }, + // { resourceRegExp: new RegExp('^@swc/core') }, + { resourceRegExp: new RegExp('^jest-resolve') }, + { resourceRegExp: new RegExp('^@vue/compiler-sfc') }, + { resourceRegExp: new RegExp('^batch') }, + { resourceRegExp: new RegExp('^../build/Release/cpufeatures.node') }, + { resourceRegExp: new RegExp('^pnpapi') }, + // { resourceRegExp: new RegExp('^shelljs') }, + // { resourceRegExp: new RegExp('^react') }, + // { resourceRegExp: new RegExp('^react-router-dom') }, + { resourceRegExp: new RegExp('^esbuild') }, + // { resourceRegExp: new RegExp('^../prelude/bootstrap.js') }, + // { resourceRegExp: new RegExp('^./html.docs.mdx') }, + // { resourceRegExp: new RegExp('^stream-browserify') }, + // { resourceRegExp: new RegExp('^expose-loader') }, + // { resourceRegExp: new RegExp('^querystring-es3') }, + // { resourceRegExp: new RegExp('^assert/') }, + // { resourceRegExp: new RegExp('^buffer/') }, + // { resourceRegExp: new RegExp('^constants-browserify') }, + // { resourceRegExp: new RegExp('^crypto-browserify') }, + // { resourceRegExp: new RegExp('^domain-browser') }, + // { resourceRegExp: new RegExp('^stream-http') }, + // { resourceRegExp: new RegExp('^https-browserify') }, + // { resourceRegExp: new RegExp('^os-browserify/browser') }, + // { resourceRegExp: new RegExp('^path-browserify') }, + // { resourceRegExp: new RegExp('^punycode/') }, + // { resourceRegExp: new RegExp('^process/browser') }, + // { resourceRegExp: new RegExp('^querystring-es3') }, + // { resourceRegExp: new RegExp('^stream-browserify') }, + // { resourceRegExp: new RegExp('^string_decoder/') }, + // { resourceRegExp: new RegExp('^util/') }, + // { resourceRegExp: new RegExp('^timers-browserify') }, + // { resourceRegExp: new RegExp('^tty-browserify') }, + // { resourceRegExp: new RegExp('^url/') }, + // { resourceRegExp: new RegExp('^util/') }, + // { resourceRegExp: new RegExp('^vm-browserify') }, + // { resourceRegExp: new RegExp('^browserify-zlib') }, + ]), + configFilesEsbuildPlugin(outDir), + timeEsbuildPlugin('Bit bundle'), + ], + loader: { '.png': 'binary', '.node': 'binary' }, + }); +} diff --git a/scopes/harmony/bit/bundle/externals.ts b/scopes/harmony/bit/bundle/externals.ts new file mode 100644 index 000000000000..2cb054f5ef10 --- /dev/null +++ b/scopes/harmony/bit/bundle/externals.ts @@ -0,0 +1,115 @@ +export const externals = [ + // 'jest.worker', + 'browserslist', + 'yoga-layout', + 'yoga-layout-prebuilt', + '@surma/rollup-plugin-off-main-thread', + '@babel/preset-react', + 'ink', + 'camelcase', + 'rrweb-cssom', + 'canvas', + 'style-loader', + 'mini-css-extract-plugin', + '@prerenderer/renderer-jsdom', + '@pmmmwh/react-refresh-webpack-plugin', + '@teambit/react.babel.bit-react-transformer', + 'source-map-loader', + 'babel-loader', + 'react-refresh/babel', + 'babel-loader', + '@babel/core', + '@testing-library/jest-dom', + '@babel/runtime', + '@babel/preset-react', + '@babel/preset-env', + '@teambit/mdx.modules.mdx-loader', + '@swc/core', + '@babel/plugin-proposal-class-properties', + '@babel/plugin-proposal-decorators', + '@babel/plugin-proposal-object-rest-spread', + '@babel/plugin-syntax-typescript', + '@babel/plugin-transform-modules-commonjs', + '@babel/plugin-transform-runtime', + '@babel/preset-typescript', + '@mdx-js/react', + '@teambit/mdx.ui.mdx-scope-context', + '@teambit/node/jest/jest.config', + '@typescript-eslint/parser', + 'identity-obj-proxy', + 'uuid', + 'jest-environment-jsdom', + 'react-app-polyfill/jsdom', + 'assert/', + 'babel-jest', + 'babel-plugin-istanbul', + 'babel-plugin-transform-typescript-metadata', + 'babel-preset-current-node-syntax', + 'babel-preset-jest', + 'babel-preset-react-app/webpack-overrides', + 'browserify-zlib', + 'buffer/', + 'constants-browserify', + 'crypto-browserify', + 'css-loader', + 'domain-browser', + 'eslint-config-airbnb-typescript', + 'eslint-config-prettier', + 'espree', + 'expose-loader', + 'https-browserify', + 'jest', + 'jest-circus/runner', + 'jest-jasmine2', + 'less-loader', + 'os-browserify/browser', + 'path-browserify', + 'postcss-flexbugs-fixes', + 'postcss-loader', + 'postcss-normalize', + 'process/browser', + 'punycode/', + 'querystring-es3', + 'react', + 'react-dom', + 'react-dom/server', + 'react/jsx-dev-runtime.js', + 'react/jsx-runtime.js', + 'resolve-url-loader', + 'sass-loader', + 'stream-browserify', + 'stream-http', + 'string_decoder/', + 'timers-browserify', + 'tty-browserify', + 'url/', + 'util/', + 'vm-browserify', + 'watchpack', + 'webpack/hot/dev-server', + 'webpack/hot/only-dev-server', + 'source-map-support', + 'css-minimizer-webpack-plugin', + 'html-webpack-plugin', + 'jest-worker', + 'jest-environment-node', + 'mocha', + 'rollup-plugin-terser', + 'terser-webpack-plugin', + 'uglify-js', + 'uid-number', + 'webpack-dev-server', + '@svgr/webpack', + 'new-url-loader', + '@teambit/react.eslint-config-bit-react', + '@teambit/react.ui.docs-app', + '@teambit/react.ui.compositions-app', + 'babel-preset-react-app', + 'tippy.js', + '@babel/plugin-transform-object-rest-spread', + '@babel/plugin-transform-class-properties', + '@bitdev/react.webpack.refresh-overlay', + 'events', + // 'esbuild' + // 'mime' +]; diff --git a/scopes/harmony/bit/bundle/generate-core-aspects-exports.ts b/scopes/harmony/bit/bundle/generate-core-aspects-exports.ts new file mode 100644 index 000000000000..45245894da68 --- /dev/null +++ b/scopes/harmony/bit/bundle/generate-core-aspects-exports.ts @@ -0,0 +1,33 @@ +import camelcase from 'camelcase'; +import { getCoreAspectName, getCoreAspectPackageName } from '@teambit/aspect-loader'; +import fs from 'fs-extra'; +import { join } from 'path'; + +import { coreAspectsIds } from '../core-aspects-ids'; + +const FILE_NAME = 'core-aspects-exports.ts'; +// const filePath = join('..', FILE_NAME); +// TODO: make it not hard coded +const filePath = join('/Users/giladshoham/dev/bit/bit/scopes/harmony/bit', FILE_NAME); + +export function generateCoreAspectsBarrelFile() { + const exports = generateExports(); + const autoGeneratedMessage = `// This file is auto generated by generate-core-aspects-exports.ts`; + const content = `${autoGeneratedMessage}\n${exports}`; + return fs.outputFile(filePath, content); +} + +function generateExports(): string { + const exportsLines = coreAspectsIds.map((id) => { + const name = getCoreAspectName(id); + const packageName = getCoreAspectPackageName(id); + return generateOneExport(name, packageName); + }); + exportsLines.push(generateOneExport('legacy', '@teambit/legacy')); + exportsLines.push(generateOneExport('harmony', '@teambit/harmony')); + return exportsLines.join('\n'); +} + +function generateOneExport(name, packageName) { + return `export * as ${camelcase(name)} from '${packageName}';`; +} diff --git a/scopes/harmony/bit/bundle/generate-core-aspects-modules.ts b/scopes/harmony/bit/bundle/generate-core-aspects-modules.ts new file mode 100644 index 000000000000..a49d9a4f3a91 --- /dev/null +++ b/scopes/harmony/bit/bundle/generate-core-aspects-modules.ts @@ -0,0 +1,75 @@ +import { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator'; +import camelcase from 'camelcase'; +import { getCoreAspectName, getCoreAspectPackageName } from '@teambit/aspect-loader'; +import fs from 'fs-extra'; +import { join } from 'path'; + +import { coreAspectsIds } from '../core-aspects-ids'; + +let wsRootDir: string; + +async function loadWsRootDir() { + const consumerInfo = await getWorkspaceInfo(process.cwd()); + if (!consumerInfo) throw new Error('unable to find consumer'); + wsRootDir = consumerInfo.path; + return consumerInfo.path; +} + +export async function generateCoreAspectsModules(bundleDir: string, appName: string) { + await loadWsRootDir(); + const generateOneAspectP = coreAspectsIds.map((id) => { + const name = getCoreAspectName(id); + const packageName = getCoreAspectPackageName(id); + return handleOneAspect(bundleDir, name, packageName, appName); + }); + generateOneAspectP.push(handleOneAspect(bundleDir, 'legacy', '@teambit/legacy', appName)); + generateOneAspectP.push(handleOneAspect(bundleDir, 'harmony', '@teambit/harmony', appName)); + return Promise.all(generateOneAspectP); +} + +async function handleOneAspect(bundleDir: string, name: string, packageName: string, appName: string) { + const dirPath = join(bundleDir, 'node_modules', packageName); + await fs.ensureDir(dirPath); + await generateIndexFile(dirPath, name, appName); + await generateEsmMjsFile(dirPath, packageName); + await generatePackageJson(dirPath, packageName); +} + +async function generateIndexFile(dirPath: string, name: string, appName: string) { + const indexFilePath = join(dirPath, 'index.js'); + const indexFileContent = getIndexContent(name, appName); + return fs.outputFile(indexFilePath, indexFileContent); +} + +async function generateEsmMjsFile(dirPath: string, packageName: string) { + const esmMjsPath = join(wsRootDir, 'node_modules', packageName, 'esm.mjs'); + const exists = await fs.pathExists(esmMjsPath); + if (exists) { + const targetPath = join(dirPath, 'esm.mjs'); + return fs.copyFile(esmMjsPath, targetPath); + } + return Promise.resolve(); +} + +async function generatePackageJson(dirPath: string, packageName: string) { + const packageJsonPath = join(wsRootDir, 'node_modules', packageName, 'package.json'); + const targetPath = join(dirPath, 'package.json'); + const origPackageJson = await fs.readJson(packageJsonPath); + origPackageJson.main = 'index.js'; + if (origPackageJson.exports && origPackageJson.exports['.']) { + origPackageJson.exports['.'].node.require = './index.js'; + origPackageJson.exports['.'].node.import = './esm.mjs'; + origPackageJson.exports['.'].default = './index.js'; + } + return fs.writeJson(targetPath, origPackageJson, { spaces: 2 }); +} + +function getIndexContent(name: string, appName: string) { + const camelName = camelcase(name); + return ` +// This file is auto generated by generate-core-aspects-modules.ts +Object.defineProperty(exports, "__esModule", { value: true }); +const { ${camelName} } = require("../../${appName}"); +module.exports = ${camelName}; +`; +} diff --git a/scopes/harmony/bit/bundle/generate-npmrc.ts b/scopes/harmony/bit/bundle/generate-npmrc.ts new file mode 100644 index 000000000000..80d1b0360ef7 --- /dev/null +++ b/scopes/harmony/bit/bundle/generate-npmrc.ts @@ -0,0 +1,10 @@ +import { ensureDirSync, writeFileSync } from 'fs-extra'; +import { join } from 'path'; + +const content = `@teambit:registry=https://node-registry.bit.cloud`; + +export function generateNpmrc(bundleDir: string) { + ensureDirSync(bundleDir); + const filePath = join(bundleDir, '.npmrc'); + writeFileSync(filePath, content); +} diff --git a/scopes/harmony/bit/bundle/generate-sea-config.ts b/scopes/harmony/bit/bundle/generate-sea-config.ts new file mode 100644 index 000000000000..a2c7a227f510 --- /dev/null +++ b/scopes/harmony/bit/bundle/generate-sea-config.ts @@ -0,0 +1,15 @@ +import fs from 'fs-extra'; +import { join } from 'path'; + +export async function generateSeaConfig(bundleDir: string, jsAppFile: string, blobAppFile: string) { + const config = { + main: join(bundleDir, jsAppFile), + output: join(bundleDir, blobAppFile), + disableExperimentalSEAWarning: true, // Default: false + useSnapshot: false, // Default: false + useCodeCache: true, // Default: false + }; + + const seaConfigPath = join(bundleDir, 'sea-config.json'); + fs.writeJSONSync(seaConfigPath, config, { spaces: 2 }); +} diff --git a/scopes/harmony/bit/bundle/readme.md b/scopes/harmony/bit/bundle/readme.md new file mode 100644 index 000000000000..4c93c291b1d2 --- /dev/null +++ b/scopes/harmony/bit/bundle/readme.md @@ -0,0 +1,42 @@ +## create bundle: + +``` +node node_modules/@teambit/bit/dist/bundle/bundle.js > bundle.result.json +``` + +## Use the bundle + +``` +node /bit/bundle/bit.app.js +``` + +## structure + +1. generate-npmrc.ts - generate an npmrc file with the bit registry + (so you can install external packages with regular pcaakge manager) +1. create-package-json.ts - generate a package.json file with all external packages +1. bundle.ts - main file to generate the bundle +1. esbuild.ts - running the esbuild bundler +1. generate-core-aspects-exports - This will generate a file that exports all the core aspects + +## binary + +1. node --experimental-sea-config sea-config.json +1. cp $(command -v node) bit-app +1. codesign --remove-signature bit-app +1. npx postject bit-app NODE_SEA_BLOB bit.app.blob \ + --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \ + --macho-segment-name NODE_SEA +1. codesign --sign - bit-app + +## binary script + +``` +node --experimental-sea-config sea-config.json +cp $(command -v node) bit-app +codesign --remove-signature bit-app +npx postject bit-app NODE_SEA_BLOB bit.app.blob \ + --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \ + --macho-segment-name NODE_SEA +codesign --sign - bit-app +``` diff --git a/scopes/harmony/bit/bundle/tsup.ts b/scopes/harmony/bit/bundle/tsup.ts new file mode 100644 index 000000000000..7f119806cf7f --- /dev/null +++ b/scopes/harmony/bit/bundle/tsup.ts @@ -0,0 +1,41 @@ +import ignorePlugin from 'esbuild-plugin-ignore'; +import { build, Options } from 'tsup'; +import { configFilesEsbuildPlugin } from './config-files-esbuild-plugin'; +import { timeEsbuildPlugin } from './esbuild-plugin-time'; +import { externals } from './externals'; + +export async function runTsup(outDir: string, _appFile: string) { + const opts: Options = { + entry: ['/Users/giladshoham/dev/bit/bit/scopes/harmony/bit/app.ts'], + splitting: false, + sourcemap: true, + clean: true, + dts: true, + format: ['cjs'], + target: 'node18', + outDir, + platform: 'node', + external: externals, + keepNames: true, + esbuildPlugins: [ + ignorePlugin([ + // { resourceRegExp: /(.*)\.ui\.runtime\.*/g }, + { resourceRegExp: /\.(s[ac]ss|css)$/ }, + { resourceRegExp: /\.(mdx)$/ }, + { resourceRegExp: /\.(md)$/ }, + { resourceRegExp: new RegExp('^jest-resolve') }, + { resourceRegExp: new RegExp('^@vue/compiler-sfc') }, + { resourceRegExp: new RegExp('^batch') }, + { resourceRegExp: new RegExp('^../build/Release/cpufeatures.node') }, + { resourceRegExp: new RegExp('^pnpapi') }, + { resourceRegExp: new RegExp('^esbuild') }, + ]), + configFilesEsbuildPlugin(outDir), + timeEsbuildPlugin('Bit bundle'), + ], + esbuildOptions(options, _context) { + options.define['process.env.BIT_LOG'] = '"debug"'; + }, + }; + return build(opts); +} diff --git a/scopes/harmony/bit/core-aspects-exports.ts b/scopes/harmony/bit/core-aspects-exports.ts new file mode 100644 index 000000000000..f54faedd85e7 --- /dev/null +++ b/scopes/harmony/bit/core-aspects-exports.ts @@ -0,0 +1,105 @@ +// This file is auto generated by generate-core-aspects-exports.ts +export * as bit from '@teambit/bit'; +export * as config from '@teambit/config'; +export * as configMerger from '@teambit/config-merger'; +export * as aspectLoader from '@teambit/aspect-loader'; +export * as cli from '@teambit/cli'; +export * as devFiles from '@teambit/dev-files'; +export * as workspace from '@teambit/workspace'; +export * as workspaceConfigFiles from '@teambit/workspace-config-files'; +export * as install from '@teambit/install'; +export * as eslint from '@teambit/eslint'; +export * as prettier from '@teambit/prettier'; +export * as compiler from '@teambit/compiler'; +export * as linter from '@teambit/linter'; +export * as formatter from '@teambit/formatter'; +export * as component from '@teambit/component'; +export * as mdx from '@teambit/mdx'; +export * as readme from '@teambit/readme'; +export * as preview from '@teambit/preview'; +export * as componentSizer from '@teambit/component-sizer'; +export * as docs from '@teambit/docs'; +export * as yarn from '@teambit/yarn'; +export * as compositions from '@teambit/compositions'; +export * as globalConfig from '@teambit/global-config'; +export * as graphql from '@teambit/graphql'; +export * as pnpm from '@teambit/pnpm'; +export * as multiCompiler from '@teambit/multi-compiler'; +export * as ui from '@teambit/ui'; +export * as generator from '@teambit/generator'; +export * as envs from '@teambit/envs'; +export * as env from '@teambit/env'; +export * as graph from '@teambit/graph'; +export * as pubsub from '@teambit/pubsub'; +export * as dependencyResolver from '@teambit/dependency-resolver'; +export * as insights from '@teambit/insights'; +export * as isolator from '@teambit/isolator'; +export * as logger from '@teambit/logger'; +export * as pkg from '@teambit/pkg'; +export * as react from '@teambit/react'; +export * as worker from '@teambit/worker'; +export * as scope from '@teambit/scope'; +export * as tester from '@teambit/tester'; +export * as multiTester from '@teambit/multi-tester'; +export * as builder from '@teambit/builder'; +export * as variants from '@teambit/variants'; +export * as deprecation from '@teambit/deprecation'; +export * as express from '@teambit/express'; +export * as aspect from '@teambit/aspect'; +export * as webpack from '@teambit/webpack'; +export * as schema from '@teambit/schema'; +export * as reactRouter from '@teambit/react-router'; +export * as typescript from '@teambit/typescript'; +export * as panels from '@teambit/panels'; +export * as babel from '@teambit/babel'; +export * as node from '@teambit/node'; +export * as notifications from '@teambit/notifications'; +export * as bundler from '@teambit/bundler'; +export * as jest from '@teambit/jest'; +export * as cache from '@teambit/cache'; +export * as changelog from '@teambit/changelog'; +export * as code from '@teambit/code'; +export * as commandBar from '@teambit/command-bar'; +export * as sidebar from '@teambit/sidebar'; +export * as componentTree from '@teambit/component-tree'; +export * as sign from '@teambit/sign'; +export * as updateDependencies from '@teambit/update-dependencies'; +export * as export from '@teambit/export'; +export * as importer from '@teambit/importer'; +export * as harmonyUiApp from '@teambit/harmony-ui-app'; +export * as userAgent from '@teambit/user-agent'; +export * as application from '@teambit/application'; +export * as eject from '@teambit/eject'; +export * as html from '@teambit/html'; +export * as lanes from '@teambit/lanes'; +export * as forking from '@teambit/forking'; +export * as renaming from '@teambit/renaming'; +export * as newComponentHelper from '@teambit/new-component-helper'; +export * as componentLog from '@teambit/component-log'; +export * as clearCache from '@teambit/clear-cache'; +export * as mocha from '@teambit/mocha'; +export * as diagnostic from '@teambit/diagnostic'; +export * as status from '@teambit/status'; +export * as community from '@teambit/community'; +export * as cloud from '@teambit/cloud'; +export * as snapping from '@teambit/snapping'; +export * as merging from '@teambit/merging'; +export * as issues from '@teambit/issues'; +export * as refactoring from '@teambit/refactoring'; +export * as componentCompare from '@teambit/component-compare'; +export * as lister from '@teambit/lister'; +export * as dependencies from '@teambit/dependencies'; +export * as remove from '@teambit/remove'; +export * as mergeLanes from '@teambit/merge-lanes'; +export * as checkout from '@teambit/checkout'; +export * as componentWriter from '@teambit/component-writer'; +export * as apiReference from '@teambit/api-reference'; +export * as apiServer from '@teambit/api-server'; +export * as tracker from '@teambit/tracker'; +export * as mover from '@teambit/mover'; +export * as watcher from '@teambit/watcher'; +export * as stash from '@teambit/stash'; +export * as git from '@teambit/git'; +export * as ipcEvents from '@teambit/ipc-events'; +export * as legacy from '@teambit/legacy'; +export * as harmony from '@teambit/harmony'; diff --git a/scopes/harmony/bit/core-aspects-ids.ts b/scopes/harmony/bit/core-aspects-ids.ts new file mode 100644 index 000000000000..dd0af8620a23 --- /dev/null +++ b/scopes/harmony/bit/core-aspects-ids.ts @@ -0,0 +1,105 @@ +// TODO: combine this with the manifests somehow +export const coreAspectsIds = [ + 'teambit.harmony/bit', + 'teambit.harmony/config', + 'teambit.harmony/config-merger', + 'teambit.harmony/aspect-loader', + 'teambit.harmony/cli', + 'teambit.component/dev-files', + 'teambit.workspace/workspace', + 'teambit.workspace/workspace-config-files', + 'teambit.bit/install', + 'teambit.defender/eslint', + 'teambit.defender/prettier', + 'teambit.compilation/compiler', + 'teambit.defender/linter', + 'teambit.defender/formatter', + 'teambit.component/component', + 'teambit.mdx/mdx', + 'teambit.mdx/readme', + 'teambit.preview/preview', + 'teambit.component/component-sizer', + 'teambit.docs/docs', + 'teambit.dependencies/yarn', + 'teambit.compositions/compositions', + 'teambit.harmony/global-config', + 'teambit.harmony/graphql', + 'teambit.dependencies/pnpm', + 'teambit.compilation/multi-compiler', + 'teambit.ui-foundation/ui', + 'teambit.generator/generator', + 'teambit.envs/envs', + 'teambit.envs/env', + 'teambit.component/graph', + 'teambit.harmony/pubsub', + 'teambit.dependencies/dependency-resolver', + 'teambit.explorer/insights', + 'teambit.component/isolator', + 'teambit.harmony/logger', + 'teambit.pkg/pkg', + 'teambit.react/react', + 'teambit.harmony/worker', + 'teambit.scope/scope', + 'teambit.defender/tester', + 'teambit.defender/multi-tester', + 'teambit.pipelines/builder', + 'teambit.workspace/variants', + 'teambit.component/deprecation', + 'teambit.harmony/express', + 'teambit.harmony/aspect', + 'teambit.webpack/webpack', + 'teambit.semantics/schema', + 'teambit.ui-foundation/react-router', + 'teambit.typescript/typescript', + 'teambit.ui-foundation/panels', + 'teambit.compilation/babel', + 'teambit.harmony/node', + 'teambit.ui-foundation/notifications', + 'teambit.compilation/bundler', + 'teambit.defender/jest', + 'teambit.harmony/cache', + 'teambit.component/changelog', + 'teambit.component/code', + 'teambit.explorer/command-bar', + 'teambit.ui-foundation/sidebar', + 'teambit.component/component-tree', + 'teambit.scope/sign', + 'teambit.scope/update-dependencies', + 'teambit.scope/export', + 'teambit.scope/importer', + 'teambit.ui-foundation/harmony-ui-app', + 'teambit.ui-foundation/user-agent', + 'teambit.harmony/application', + 'teambit.workspace/eject', + 'teambit.html/html', + 'teambit.lanes/lanes', + 'teambit.component/forking', + 'teambit.component/renaming', + 'teambit.component/new-component-helper', + 'teambit.component/component-log', + 'teambit.bit/clear-cache', + 'teambit.defender/mocha', + 'teambit.harmony/diagnostic', + 'teambit.component/status', + 'teambit.community/community', + 'teambit.cloud/cloud', + 'teambit.component/snapping', + 'teambit.component/merging', + 'teambit.component/issues', + 'teambit.component/refactoring', + 'teambit.component/component-compare', + 'teambit.component/lister', + 'teambit.dependencies/dependencies', + 'teambit.component/remove', + 'teambit.lanes/merge-lanes', + 'teambit.component/checkout', + 'teambit.component/component-writer', + 'teambit.api-reference/api-reference', + 'teambit.harmony/api-server', + 'teambit.component/tracker', + 'teambit.component/mover', + 'teambit.workspace/watcher', + 'teambit.component/stash', + 'teambit.git/git', + 'teambit.harmony/ipc-events', +]; diff --git a/scopes/harmony/bit/load-bit.ts b/scopes/harmony/bit/load-bit.ts index 63bc0189f391..8694d5d03c80 100644 --- a/scopes/harmony/bit/load-bit.ts +++ b/scopes/harmony/bit/load-bit.ts @@ -22,7 +22,7 @@ import { import json from 'comment-json'; import userHome from 'user-home'; import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli'; -import { ConfigAspect, ConfigRuntime } from '@teambit/config'; +import { ConfigRuntime, getConfigAspect } from '@teambit/config'; import { Harmony, RuntimeDefinition, Extension } from '@teambit/harmony'; // TODO: expose this types from harmony (once we have a way to expose it only for node) import { Config } from '@teambit/harmony/dist/harmony-config'; @@ -45,16 +45,20 @@ import { logger } from '@teambit/legacy.logger'; import { ExternalActions } from '@teambit/legacy.scope-api'; import { readdir, readFile } from 'fs-extra'; import { resolve, join } from 'path'; -import { getAllCoreAspectsIds, isCoreAspect, manifestsMap } from './manifests'; +import { getAllCoreAspectsIds, isCoreAspect, getManifestsMap } from './manifests'; import { BitAspect } from './bit.aspect'; import { registerCoreExtensions } from './bit.main.runtime'; import { BitConfig } from './bit.provider'; import { EnvsAspect, EnvsMain } from '@teambit/envs'; import { GeneratorAspect, GeneratorMain } from '@teambit/generator'; +const manifestsMap = getManifestsMap(); + async function loadLegacyConfig(config: any) { - const harmony = await Harmony.load([ConfigAspect], ConfigRuntime.name, config.toObject()); - await harmony.run(async (aspect: Extension, runtime: RuntimeDefinition) => requireAspects(aspect, runtime)); + const aspectsToLoad = [getConfigAspect()]; + const harmony = await Harmony.load(aspectsToLoad, ConfigRuntime.name, config.toObject()); + // await harmony.run(async (aspect: Extension, runtime: RuntimeDefinition) => requireAspects(aspect, runtime)); + await harmony.run(); } async function getConfig(cwd = process.cwd()) { @@ -199,11 +203,11 @@ export async function requireAspects(aspect: Extension, runtime: RuntimeDefiniti } function getMainAspect() { - const mainAspectDir = getAspectDir(BitAspect.id); - let version: string | undefined; const packageName = getCoreAspectPackageName(BitAspect.id); - + let version: string | undefined; + let mainAspectDir = ''; try { + mainAspectDir = getAspectDir(BitAspect.id); // eslint-disable-next-line global-require const packageJson = require(`${mainAspectDir}/package.json`); version = packageJson.version; @@ -271,14 +275,17 @@ export async function loadBit(path = process.cwd()) { const loadCLIOnly = shouldLoadInSafeMode(); if (isClearCacheCommand()) aspectsToLoad.push(ClearCacheAspect); if (!loadCLIOnly) { - aspectsToLoad.push(BitAspect); + // aspectsToLoad.push(BitAspect); + aspectsToLoad.push(...Object.values(manifestsMap)); } if (shouldRunAsDaemon()) { logger.isDaemon = true; } const harmony = await Harmony.load(aspectsToLoad, MainRuntime.name, configMap); - await harmony.run(async (aspect: Extension, runtime: RuntimeDefinition) => requireAspects(aspect, runtime)); + // await harmony.run(async (aspect: Extension, runtime: RuntimeDefinition) => requireAspects(aspect, runtime)); + await harmony.run(); + if (loadCLIOnly) return harmony; const aspectLoader = harmony.get(AspectLoaderAspect.id); aspectLoader.setCoreAspects(Object.values(manifestsMap)); diff --git a/scopes/harmony/bit/manifests.ts b/scopes/harmony/bit/manifests.ts index 33cf1c32bbde..f34a6babd9ef 100644 --- a/scopes/harmony/bit/manifests.ts +++ b/scopes/harmony/bit/manifests.ts @@ -1,226 +1,429 @@ -import { AspectAspect } from '@teambit/aspect'; -import { AspectLoaderAspect } from '@teambit/aspect-loader'; -import { BuilderAspect } from '@teambit/builder'; -import { BundlerAspect } from '@teambit/bundler'; -import { CacheAspect } from '@teambit/cache'; -import { CLIAspect } from '@teambit/cli'; -import { CompilerAspect } from '@teambit/compiler'; -import { ComponentAspect } from '@teambit/component'; -import { CompositionsAspect } from '@teambit/compositions'; -import { ConfigAspect } from '@teambit/config'; -import { DependencyResolverAspect } from '@teambit/dependency-resolver'; -import { DeprecationAspect } from '@teambit/deprecation'; -import { DocsAspect } from '@teambit/docs'; -import { EnvsAspect } from '@teambit/envs'; -import { EnvAspect } from '@teambit/env'; -import { ExpressAspect } from '@teambit/express'; -import { YarnAspect } from '@teambit/yarn'; -import { GeneratorAspect } from '@teambit/generator'; -import { HarmonyUiAppAspect } from '@teambit/harmony-ui-app'; -import { GraphAspect } from '@teambit/graph'; -import { GraphqlAspect } from '@teambit/graphql'; -import { InsightsAspect } from '@teambit/insights'; -import { IsolatorAspect } from '@teambit/isolator'; -import { JestAspect } from '@teambit/jest'; -import { LoggerAspect } from '@teambit/logger'; -import { NodeAspect } from '@teambit/node'; -import { NotificationsAspect } from '@teambit/notifications'; -import { PanelUiAspect } from '@teambit/panels'; -import { PkgAspect } from '@teambit/pkg'; -import { PnpmAspect } from '@teambit/pnpm'; -import { PreviewAspect } from '@teambit/preview'; -import { ComponentSizerAspect } from '@teambit/component-sizer'; -import { ReactAspect } from '@teambit/react'; -import { ReactRouterAspect } from '@teambit/react-router'; -import { SchemaAspect } from '@teambit/schema'; -import { PubsubAspect } from '@teambit/pubsub'; -import { ScopeAspect } from '@teambit/scope'; -// import { StencilAspect } from '@teambit/stencil'; -import { TesterAspect } from '@teambit/tester'; -import { MultiTesterAspect } from '@teambit/multi-tester'; -import { TypescriptAspect } from '@teambit/typescript'; -import { BabelAspect } from '@teambit/babel'; -import { UIAspect } from '@teambit/ui'; -import { VariantsAspect } from '@teambit/variants'; -import { WebpackAspect } from '@teambit/webpack'; -import { WorkspaceAspect } from '@teambit/workspace'; -import { WorkspaceConfigFilesAspect } from '@teambit/workspace-config-files'; -import { InstallAspect } from '@teambit/install'; -import { LinterAspect } from '@teambit/linter'; -import { FormatterAspect } from '@teambit/formatter'; -import { ChangelogAspect } from '@teambit/changelog'; -import { CodeAspect } from '@teambit/code'; -import { CommandBarAspect } from '@teambit/command-bar'; -import { SidebarAspect } from '@teambit/sidebar'; -import { ComponentTreeAspect } from '@teambit/component-tree'; -import { DevFilesAspect } from '@teambit/dev-files'; -import { ESLintAspect } from '@teambit/eslint'; -import { PrettierAspect } from '@teambit/prettier'; -import { SignAspect } from '@teambit/sign'; -import { WorkerAspect } from '@teambit/worker'; -import { GlobalConfigAspect } from '@teambit/global-config'; -import { MultiCompilerAspect } from '@teambit/multi-compiler'; -import { MDXAspect } from '@teambit/mdx'; -import { ReadmeAspect } from '@teambit/readme'; -import { ApplicationAspect } from '@teambit/application'; -import { UpdateDependenciesAspect } from '@teambit/update-dependencies'; -import { ExportAspect } from '@teambit/export'; -import { ImporterAspect } from '@teambit/importer'; -import { EjectAspect } from '@teambit/eject'; -import { UserAgentAspect } from '@teambit/user-agent'; -import { HtmlAspect } from '@teambit/html'; -import { LanesAspect } from '@teambit/lanes'; -import { ForkingAspect } from '@teambit/forking'; -import { RenamingAspect } from '@teambit/renaming'; -import { ComponentLogAspect } from '@teambit/component-log'; -import { ClearCacheAspect } from '@teambit/clear-cache'; -import { DiagnosticAspect } from '@teambit/diagnostic'; -import { NewComponentHelperAspect } from '@teambit/new-component-helper'; -import { MochaAspect } from '@teambit/mocha'; -import { CommunityAspect } from '@teambit/community'; -import { CloudAspect } from '@teambit/cloud'; -import { StatusAspect } from '@teambit/status'; -import { SnappingAspect } from '@teambit/snapping'; -import { MergingAspect } from '@teambit/merging'; -import { IssuesAspect } from '@teambit/issues'; -import { RefactoringAspect } from '@teambit/refactoring'; -import { ComponentCompareAspect } from '@teambit/component-compare'; -import { ListerAspect } from '@teambit/lister'; -import { DependenciesAspect } from '@teambit/dependencies'; -import { RemoveAspect } from '@teambit/remove'; -import { MergeLanesAspect } from '@teambit/merge-lanes'; -import { CheckoutAspect } from '@teambit/checkout'; -import { APIReferenceAspect } from '@teambit/api-reference'; -import { ApiServerAspect } from '@teambit/api-server'; -import { ComponentWriterAspect } from '@teambit/component-writer'; -import { TrackerAspect } from '@teambit/tracker'; -import { MoverAspect } from '@teambit/mover'; -import { WatcherAspect } from '@teambit/watcher'; -import { StashAspect } from '@teambit/stash'; -import { GitAspect } from '@teambit/git'; -import { IpcEventsAspect } from '@teambit/ipc-events'; -import { ConfigMergerAspect } from '@teambit/config-merger'; -import { VersionHistoryAspect } from '@teambit/version-history'; -import { HostInitializerAspect } from '@teambit/host-initializer'; -import { DoctorAspect } from '@teambit/doctor'; -import { ApplyAspect } from '@teambit/apply'; +import { AspectAspect } from '@teambit/aspect/aspect.aspect'; +import { AspectLoaderAspect } from '@teambit/aspect-loader/aspect-loader.aspect'; +import { BuilderAspect } from '@teambit/builder/builder.aspect'; +import { BundlerAspect } from '@teambit/bundler/bundler.aspect'; +import { CacheAspect } from '@teambit/cache/cache.aspect'; +import { CLIAspect } from '@teambit/cli/cli.aspect'; +import { CompilerAspect } from '@teambit/compiler/compiler.aspect'; +import { ComponentAspect } from '@teambit/component/component.aspect'; +import { CompositionsAspect } from '@teambit/compositions/compositions.aspect'; +import { ConfigAspect } from '@teambit/config/config.aspect'; +import { DependencyResolverAspect } from '@teambit/dependency-resolver/dependency-resolver.aspect'; +import { DeprecationAspect } from '@teambit/deprecation/deprecation.aspect'; +import { DocsAspect } from '@teambit/docs/docs.aspect'; +import { EnvsAspect } from '@teambit/envs/environments.aspect'; +import { EnvAspect } from '@teambit/env/env.aspect'; +import { ExpressAspect } from '@teambit/express/express.aspect'; +import { YarnAspect } from '@teambit/yarn/yarn.aspect'; +import { GeneratorAspect } from '@teambit/generator/generator.aspect'; +import { HarmonyUiAppAspect } from '@teambit/harmony-ui-app/harmony-ui-app.aspect'; +import { GraphAspect } from '@teambit/graph/graph.aspect'; +import { GraphqlAspect } from '@teambit/graphql/graphql.aspect'; +import { InsightsAspect } from '@teambit/insights/insights.aspect'; +import { IsolatorAspect } from '@teambit/isolator/isolator.aspect'; +import { JestAspect } from '@teambit/jest/jest.aspect'; +import { LoggerAspect } from '@teambit/logger/logger.aspect'; +import { NodeAspect } from '@teambit/node/node.aspect'; +import { NotificationsAspect } from '@teambit/notifications/notifications.aspect'; +import { PanelUiAspect } from '@teambit/panels/panel-ui.aspect'; +import { PkgAspect } from '@teambit/pkg/pkg.aspect'; +import { PnpmAspect } from '@teambit/pnpm/pnpm.aspect'; +import { PreviewAspect } from '@teambit/preview/preview.aspect'; +import { ComponentSizerAspect } from '@teambit/component-sizer/component-sizer.aspect'; +import { ReactAspect } from '@teambit/react/react.aspect'; +import { ReactRouterAspect } from '@teambit/react-router/react-router.aspect'; +import { SchemaAspect } from '@teambit/schema/schema.aspect'; +import { PubsubAspect } from '@teambit/pubsub/pubsub.aspect'; +import { ScopeAspect } from '@teambit/scope/scope.aspect'; +// import { StencilAspect } from '@teambit/stencil/stencil.aspect'; +import { TesterAspect } from '@teambit/tester/tester.aspect'; +import { MultiTesterAspect } from '@teambit/multi-tester/multi-tester.aspect'; +import { TypescriptAspect } from '@teambit/typescript/typescript.aspect'; +import { BabelAspect } from '@teambit/babel/babel.aspect'; +import { UIAspect } from '@teambit/ui/ui.aspect'; +import { VariantsAspect } from '@teambit/variants/variants.aspect'; +import { WebpackAspect } from '@teambit/webpack/webpack.aspect'; +import { WorkspaceAspect } from '@teambit/workspace/workspace.aspect'; +import { WorkspaceConfigFilesAspect } from '@teambit/workspace-config-files/workspace-config-files.aspect'; +import { InstallAspect } from '@teambit/install/install.aspect'; +import { LinterAspect } from '@teambit/linter/linter.aspect'; +import { FormatterAspect } from '@teambit/formatter/formatter.aspect'; +import { ChangelogAspect } from '@teambit/changelog/changelog.aspect'; +import { CodeAspect } from '@teambit/code/code.aspect'; +import { CommandBarAspect } from '@teambit/command-bar/command-bar.aspect'; +import { SidebarAspect } from '@teambit/sidebar/sidebar.aspect'; +import { ComponentTreeAspect } from '@teambit/component-tree/component-tree.aspect'; +import { DevFilesAspect } from '@teambit/dev-files/dev-files.aspect'; +import { ESLintAspect } from '@teambit/eslint/eslint.aspect'; +import { PrettierAspect } from '@teambit/prettier/prettier.aspect'; +import { SignAspect } from '@teambit/sign/sign.aspect'; +import { WorkerAspect } from '@teambit/worker/worker.aspect'; +import { GlobalConfigAspect } from '@teambit/global-config/global-config.aspect'; +import { MultiCompilerAspect } from '@teambit/multi-compiler/multi-compiler.aspect'; +import { MDXAspect } from '@teambit/mdx/mdx.aspect'; +import { ReadmeAspect } from '@teambit/readme/readme.aspect'; +import { ApplicationAspect } from '@teambit/application/application.aspect'; +import { UpdateDependenciesAspect } from '@teambit/update-dependencies/update-dependencies.aspect'; +import { ExportAspect } from '@teambit/export/export.aspect'; +import { ImporterAspect } from '@teambit/importer/importer.aspect'; +import { EjectAspect } from '@teambit/eject/eject.aspect'; +import { UserAgentAspect } from '@teambit/user-agent/user-agent.aspect'; +// import { HtmlAspect } from '@teambit/html/html.aspect'; +import { LanesAspect } from '@teambit/lanes/lanes.aspect'; +import { ForkingAspect } from '@teambit/forking/forking.aspect'; +import { RenamingAspect } from '@teambit/renaming/renaming.aspect'; +import { ComponentLogAspect } from '@teambit/component-log/component-log.aspect'; +import { ClearCacheAspect } from '@teambit/clear-cache/clear-cache.aspect'; +import { DiagnosticAspect } from '@teambit/diagnostic/diagnostic.aspect'; +import { NewComponentHelperAspect } from '@teambit/new-component-helper/new-component-helper.aspect'; +import { MochaAspect } from '@teambit/mocha/mocha.aspect'; +import { CommunityAspect } from '@teambit/community/community.aspect'; +import { CloudAspect } from '@teambit/cloud/cloud.aspect'; +import { StatusAspect } from '@teambit/status/status.aspect'; +import { SnappingAspect } from '@teambit/snapping/snapping.aspect'; +import { MergingAspect } from '@teambit/merging/merging.aspect'; +import { IssuesAspect } from '@teambit/issues/issues.aspect'; +import { RefactoringAspect } from '@teambit/refactoring/refactoring.aspect'; +import { ComponentCompareAspect } from '@teambit/component-compare/component-compare.aspect'; +import { ListerAspect } from '@teambit/lister/lister.aspect'; +import { DependenciesAspect } from '@teambit/dependencies/dependencies.aspect'; +import { RemoveAspect } from '@teambit/remove/remove.aspect'; +import { MergeLanesAspect } from '@teambit/merge-lanes/merge-lanes.aspect'; +import { CheckoutAspect } from '@teambit/checkout/checkout.aspect'; +import { APIReferenceAspect } from '@teambit/api-reference/api-reference.aspect'; +import { ApiServerAspect } from '@teambit/api-server/api-server.aspect'; +import { ComponentWriterAspect } from '@teambit/component-writer/component-writer.aspect'; +import { TrackerAspect } from '@teambit/tracker/tracker.aspect'; +import { MoverAspect } from '@teambit/mover/mover.aspect'; +import { WatcherAspect } from '@teambit/watcher/watcher.aspect'; +import { StashAspect } from '@teambit/stash/stash.aspect'; +import { GitAspect } from '@teambit/git/git.aspect'; +import { IpcEventsAspect } from '@teambit/ipc-events/ipc-events.aspect'; +import { ConfigMergerAspect } from '@teambit/config-merger/config-merger.aspect'; +import { VersionHistoryAspect } from '@teambit/version-history/version-history.aspect'; +import { HostInitializerAspect } from '@teambit/host-initializer/host-initializer.aspect'; +import { DoctorAspect } from '@teambit/doctor/doctor.aspect'; +import { ApplyAspect } from '@teambit/apply/apply.aspect'; + +import { AspectMain } from '@teambit/aspect/aspect.main.runtime'; +import { AspectLoaderMain } from '@teambit/aspect-loader/aspect-loader.main.runtime'; +import { BuilderMain } from '@teambit/builder/builder.main.runtime'; +import { BundlerMain } from '@teambit/bundler/bundler.main.runtime'; +import { CacheMain } from '@teambit/cache/cache.main.runtime'; +import { CLIMain } from '@teambit/cli/cli.main.runtime'; +import { CompilerMain } from '@teambit/compiler/compiler.main.runtime'; +import { ComponentMain } from '@teambit/component/component.main.runtime'; +import { CompositionsMain } from '@teambit/compositions/compositions.main.runtime'; +// import { ConfigMain } from '@teambit/config/config.main.runtime'; +import { DependencyResolverMain } from '@teambit/dependency-resolver/dependency-resolver.main.runtime'; +import { DeprecationMain } from '@teambit/deprecation/deprecation.main.runtime'; +import { DocsMain } from '@teambit/docs/docs.main.runtime'; +import { EnvsMain } from '@teambit/envs/environments.main.runtime'; +import { EnvMain } from '@teambit/env/env.main.runtime'; +import { ExpressMain } from '@teambit/express/express.main.runtime'; +import { YarnMain } from '@teambit/yarn/yarn.main.runtime'; +import { GeneratorMain } from '@teambit/generator/generator.main.runtime'; +import { HarmonyUiAppMain } from '@teambit/harmony-ui-app/harmony-ui-app.main.runtime'; +import { GraphMain } from '@teambit/graph/graph.main.runtime'; +import { GraphqlMain } from '@teambit/graphql/graphql.main.runtime'; +import { InsightsMain } from '@teambit/insights/insights.main.runtime'; +import { IsolatorMain } from '@teambit/isolator/isolator.main.runtime'; +import { JestMain } from '@teambit/jest/jest.main.runtime'; +import { LoggerMain } from '@teambit/logger/logger.main.runtime'; +import { NodeMain } from '@teambit/node/node.main.runtime'; +import { PanelUIMain } from '@teambit/panels/panel-ui.main.runtime'; +import { PkgMain } from '@teambit/pkg/pkg.main.runtime'; +import { PnpmMain } from '@teambit/pnpm/pnpm.main.runtime'; +import { PreviewMain } from '@teambit/preview/preview.main.runtime'; +import { ComponentSizerMain } from '@teambit/component-sizer/component-sizer.main.runtime'; +import { ReactMain } from '@teambit/react/react.main.runtime'; +import { SchemaMain } from '@teambit/schema/schema.main.runtime'; +import { PubsubMain } from '@teambit/pubsub/pubsub.main.runtime'; +import { ScopeMain } from '@teambit/scope/scope.main.runtime'; +// import { StencilMain } from '@teambit/stencil/stencil.main.runtime'; +import { TesterMain } from '@teambit/tester/tester.main.runtime'; +import { MultiTesterMain } from '@teambit/multi-tester/multi-tester.main.runtime'; +import { TypescriptMain } from '@teambit/typescript/typescript.main.runtime'; +import { BabelMain } from '@teambit/babel/babel.main.runtime'; +import { UiMain } from '@teambit/ui/ui.main.runtime'; +import { VariantsMain } from '@teambit/variants/variants.main.runtime'; +import { WebpackMain } from '@teambit/webpack/webpack.main.runtime'; +import { WorkspaceMain } from '@teambit/workspace/workspace.main.runtime'; +import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files/workspace-config-files.main.runtime'; +import { InstallMain } from '@teambit/install/install.main.runtime'; +import { LinterMain } from '@teambit/linter/linter.main.runtime'; +import { FormatterMain } from '@teambit/formatter/formatter.main.runtime'; +import { DevFilesMain } from '@teambit/dev-files/dev-files.main.runtime'; +import { ESLintMain } from '@teambit/eslint/eslint.main.runtime'; +import { PrettierMain } from '@teambit/prettier/prettier.main.runtime'; +import { SignMain } from '@teambit/sign/sign.main.runtime'; +import { WorkerMain } from '@teambit/worker/worker.main.runtime'; +import { GlobalConfigMain } from '@teambit/global-config/global-config.main.runtime'; +import { MultiCompilerMain } from '@teambit/multi-compiler/multi-compiler.main.runtime'; +import { MDXMain } from '@teambit/mdx/mdx.main.runtime'; +import { ReadmeMain } from '@teambit/readme/readme.main.runtime'; +import { ApplicationMain } from '@teambit/application/application.main.runtime'; +import { UpdateDependenciesMain } from '@teambit/update-dependencies/update-dependencies.main.runtime'; +import { ExportMain } from '@teambit/export/export.main.runtime'; +import { ImporterMain } from '@teambit/importer/importer.main.runtime'; +import { EjectMain } from '@teambit/eject/eject.main.runtime'; +// import { HtmlMain } from '@teambit/html/html.main.runtime'; +import { LanesMain } from '@teambit/lanes/lanes.main.runtime'; +import { ForkingMain } from '@teambit/forking/forking.main.runtime'; +import { RenamingMain } from '@teambit/renaming/renaming.main.runtime'; +import { ComponentLogMain } from '@teambit/component-log/component-log.main.runtime'; +import { ClearCacheMain } from '@teambit/clear-cache/clear-cache.main.runtime'; +import { DiagnosticMain } from '@teambit/diagnostic/diagnostic.main.runtime'; +import { NewComponentHelperMain } from '@teambit/new-component-helper/new-component-helper.main.runtime'; +import { MochaMain } from '@teambit/mocha/mocha.main.runtime'; +import { CommunityMain } from '@teambit/community/community.main.runtime'; +import { CloudMain } from '@teambit/cloud/cloud.main.runtime'; +import { StatusMain } from '@teambit/status/status.main.runtime'; +import { SnappingMain } from '@teambit/snapping/snapping.main.runtime'; +import { MergingMain } from '@teambit/merging/merging.main.runtime'; +import { IssuesMain } from '@teambit/issues/issues.main.runtime'; +import { RefactoringMain } from '@teambit/refactoring/refactoring.main.runtime'; +import { ComponentCompareMain } from '@teambit/component-compare/component-compare.main.runtime'; +import { ListerMain } from '@teambit/lister/lister.main.runtime'; +import { DependenciesMain } from '@teambit/dependencies/dependencies.main.runtime'; +import { RemoveMain } from '@teambit/remove/remove.main.runtime'; +import { MergeLanesMain } from '@teambit/merge-lanes/merge-lanes.main.runtime'; +import { CheckoutMain } from '@teambit/checkout/checkout.main.runtime'; +import { ApiServerMain } from '@teambit/api-server/api-server.main.runtime'; +import { ComponentWriterMain } from '@teambit/component-writer/component-writer.main.runtime'; +import { TrackerMain } from '@teambit/tracker/tracker.main.runtime'; +import { MoverMain } from '@teambit/mover/mover.main.runtime'; +import { WatcherMain } from '@teambit/watcher/watcher.main.runtime'; +import { StashMain } from '@teambit/stash/stash.main.runtime'; +import { GitMain } from '@teambit/git/git.main.runtime'; +import { IpcEventsMain } from '@teambit/ipc-events/ipc-events.main.runtime'; +import { ConfigMergerMain } from '@teambit/config-merger/config-merger.main.runtime'; +import { VersionHistoryMain } from '@teambit/version-history/version-history.main.runtime'; +import { HostInitializerMain } from '@teambit/host-initializer/host-initializer.main.runtime'; +import { DoctorMain } from '@teambit/doctor/doctor.main.runtime'; +import { ApplyMain } from '@teambit/apply/apply.main.runtime'; + import { BitAspect } from './bit.aspect'; -export const manifestsMap = { - [AspectLoaderAspect.id]: AspectLoaderAspect, - [CLIAspect.id]: CLIAspect, - [DevFilesAspect.id]: DevFilesAspect, - [WorkspaceAspect.id]: WorkspaceAspect, - [WorkspaceConfigFilesAspect.id]: WorkspaceConfigFilesAspect, - [InstallAspect.id]: InstallAspect, - [ESLintAspect.id]: ESLintAspect, - [PrettierAspect.id]: PrettierAspect, - [CompilerAspect.id]: CompilerAspect, - [LinterAspect.id]: LinterAspect, - [FormatterAspect.id]: FormatterAspect, - [ComponentAspect.id]: ComponentAspect, - [MDXAspect.id]: MDXAspect, - [ReadmeAspect.id]: ReadmeAspect, - [PreviewAspect.id]: PreviewAspect, - [ComponentSizerAspect.id]: ComponentSizerAspect, - [DocsAspect.id]: DocsAspect, - [YarnAspect.id]: YarnAspect, - [CompositionsAspect.id]: CompositionsAspect, - [GlobalConfigAspect.id]: GlobalConfigAspect, - [GraphqlAspect.id]: GraphqlAspect, - [PnpmAspect.id]: PnpmAspect, - [MultiCompilerAspect.id]: MultiCompilerAspect, - [UIAspect.id]: UIAspect, - [GeneratorAspect.id]: GeneratorAspect, - [EnvsAspect.id]: EnvsAspect, - [EnvAspect.id]: EnvAspect, - [GraphAspect.id]: GraphAspect, - [PubsubAspect.id]: PubsubAspect, - [DependencyResolverAspect.id]: DependencyResolverAspect, - [InsightsAspect.id]: InsightsAspect, - [IsolatorAspect.id]: IsolatorAspect, - [LoggerAspect.id]: LoggerAspect, - [PkgAspect.id]: PkgAspect, - [ReactAspect.id]: ReactAspect, - [WorkerAspect.id]: WorkerAspect, - // [StencilAspect.id]: StencilAspect, - [ScopeAspect.id]: ScopeAspect, - [TesterAspect.id]: TesterAspect, - [MultiTesterAspect.id]: MultiTesterAspect, - [BuilderAspect.id]: BuilderAspect, - [VariantsAspect.id]: VariantsAspect, - [DeprecationAspect.id]: DeprecationAspect, - [ExpressAspect.id]: ExpressAspect, - [AspectAspect.id]: AspectAspect, - [WebpackAspect.id]: WebpackAspect, - [SchemaAspect.id]: SchemaAspect, - [ReactRouterAspect.id]: ReactRouterAspect, - [TypescriptAspect.id]: TypescriptAspect, - [PanelUiAspect.id]: PanelUiAspect, - [BabelAspect.id]: BabelAspect, - [NodeAspect.id]: NodeAspect, - [NotificationsAspect.id]: NotificationsAspect, - [BundlerAspect.id]: BundlerAspect, - [JestAspect.id]: JestAspect, - [CacheAspect.id]: CacheAspect, - [ChangelogAspect.id]: ChangelogAspect, - [CodeAspect.id]: CodeAspect, - [CommandBarAspect.id]: CommandBarAspect, - [SidebarAspect.id]: SidebarAspect, - [ComponentTreeAspect.id]: ComponentTreeAspect, - [SignAspect.id]: SignAspect, - [UpdateDependenciesAspect.id]: UpdateDependenciesAspect, - [ExportAspect.id]: ExportAspect, - [ImporterAspect.id]: ImporterAspect, - [HarmonyUiAppAspect.id]: HarmonyUiAppAspect, - [UserAgentAspect.id]: UserAgentAspect, - [ApplicationAspect.id]: ApplicationAspect, - [EjectAspect.id]: EjectAspect, - [HtmlAspect.id]: HtmlAspect, - [LanesAspect.id]: LanesAspect, - [ForkingAspect.id]: ForkingAspect, - [RenamingAspect.id]: RenamingAspect, - [NewComponentHelperAspect.id]: NewComponentHelperAspect, - [ComponentLogAspect.id]: ComponentLogAspect, - [ClearCacheAspect.id]: ClearCacheAspect, - [MochaAspect.id]: MochaAspect, - [DiagnosticAspect.id]: DiagnosticAspect, - [StatusAspect.id]: StatusAspect, - [CommunityAspect.id]: CommunityAspect, - [CloudAspect.id]: CloudAspect, - [SnappingAspect.id]: SnappingAspect, - [MergingAspect.id]: MergingAspect, - [IssuesAspect.id]: IssuesAspect, - [RefactoringAspect.id]: RefactoringAspect, - [ComponentCompareAspect.id]: ComponentCompareAspect, - [ListerAspect.id]: ListerAspect, - [DependenciesAspect.id]: DependenciesAspect, - [RemoveAspect.id]: RemoveAspect, - [MergeLanesAspect.id]: MergeLanesAspect, - [CheckoutAspect.id]: CheckoutAspect, - [ComponentWriterAspect.id]: ComponentWriterAspect, - [APIReferenceAspect.id]: APIReferenceAspect, - [ApiServerAspect.id]: ApiServerAspect, - [TrackerAspect.id]: TrackerAspect, - [MoverAspect.id]: MoverAspect, - [WatcherAspect.id]: WatcherAspect, - [StashAspect.id]: StashAspect, - [GitAspect.id]: GitAspect, - [IpcEventsAspect.id]: IpcEventsAspect, - [ConfigMergerAspect.id]: ConfigMergerAspect, - [VersionHistoryAspect.id]: VersionHistoryAspect, - [HostInitializerAspect.id]: HostInitializerAspect, - [DoctorAspect.id]: DoctorAspect, - [ApplyAspect.id]: ApplyAspect, +export function getManifestsMap() { + const manifestsMap = { + [AspectLoaderAspect.id]: AspectLoaderAspect, + [CLIAspect.id]: CLIAspect, + [DevFilesAspect.id]: DevFilesAspect, + [WorkspaceAspect.id]: WorkspaceAspect, + [WorkspaceConfigFilesAspect.id]: WorkspaceConfigFilesAspect, + [InstallAspect.id]: InstallAspect, + [ESLintAspect.id]: ESLintAspect, + [PrettierAspect.id]: PrettierAspect, + [CompilerAspect.id]: CompilerAspect, + [LinterAspect.id]: LinterAspect, + [FormatterAspect.id]: FormatterAspect, + [ComponentAspect.id]: ComponentAspect, + [MDXAspect.id]: MDXAspect, + [ReadmeAspect.id]: ReadmeAspect, + [PreviewAspect.id]: PreviewAspect, + [ComponentSizerAspect.id]: ComponentSizerAspect, + [DocsAspect.id]: DocsAspect, + [YarnAspect.id]: YarnAspect, + [CompositionsAspect.id]: CompositionsAspect, + [GlobalConfigAspect.id]: GlobalConfigAspect, + [GraphqlAspect.id]: GraphqlAspect, + [PnpmAspect.id]: PnpmAspect, + [MultiCompilerAspect.id]: MultiCompilerAspect, + [UIAspect.id]: UIAspect, + [GeneratorAspect.id]: GeneratorAspect, + [EnvsAspect.id]: EnvsAspect, + [EnvAspect.id]: EnvAspect, + [GraphAspect.id]: GraphAspect, + [PubsubAspect.id]: PubsubAspect, + [DependencyResolverAspect.id]: DependencyResolverAspect, + [InsightsAspect.id]: InsightsAspect, + [IsolatorAspect.id]: IsolatorAspect, + [LoggerAspect.id]: LoggerAspect, + [PkgAspect.id]: PkgAspect, + [ReactAspect.id]: ReactAspect, + [WorkerAspect.id]: WorkerAspect, + // [StencilAspect.id]: StencilAspect, + [ScopeAspect.id]: ScopeAspect, + [TesterAspect.id]: TesterAspect, + [MultiTesterAspect.id]: MultiTesterAspect, + [BuilderAspect.id]: BuilderAspect, + [VariantsAspect.id]: VariantsAspect, + [DeprecationAspect.id]: DeprecationAspect, + [ExpressAspect.id]: ExpressAspect, + [AspectAspect.id]: AspectAspect, + [WebpackAspect.id]: WebpackAspect, + [SchemaAspect.id]: SchemaAspect, + [ReactRouterAspect.id]: ReactRouterAspect, + [TypescriptAspect.id]: TypescriptAspect, + [PanelUiAspect.id]: PanelUiAspect, + [BabelAspect.id]: BabelAspect, + [NodeAspect.id]: NodeAspect, + [NotificationsAspect.id]: NotificationsAspect, + [BundlerAspect.id]: BundlerAspect, + [JestAspect.id]: JestAspect, + [CacheAspect.id]: CacheAspect, + [ChangelogAspect.id]: ChangelogAspect, + [CodeAspect.id]: CodeAspect, + [CommandBarAspect.id]: CommandBarAspect, + [SidebarAspect.id]: SidebarAspect, + [ComponentTreeAspect.id]: ComponentTreeAspect, + [SignAspect.id]: SignAspect, + [UpdateDependenciesAspect.id]: UpdateDependenciesAspect, + [ExportAspect.id]: ExportAspect, + [ImporterAspect.id]: ImporterAspect, + [HarmonyUiAppAspect.id]: HarmonyUiAppAspect, + [UserAgentAspect.id]: UserAgentAspect, + [ApplicationAspect.id]: ApplicationAspect, + [EjectAspect.id]: EjectAspect, + // [HtmlAspect.id]: HtmlAspect, + [LanesAspect.id]: LanesAspect, + [ForkingAspect.id]: ForkingAspect, + [RenamingAspect.id]: RenamingAspect, + [NewComponentHelperAspect.id]: NewComponentHelperAspect, + [ComponentLogAspect.id]: ComponentLogAspect, + [ClearCacheAspect.id]: ClearCacheAspect, + [MochaAspect.id]: MochaAspect, + [DiagnosticAspect.id]: DiagnosticAspect, + [StatusAspect.id]: StatusAspect, + [CommunityAspect.id]: CommunityAspect, + [CloudAspect.id]: CloudAspect, + [SnappingAspect.id]: SnappingAspect, + [MergingAspect.id]: MergingAspect, + [IssuesAspect.id]: IssuesAspect, + [RefactoringAspect.id]: RefactoringAspect, + [ComponentCompareAspect.id]: ComponentCompareAspect, + [ListerAspect.id]: ListerAspect, + [DependenciesAspect.id]: DependenciesAspect, + [RemoveAspect.id]: RemoveAspect, + [MergeLanesAspect.id]: MergeLanesAspect, + [CheckoutAspect.id]: CheckoutAspect, + [ComponentWriterAspect.id]: ComponentWriterAspect, + [APIReferenceAspect.id]: APIReferenceAspect, + [ApiServerAspect.id]: ApiServerAspect, + [TrackerAspect.id]: TrackerAspect, + [MoverAspect.id]: MoverAspect, + [WatcherAspect.id]: WatcherAspect, + [StashAspect.id]: StashAspect, + [GitAspect.id]: GitAspect, + [IpcEventsAspect.id]: IpcEventsAspect, + [ConfigMergerAspect.id]: ConfigMergerAspect, + [VersionHistoryAspect.id]: VersionHistoryAspect, + [HostInitializerAspect.id]: HostInitializerAspect, + [DoctorAspect.id]: DoctorAspect, + [ApplyAspect.id]: ApplyAspect, + }; + return manifestsMap; +} + +export const runtimesMap = { + [AspectLoaderAspect.id]: AspectLoaderMain, + [CLIAspect.id]: CLIMain, + [DevFilesAspect.id]: DevFilesMain, + [WorkspaceAspect.id]: WorkspaceMain, + [WorkspaceConfigFilesAspect.id]: WorkspaceConfigFilesMain, + [InstallAspect.id]: InstallMain, + [ESLintAspect.id]: ESLintMain, + [PrettierAspect.id]: PrettierMain, + [CompilerAspect.id]: CompilerMain, + [LinterAspect.id]: LinterMain, + [FormatterAspect.id]: FormatterMain, + [ComponentAspect.id]: ComponentMain, + [MDXAspect.id]: MDXMain, + [ReadmeAspect.id]: ReadmeMain, + [PreviewAspect.id]: PreviewMain, + [ComponentSizerAspect.id]: ComponentSizerMain, + [DocsAspect.id]: DocsMain, + [YarnAspect.id]: YarnMain, + [CompositionsAspect.id]: CompositionsMain, + [GlobalConfigAspect.id]: GlobalConfigMain, + [GraphqlAspect.id]: GraphqlMain, + [PnpmAspect.id]: PnpmMain, + [MultiCompilerAspect.id]: MultiCompilerMain, + [UIAspect.id]: UiMain, + [GeneratorAspect.id]: GeneratorMain, + [EnvsAspect.id]: EnvsMain, + [EnvAspect.id]: EnvMain, + [GraphAspect.id]: GraphMain, + [PubsubAspect.id]: PubsubMain, + [DependencyResolverAspect.id]: DependencyResolverMain, + [InsightsAspect.id]: InsightsMain, + [IsolatorAspect.id]: IsolatorMain, + [LoggerAspect.id]: LoggerMain, + [PkgAspect.id]: PkgMain, + [ReactAspect.id]: ReactMain, + [WorkerAspect.id]: WorkerMain, + // [StencilAspect.id]: StencilMain, + [ScopeAspect.id]: ScopeMain, + [TesterAspect.id]: TesterMain, + [MultiTesterAspect.id]: MultiTesterMain, + [BuilderAspect.id]: BuilderMain, + [VariantsAspect.id]: VariantsMain, + [DeprecationAspect.id]: DeprecationMain, + [ExpressAspect.id]: ExpressMain, + [AspectAspect.id]: AspectMain, + [WebpackAspect.id]: WebpackMain, + [SchemaAspect.id]: SchemaMain, + [TypescriptAspect.id]: TypescriptMain, + [PanelUiAspect.id]: PanelUIMain, + [BabelAspect.id]: BabelMain, + [NodeAspect.id]: NodeMain, + [BundlerAspect.id]: BundlerMain, + [JestAspect.id]: JestMain, + [CacheAspect.id]: CacheMain, + [SignAspect.id]: SignMain, + [UpdateDependenciesAspect.id]: UpdateDependenciesMain, + [ExportAspect.id]: ExportMain, + [ImporterAspect.id]: ImporterMain, + [HarmonyUiAppAspect.id]: HarmonyUiAppMain, + [ApplicationAspect.id]: ApplicationMain, + [EjectAspect.id]: EjectMain, + // [HtmlAspect.id]: HtmlMain, + [LanesAspect.id]: LanesMain, + [ForkingAspect.id]: ForkingMain, + [RenamingAspect.id]: RenamingMain, + [NewComponentHelperAspect.id]: NewComponentHelperMain, + [ComponentLogAspect.id]: ComponentLogMain, + [ClearCacheAspect.id]: ClearCacheMain, + [MochaAspect.id]: MochaMain, + [DiagnosticAspect.id]: DiagnosticMain, + [StatusAspect.id]: StatusMain, + [CommunityAspect.id]: CommunityMain, + [CloudAspect.id]: CloudMain, + [SnappingAspect.id]: SnappingMain, + [MergingAspect.id]: MergingMain, + [IssuesAspect.id]: IssuesMain, + [RefactoringAspect.id]: RefactoringMain, + [ComponentCompareAspect.id]: ComponentCompareMain, + [ListerAspect.id]: ListerMain, + [DependenciesAspect.id]: DependenciesMain, + [RemoveAspect.id]: RemoveMain, + [MergeLanesAspect.id]: MergeLanesMain, + [CheckoutAspect.id]: CheckoutMain, + [ComponentWriterAspect.id]: ComponentWriterMain, + [ApiServerAspect.id]: ApiServerMain, + [TrackerAspect.id]: TrackerMain, + [MoverAspect.id]: MoverMain, + [WatcherAspect.id]: WatcherMain, + [StashAspect.id]: StashMain, + [GitAspect.id]: GitMain, + [IpcEventsAspect.id]: IpcEventsMain, + [ConfigMergerAspect.id]: ConfigMergerMain, + [VersionHistoryAspect.id]: VersionHistoryMain, + [HostInitializerAspect.id]: HostInitializerMain, + [DoctorAspect.id]: DoctorMain, + [ApplyAspect.id]: ApplyMain, }; export function isCoreAspect(id: string) { + const manifestsMap = getManifestsMap(); const _reserved = [BitAspect.id, ConfigAspect.id]; if (_reserved.includes(id)) return true; return !!manifestsMap[id]; } export function getAllCoreAspectsIds(): string[] { + const manifestsMap = getManifestsMap(); const _reserved = [BitAspect.id, ConfigAspect.id]; return [...Object.keys(manifestsMap), ..._reserved]; } diff --git a/scopes/harmony/cli-reference/cli-reference.docs.mdx b/scopes/harmony/cli-reference/cli-reference.docs.mdx index 8bc46e1ff1dc..833103486c6d 100644 --- a/scopes/harmony/cli-reference/cli-reference.docs.mdx +++ b/scopes/harmony/cli-reference/cli-reference.docs.mdx @@ -2,4 +2,3 @@ description: 'Bit command synopses. Bit version: 1.9.18' labels: ['cli', 'mdx', 'docs'] --- - diff --git a/scopes/harmony/cli/cli-parser.ts b/scopes/harmony/cli/cli-parser.ts index d6b2555bb30e..28308206de53 100644 --- a/scopes/harmony/cli/cli-parser.ts +++ b/scopes/harmony/cli/cli-parser.ts @@ -1,5 +1,5 @@ import didYouMean from 'didyoumean'; -import yargs from 'yargs'; +// import yargs from 'yargs'; import { Command } from './command'; import { GroupsType } from './command-groups'; import { compact } from 'lodash'; @@ -15,6 +15,10 @@ import { OnCommandStartSlot } from './cli.main.runtime'; import { CommandRunner } from './command-runner'; import { YargsExitWorkaround } from './exceptions/yargs-exit-workaround'; +// Using require instead of import because of this issue: +// https://github.com/evanw/esbuild/issues/1492 +const yargs = require('yargs'); + export class CLIParser { public parser = yargs; private yargsCommands: YargsAdapter[] = []; diff --git a/scopes/harmony/config/config.main.runtime.ts b/scopes/harmony/config/config.main.runtime.ts index 2aec268b5bc3..83aba85e0619 100644 --- a/scopes/harmony/config/config.main.runtime.ts +++ b/scopes/harmony/config/config.main.runtime.ts @@ -129,9 +129,13 @@ export class ConfigMain { return configMain; } } - ConfigAspect.addRuntime(ConfigMain); +// Required for esbuild to work properly +export function getConfigAspect() { + return ConfigAspect; +} + async function loadWorkspaceConfigIfExist(cwd = process.cwd()): Promise { const consumerInfo = await getWorkspaceInfo(cwd); const configDirPath = consumerInfo?.path || cwd; diff --git a/scopes/harmony/config/index.ts b/scopes/harmony/config/index.ts index efb70ac6506a..85f2b1977790 100644 --- a/scopes/harmony/config/index.ts +++ b/scopes/harmony/config/index.ts @@ -1,4 +1,4 @@ -export { ConfigMain } from './config.main.runtime'; +export { ConfigMain, getConfigAspect } from './config.main.runtime'; export { ConfigAspect, ConfigRuntime } from './config.aspect'; export type { ComponentScopeDirMap, WorkspaceExtensionProps, WorkspaceConfigFileProps } from './workspace-config'; export { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig, WorkspaceConfig } from './workspace-config'; diff --git a/scopes/react/react/eslint/eslintrc.js b/scopes/react/react/eslint/eslintrc.js index 90df02c9e916..daa08f0e71ed 100644 --- a/scopes/react/react/eslint/eslintrc.js +++ b/scopes/react/react/eslint/eslintrc.js @@ -7,6 +7,6 @@ module.exports = { // parser: require.resolve('@typescript-eslint/parser'), // createDefaultProgram: true, // resolve the env tsconfig. - project: require.resolve('../typescript/tsconfig.json'), + project: 'auto generated by bit linter', }, }; diff --git a/scopes/react/react/react.env.ts b/scopes/react/react/react.env.ts index b839bd3a5d0f..3133ee22b8be 100644 --- a/scopes/react/react/react.env.ts +++ b/scopes/react/react/react.env.ts @@ -48,7 +48,7 @@ import { Formatter, FormatterContext } from '@teambit/formatter'; import { pathNormalizeToLinux } from '@teambit/toolbox.path.path'; import type { ComponentMeta } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta'; import { SchemaExtractor } from '@teambit/schema'; -import { join, resolve } from 'path'; +import { join } from 'path'; import { outputFileSync } from 'fs-extra'; import { Logger } from '@teambit/logger'; import { ConfigWriterEntry } from '@teambit/workspace-config-files'; @@ -165,8 +165,9 @@ export class ReactEnv * @returns */ createCjsJestTester(jestConfigPath?: string, jestModulePath?: string): Tester { - const pathToSource = pathNormalizeToLinux(__dirname).replace('/dist', ''); - const defaultConfig = join(pathToSource, './jest/jest.cjs.config.js'); + // const pathToSource = pathNormalizeToLinux(__dirname).replace('/dist', ''); + // const defaultConfig = join(pathToSource, './jest/jest.cjs.config.js'); + const defaultConfig = require.resolve('./jest/jest.cjs.config'); const config = jestConfigPath || defaultConfig; const worker = this.getJestWorker(); const tester = JestTester.create( @@ -220,13 +221,14 @@ export class ReactEnv private createTsCompilerOptions(mode: CompilerMode = 'dev'): TypeScriptCompilerOptions { const tsconfig = mode === 'dev' ? cloneDeep(defaultTsConfig) : cloneDeep(buildTsConfig); - const pathToSource = pathNormalizeToLinux(__dirname).replace('/dist/', '/src/'); + // const pathToSource = pathNormalizeToLinux(__dirname).replace('/dist/', '/src/'); + const types = [require.resolve('./typescript/style.d.ts'), require.resolve('./typescript/asset.d.ts')]; const compileJs = true; const compileJsx = true; return { tsconfig, // TODO: @david please remove this line and refactor to be something that makes sense. - types: [resolve(pathToSource, './typescript/style.d.ts'), resolve(pathToSource, './typescript/asset.d.ts')], + types, compileJs, compileJsx, }; diff --git a/scopes/workspace/workspace/workspace-aspects-loader.ts b/scopes/workspace/workspace/workspace-aspects-loader.ts index 4f9fa25ae1d1..bda6b39b0e19 100644 --- a/scopes/workspace/workspace/workspace-aspects-loader.ts +++ b/scopes/workspace/workspace/workspace-aspects-loader.ts @@ -258,9 +258,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change const callId = Math.floor(Math.random() * 1000); const loggerPrefix = `[${callId}] workspace resolveAspects,`; - this.logger.debug( - `${loggerPrefix}, resolving aspects for - runtimeName: ${runtimeName}, componentIds: ${componentIds}` - ); const defaultOpts: ResolveAspectsOptions = { excludeCore: false, requestedOnly: false, @@ -271,6 +268,13 @@ your workspace.jsonc has this component-id set. you might want to remove/change packageManagerConfigRootDir: this.workspace.path, }; const mergedOpts = { ...defaultOpts, ...opts }; + this.logger.debug( + `${loggerPrefix}, resolving aspects for - runtimeName: ${runtimeName}, componentIds: ${componentIds}, opts: ${JSON.stringify( + mergedOpts, + null, + 2 + )}` + ); const idsToResolve = componentIds ? componentIds.map((id) => id.toString()) : this.harmony.extensionsIds; const workspaceLocalAspectsIds = Object.keys(this.workspace.localAspects); const [localAspectsIds, nonLocalAspectsIds] = partition(idsToResolve, (id) => @@ -299,13 +303,15 @@ your workspace.jsonc has this component-id set. you might want to remove/change components, this.getWorkspaceAspectResolver([], runtimeName) ); - - const coreAspectDefs = await Promise.all( - coreAspectsIds.map(async (coreId) => { - const rawDef = await getAspectDef(coreId, runtimeName); - return this.aspectLoader.loadDefinition(rawDef); - }) - ); + let coreAspectDefs: AspectDefinition[] = []; + if (!mergedOpts.excludeCore) { + coreAspectDefs = await Promise.all( + coreAspectsIds.map(async (coreId) => { + const rawDef = await getAspectDef(coreId, runtimeName); + return this.aspectLoader.loadDefinition(rawDef); + }) + ); + } const idsToFilter = idsToResolve.map((idStr) => ComponentID.fromString(idStr)); const targetDefs = wsAspectDefs.concat(coreAspectDefs).concat(localDefs); diff --git a/workspace.jsonc b/workspace.jsonc index f934bf2e50fa..6d6505f0a39f 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -564,6 +564,8 @@ "diff": "^7.0.0", "dreidels": "0.6.1", "enquirer": "2.3.6", + "esbuild": "^0.24.0", + "esbuild-plugin-ignore": "^1.1.1", "eslint-config-airbnb-typescript": "17.1.0", "eslint-import-resolver-node": "0.3.4", "eventemitter2": "6.4.4", @@ -657,6 +659,7 @@ "table": "6.7.3", "terser-webpack-plugin": "5.2.0", "tippy.js": "6.2.7", + "tsup": "7.2.0", "ua-parser-js": "0.7.24", "url": "^0.11.3", "url-join": "4.0.1",