@teambit/isolator 0.0.555 → 0.0.556

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/isolator",
3
- "version": "0.0.555",
3
+ "version": "0.0.556",
4
4
  "homepage": "https://bit.dev/teambit/component/isolator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "isolator",
9
- "version": "0.0.555"
9
+ "version": "0.0.556"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -23,14 +23,14 @@
23
23
  "execa": "2.1.0",
24
24
  "@babel/runtime": "7.12.18",
25
25
  "core-js": "^3.0.0",
26
- "@teambit/component": "0.0.555",
27
- "@teambit/legacy-bit-id": "0.0.375",
28
- "@teambit/cli": "0.0.386",
29
- "@teambit/component-package-version": "0.0.372",
30
- "@teambit/dependency-resolver": "0.0.555",
31
- "@teambit/global-config": "0.0.387",
32
- "@teambit/graph": "0.0.555",
33
- "@teambit/logger": "0.0.471"
26
+ "@teambit/component": "0.0.556",
27
+ "@teambit/legacy-bit-id": "0.0.376",
28
+ "@teambit/cli": "0.0.387",
29
+ "@teambit/component-package-version": "0.0.373",
30
+ "@teambit/dependency-resolver": "0.0.556",
31
+ "@teambit/global-config": "0.0.388",
32
+ "@teambit/graph": "0.0.556",
33
+ "@teambit/logger": "0.0.472"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/fs-extra": "9.0.7",
@@ -45,7 +45,7 @@
45
45
  "@types/node": "12.20.4"
46
46
  },
47
47
  "peerDependencies": {
48
- "@teambit/legacy": "1.0.172",
48
+ "@teambit/legacy": "1.0.173",
49
49
  "react-dom": "^16.8.0 || ^17.0.0",
50
50
  "react": "^16.8.0 || ^17.0.0"
51
51
  },
@@ -73,12 +73,18 @@
73
73
  "react": "-"
74
74
  },
75
75
  "peerDependencies": {
76
- "@teambit/legacy": "1.0.172",
76
+ "@teambit/legacy": "1.0.173",
77
77
  "react-dom": "^16.8.0 || ^17.0.0",
78
78
  "react": "^16.8.0 || ^17.0.0"
79
79
  }
80
80
  }
81
81
  },
82
+ "files": [
83
+ "dist",
84
+ "!dist/tsconfig.tsbuildinfo",
85
+ "README.md",
86
+ "README.mdx"
87
+ ],
82
88
  "private": false,
83
89
  "engines": {
84
90
  "node": ">=12.22.0"
@@ -1,138 +0,0 @@
1
- import { NodeFS } from '@teambit/any-fs';
2
- import { Capsule as CapsuleTemplate, Console, Exec, State } from '@teambit/capsule';
3
- import { Component } from '@teambit/component';
4
- import filenamify from 'filenamify';
5
- import { realpathSync } from 'fs';
6
- import glob from 'glob';
7
- import path from 'path';
8
- import v4 from 'uuid';
9
-
10
- import FsContainer, { BitExecOption } from './container';
11
- import ContainerExec from './container-exec';
12
-
13
- export default class Capsule extends CapsuleTemplate<Exec, NodeFS> {
14
- private _wrkDir: string;
15
- constructor(
16
- /**
17
- * container implementation the capsule is being executed within.
18
- */
19
- protected container: FsContainer,
20
- /**
21
- * the capsule's file system.
22
- */
23
- readonly fs: NodeFS,
24
- /**
25
- * console for controlling process streams as stdout, stdin and stderr.
26
- */
27
- readonly console: Console = new Console(),
28
- /**
29
- * capsule's state.
30
- */
31
- readonly state: State,
32
- readonly component: Component
33
- ) {
34
- super(container, fs, console, state);
35
- this._wrkDir = container.wrkDir;
36
- }
37
-
38
- /**
39
- * @deprecated please use `this.path`
40
- */
41
- get wrkDir(): string {
42
- return this.path;
43
- }
44
-
45
- get path(): string {
46
- return realpathSync(this._wrkDir);
47
- }
48
-
49
- start(): Promise<any> {
50
- return this.container.start();
51
- }
52
-
53
- async execNode(executable: string, args: any, exec: ContainerExec) {
54
- return this.typedExec(
55
- {
56
- command: ['node', executable, ...(args.args || [])],
57
- cwd: '',
58
- },
59
- exec
60
- );
61
- }
62
-
63
- async typedExec(opts: BitExecOption, exec = new ContainerExec()) {
64
- return this.container.exec(opts, exec);
65
- }
66
-
67
- outputFile(file: string, data: any, options?: any): Promise<any> {
68
- return this.container.outputFile(file, data, options);
69
- }
70
-
71
- removePath(dir: string): Promise<any> {
72
- return this.container.removePath(dir);
73
- }
74
-
75
- symlink(src: string, dest: string): Promise<any> {
76
- return this.container.symlink(src, dest);
77
- }
78
-
79
- // TODO: refactor this crap and simplify capsule API
80
- async execute(cmd: string, options?: Record<string, any> | null | undefined) {
81
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
82
- const execResults = await this.exec({ command: cmd.split(' '), options });
83
- let stdout = '';
84
- let stderr = '';
85
- return new Promise((resolve, reject) => {
86
- execResults.stdout.on('data', (data: string) => {
87
- stdout += data;
88
- });
89
- execResults.stdout.on('error', (error: string) => {
90
- return reject(error);
91
- });
92
- // @ts-ignore
93
- execResults.on('close', () => {
94
- return resolve({ stdout, stderr });
95
- });
96
- execResults.stderr.on('error', (error: string) => {
97
- return reject(error);
98
- });
99
- execResults.stderr.on('data', (data: string) => {
100
- stderr += data;
101
- });
102
- });
103
- }
104
-
105
- /**
106
- * @todo: fix.
107
- * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work
108
- * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.
109
- *
110
- * returns the paths inside the capsule
111
- */
112
- getAllFilesPaths(dir = '.', options: { ignore?: string[] } = {}) {
113
- const files = glob.sync('**', { cwd: path.join(this.path, dir), nodir: true, ...options });
114
- return files.map((file) => path.join(dir, file));
115
- }
116
-
117
- static getCapsuleDirName(component: Component, config: { alwaysNew?: boolean; name?: string } = {}) {
118
- return config.name || filenamify(component.id.toString(), { replacement: '_' });
119
- }
120
-
121
- static getCapsuleRootDir(component: Component, baseDir: string, config: { alwaysNew?: boolean; name?: string } = {}) {
122
- return path.join(baseDir, Capsule.getCapsuleDirName(component, config));
123
- }
124
-
125
- static async createFromComponent(
126
- component: Component,
127
- baseDir: string,
128
- config: { alwaysNew?: boolean; name?: string } = {}
129
- ): Promise<Capsule> {
130
- // TODO: make this a static method and combine with ComponentCapsule
131
- const capsuleDirName = Capsule.getCapsuleDirName(component, config);
132
- const wrkDir = path.join(baseDir, config.alwaysNew ? `${capsuleDirName}_${v4()}` : capsuleDirName);
133
- const container = new FsContainer(wrkDir);
134
- const capsule = new Capsule(container, container.fs, new Console(), new State(), component);
135
- await capsule.start();
136
- return capsule;
137
- }
138
- }
@@ -1,31 +0,0 @@
1
- import { DuplexBufferStream, Exec, ExecStatus } from '@teambit/capsule';
2
- import { EventEmitter } from 'events';
3
-
4
- export default class ContainerExec extends EventEmitter implements Exec {
5
- constructor(private _code: number = 0) {
6
- super();
7
- }
8
-
9
- stdout: DuplexBufferStream = new DuplexBufferStream();
10
- stderr: DuplexBufferStream = new DuplexBufferStream();
11
- stdin: DuplexBufferStream = new DuplexBufferStream();
12
-
13
- setStatus(status: number): void {
14
- this._code = status;
15
- this.emit('close');
16
- }
17
-
18
- get code(): number {
19
- return this._code;
20
- }
21
-
22
- inspect(): Promise<ExecStatus> {
23
- return Promise.resolve({
24
- running: true,
25
- pid: 1,
26
- });
27
- }
28
- abort(): Promise<void> {
29
- throw new Error('Method not implemented.');
30
- }
31
- }
@@ -1,128 +0,0 @@
1
- import { AnyFS, NodeFS } from '@teambit/any-fs';
2
- import { Container, ContainerFactoryOptions, ContainerStatus, Exec, ExecOptions } from '@teambit/capsule';
3
- import execa from 'execa';
4
- import fs from 'fs-extra';
5
- import * as path from 'path';
6
- import { Stream } from 'stream';
7
-
8
- import ContainerExec from './container-exec';
9
-
10
- const debug = require('debug')('fs-container');
11
-
12
- export interface BitExecOption extends ExecOptions {
13
- cwd: string;
14
- stdio?: 'pipe' | 'ipc' | 'ignore' | 'inherit' | Stream | number | undefined;
15
- }
16
- export interface BitContainerConfig extends ContainerFactoryOptions {
17
- other?: string;
18
- }
19
-
20
- export default class FsContainer implements Container<Exec, AnyFS> {
21
- id = 'FS Container';
22
-
23
- fs: NodeFS = new NodeFS(this.wrkDir);
24
-
25
- constructor(readonly wrkDir: string) {}
26
-
27
- // TODO: do we need this?
28
- public getPath() {
29
- return this.wrkDir;
30
- }
31
-
32
- private composePath(pathToCompose) {
33
- return path.join(this.getPath(), pathToCompose);
34
- }
35
-
36
- outputFile(file, data, options) {
37
- const filePath = this.composePath(file);
38
- debug(`writing file on ${filePath}`);
39
- return fs.outputFile(filePath, data, options);
40
- }
41
-
42
- removePath(dir: string): Promise<any> {
43
- const pathToRemove = this.composePath(dir);
44
- return fs.remove(pathToRemove);
45
- }
46
-
47
- async symlink(src: string, dest: string): Promise<any> {
48
- const srcPath = this.composePath(src);
49
- const destPath = this.composePath(dest);
50
- await fs.ensureDir(path.dirname(destPath));
51
- return fs.ensureSymlink(srcPath, destPath);
52
- }
53
-
54
- async exec(execOptions: BitExecOption, exec = new ContainerExec()): Promise<ContainerExec> {
55
- const cwd = execOptions.cwd ? this.composePath(execOptions.cwd) : this.getPath();
56
- debug(`executing the following command: ${execOptions.command.join(' ')}, on cwd: ${cwd}`);
57
- const subprocessP = execa.command(execOptions.command.join(' '), {
58
- shell: true,
59
- cwd,
60
- stdio: ['ipc'],
61
- });
62
-
63
- // @TODO: FIX! This probably causes errors ad the promise is not handled properly!
64
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
65
- subprocessP.on('message', function (msg: any) {
66
- exec.emit('message', msg);
67
- });
68
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
69
- subprocessP.stderr?.pipe(exec.stderr);
70
- subprocessP.stdout?.pipe(exec.stdout);
71
- ['close', 'exit'].forEach(function (eventName: string) {
72
- // @TODO: FIX! This probably causes errors ad the promise is not handled properly!
73
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
74
- subprocessP.on(eventName, function (statusCode) {
75
- exec.setStatus(statusCode);
76
- });
77
- });
78
-
79
- return exec;
80
- }
81
-
82
- async execP(execOptions: BitExecOption): Promise<string> {
83
- let hasError = false;
84
- const exec = await this.exec(execOptions);
85
- return new Promise((resolve, reject) => {
86
- exec.stdout.on('error', () => {
87
- hasError = true;
88
- });
89
- exec.on('close', () => {
90
- if (hasError) reject(exec.stderr.getContents!(exec.stderr.size).toString());
91
- resolve(exec.stdout.getContents!(exec.stdout.size).toString());
92
- });
93
- });
94
- }
95
-
96
- async terminal() {
97
- const cwd = this.getPath();
98
- return execa.command(process.env.SHELL || '/bin/zsh', { cwd, stdio: 'inherit' });
99
- }
100
-
101
- start(): Promise<void> {
102
- return fs.ensureDir(this.wrkDir);
103
- }
104
- // @ts-ignore
105
- async inspect(): Promise<ContainerStatus> {
106
- // todo: probably not needed for this container
107
- }
108
- async pause(): Promise<void> {
109
- // do nothing
110
- }
111
- async resume(): Promise<void> {
112
- // do nothing
113
- }
114
- // eslint-disable-next-line
115
- stop(ttl?: number | undefined): Promise<void> {
116
- return fs.remove(this.wrkDir);
117
- }
118
- async destroy(): Promise<void> {
119
- await this.stop();
120
- }
121
- log(): Promise<Exec> {
122
- throw new Error('Method not implemented.');
123
- }
124
- on(event: string, fn: (data: any) => void): void {
125
- return fn(event);
126
- // throw new Error('Method not implemented.');
127
- }
128
- }
package/capsule/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { default as Capsule } from './capsule';
2
- export { default as FsContainer } from './container';
3
- export { default as ContainerExec } from './container-exec';
package/capsule-list.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { Component, ComponentID } from '@teambit/component';
2
- import { normalize } from 'path';
3
- import { BitId } from '@teambit/legacy-bit-id';
4
- import { Capsule } from './capsule';
5
-
6
- export default class CapsuleList extends Array<Capsule> {
7
- getCapsule(id: ComponentID): Capsule | undefined {
8
- return this.find((capsule) => capsule.component.id.isEqual(id));
9
- }
10
- getCapsuleByLegacyId(id: BitId): Capsule | undefined {
11
- return this.find((capsule) => capsule.component.id._legacy.isEqual(id));
12
- }
13
- getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined {
14
- return this.find((capsule) => capsule.component.id._legacy.isEqualWithoutVersion(id._legacy));
15
- }
16
- getCapsuleIgnoreScopeAndVersion(id: ComponentID): Capsule | undefined {
17
- return this.find((capsule) => capsule.component.id._legacy.isEqualWithoutScopeAndVersion(id._legacy));
18
- }
19
- getAllCapsuleDirs(): string[] {
20
- return this.map((capsule) => capsule.path);
21
- }
22
- getIdByPathInCapsule(pathInCapsule: string): ComponentID | null {
23
- const normalizedPathInCapsule = normalize(pathInCapsule);
24
- const found = this.find((capsule) => normalizedPathInCapsule === normalize(capsule.path));
25
- return found ? found.component.id : null;
26
- }
27
- getAllComponents(): Component[] {
28
- return this.map((c) => c.component);
29
- }
30
- static fromArray(capsules: Capsule[]) {
31
- return new CapsuleList(...capsules);
32
- }
33
- }
package/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export { IsolateComponentsOptions } from './isolator.main.runtime';
2
- export { Network } from './network';
3
- export { FsContainer, Capsule, ContainerExec } from './capsule';
4
- export type { IsolatorMain } from './isolator.main.runtime';
5
- export { IsolatorAspect } from './isolator.aspect';
6
- export { default as CapsuleList } from './capsule-list';
@@ -1,7 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const IsolatorAspect = Aspect.create({
4
- id: 'teambit.component/isolator',
5
- dependencies: [],
6
- defaultConfig: {},
7
- });
package/isolator.docs.md DELETED
@@ -1,41 +0,0 @@
1
- ---
2
- description: Isolate components for build, debugging, development and testing.
3
- labels: ['isolation', 'component']
4
- ---
5
-
6
- ## Isolate a component
7
-
8
- ```bash
9
- bit create-capsule ui/button
10
- ```
11
-
12
- ## Entities
13
-
14
- ### Capsule
15
-
16
- Bit implements a filesystem capsule, which is an isolated folder containing the component files.
17
- Capsules include the component files and links to other capsules that include the component's dependencies.
18
-
19
- ### Network
20
-
21
- A network is a group of capsules, related to one another by their dependencies.
22
- A network includes a graph of all seed components given to it, as well as a list of the capsules.
23
-
24
- Example:
25
-
26
- ```javascript
27
- const Network = {
28
- graph: Graph,
29
- capsules: CapsuleList,
30
- };
31
- ```
32
-
33
- ## API
34
-
35
- The exact particularities of this API are beyond the scope of this readme. Instead, this document opts to
36
- provide a general description of the methods of this API and their purpose.
37
-
38
- ### Isolator.isolateComponents
39
-
40
- This method receives a list of components, create capsule for the components and write the components data into the capsule.
41
- It returns a list of capsules.
@@ -1,520 +0,0 @@
1
- import { MainRuntime } from '@teambit/cli';
2
- import { compact, pick } from 'lodash';
3
- import { Component, ComponentMap, ComponentAspect, ComponentID } from '@teambit/component';
4
- import type { ComponentMain, ComponentFactory } from '@teambit/component';
5
- import { getComponentPackageVersion } from '@teambit/component-package-version';
6
- import { GraphAspect } from '@teambit/graph';
7
- import type { GraphBuilder } from '@teambit/graph';
8
- import {
9
- DependencyResolverAspect,
10
- DependencyResolverMain,
11
- LinkingOptions,
12
- WorkspacePolicy,
13
- InstallOptions,
14
- DependencyList,
15
- ComponentDependency,
16
- KEY_NAME_BY_LIFECYCLE_TYPE,
17
- } from '@teambit/dependency-resolver';
18
- import legacyLogger from '@teambit/legacy/dist/logger/logger';
19
- import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
20
- import { BitIds } from '@teambit/legacy/dist/bit-id';
21
- import LegacyScope from '@teambit/legacy/dist/scope/scope';
22
- import GlobalConfigAspect, { GlobalConfigMain } from '@teambit/global-config';
23
- import {
24
- CACHE_ROOT,
25
- DEPENDENCIES_FIELDS,
26
- PACKAGE_JSON,
27
- CFG_CAPSULES_ROOT_BASE_DIR,
28
- } from '@teambit/legacy/dist/constants';
29
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
30
- import PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';
31
- import { importMultipleDistsArtifacts } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
32
- import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
33
- import { Scope } from '@teambit/legacy/dist/scope';
34
- import fs from 'fs-extra';
35
- import hash from 'object-hash';
36
- import path from 'path';
37
- import equals from 'ramda/src/equals';
38
- import BitMap from '@teambit/legacy/dist/consumer/bit-map';
39
- import ComponentWriter, { ComponentWriterProps } from '@teambit/legacy/dist/consumer/component-ops/component-writer';
40
- import { Capsule } from './capsule';
41
- import CapsuleList from './capsule-list';
42
- import { IsolatorAspect } from './isolator.aspect';
43
- import { symlinkBitLegacyToCapsules } from './symlink-bit-legacy-to-capsules';
44
- import { symlinkOnCapsuleRoot, symlinkDependenciesToCapsules } from './symlink-dependencies-to-capsules';
45
- import { Network } from './network';
46
-
47
- const DEFAULT_CAPSULES_BASE_DIR = path.join(CACHE_ROOT, 'capsules'); // TODO: move elsewhere
48
-
49
- export type ListResults = {
50
- workspace: string;
51
- capsules: string[];
52
- };
53
-
54
- export type IsolateComponentsInstallOptions = {
55
- installPackages?: boolean; // default: true
56
- // TODO: add back when depResolver.getInstaller support it
57
- // packageManager?: string;
58
- dedupe?: boolean;
59
- copyPeerToRuntimeOnComponents?: boolean;
60
- copyPeerToRuntimeOnRoot?: boolean;
61
- installTeambitBit?: boolean;
62
- };
63
-
64
- type CreateGraphOptions = {
65
- /**
66
- * include components that exists in nested hosts. for example include components that exist in scope but not in the workspace
67
- */
68
- includeFromNestedHosts?: boolean;
69
-
70
- /**
71
- * Force specific host to get the component from.
72
- */
73
- host?: ComponentFactory;
74
- };
75
-
76
- export type IsolateComponentsOptions = CreateGraphOptions & {
77
- name?: string;
78
- /**
79
- * absolute path to put all the capsules dirs inside.
80
- */
81
- rootBaseDir?: string;
82
-
83
- /**
84
- * the capsule root-dir based on a *hash* of this baseDir, not on the baseDir itself.
85
- * A folder with this hash as its name will be created in the rootBaseDir
86
- * By default this value will be the host path
87
- */
88
- baseDir?: string;
89
-
90
- /**
91
- * create a new capsule with a random string attached to the path suffix
92
- */
93
- alwaysNew?: boolean;
94
-
95
- /**
96
- * installation options
97
- */
98
- installOptions?: IsolateComponentsInstallOptions;
99
-
100
- linkingOptions?: LinkingOptions;
101
-
102
- /**
103
- * delete the capsule rootDir first. it makes sure that the isolation process starts fresh with
104
- * no previous capsules. for build and tag this is true.
105
- */
106
- emptyRootDir?: boolean;
107
-
108
- /**
109
- * skip the reproduction of the capsule in case it exists.
110
- */
111
- skipIfExists?: boolean;
112
-
113
- /**
114
- * get existing capsule without doing any changes, no writes, no installations.
115
- */
116
- getExistingAsIs?: boolean;
117
-
118
- /**
119
- * place the package-manager cache on the capsule-root
120
- */
121
- cachePackagesOnCapsulesRoot?: boolean;
122
-
123
- /**
124
- * do not build graph with all dependencies. isolate the seeders only.
125
- */
126
- seedersOnly?: boolean;
127
-
128
- /**
129
- * Force specific host to get the component from.
130
- */
131
- host?: ComponentFactory;
132
- };
133
-
134
- type CapsulePackageJsonData = {
135
- capsule: Capsule;
136
- currentPackageJson?: Record<string, any>;
137
- previousPackageJson: Record<string, any> | null;
138
- };
139
-
140
- const DEFAULT_ISOLATE_INSTALL_OPTIONS: IsolateComponentsInstallOptions = {
141
- installPackages: true,
142
- dedupe: true,
143
- copyPeerToRuntimeOnComponents: false,
144
- copyPeerToRuntimeOnRoot: true,
145
- };
146
-
147
- export class IsolatorMain {
148
- static runtime = MainRuntime;
149
- static dependencies = [DependencyResolverAspect, LoggerAspect, ComponentAspect, GraphAspect, GlobalConfigAspect];
150
- static defaultConfig = {};
151
- _componentsPackagesVersionCache: { [idStr: string]: string } = {}; // cache packages versions of components
152
-
153
- static async provider([dependencyResolver, loggerExtension, componentAspect, graphAspect, globalConfig]: [
154
- DependencyResolverMain,
155
- LoggerMain,
156
- ComponentMain,
157
- GraphBuilder,
158
- GlobalConfigMain
159
- ]): Promise<IsolatorMain> {
160
- const logger = loggerExtension.createLogger(IsolatorAspect.id);
161
- const isolator = new IsolatorMain(dependencyResolver, logger, componentAspect, graphAspect, globalConfig);
162
- return isolator;
163
- }
164
- constructor(
165
- private dependencyResolver: DependencyResolverMain,
166
- private logger: Logger,
167
- private componentAspect: ComponentMain,
168
- private graphBuilder: GraphBuilder,
169
- private globalConfig: GlobalConfigMain
170
- ) {}
171
-
172
- // TODO: the legacy scope used for the component writer, which then decide if it need to write the artifacts and dists
173
- // TODO: we should think of another way to provide it (maybe a new opts) then take the scope internally from the host
174
- async isolateComponents(
175
- seeders: ComponentID[],
176
- opts: IsolateComponentsOptions = {},
177
- legacyScope?: LegacyScope
178
- ): Promise<Network> {
179
- const host = this.componentAspect.getHost();
180
- const longProcessLogger = this.logger.createLongProcessLogger('create capsules network');
181
- legacyLogger.debug(
182
- `isolatorExt, createNetwork ${seeders.join(', ')}. opts: ${JSON.stringify(
183
- Object.assign({}, opts, { host: opts.host?.name })
184
- )}`
185
- );
186
- const createGraphOpts = pick(opts, ['includeFromNestedHosts', 'host']);
187
- const componentsToIsolate = opts.seedersOnly
188
- ? await host.getMany(seeders)
189
- : await this.createGraph(seeders, createGraphOpts);
190
- opts.baseDir = opts.baseDir || host.path;
191
- const capsuleList = await this.createCapsules(componentsToIsolate, opts, legacyScope);
192
- longProcessLogger.end();
193
- this.logger.consoleSuccess();
194
- return new Network(capsuleList, seeders, this.getCapsulesRootDir(opts.baseDir, opts.rootBaseDir));
195
- }
196
-
197
- private async createGraph(seeders: ComponentID[], opts: CreateGraphOptions = {}): Promise<Component[]> {
198
- const host = this.componentAspect.getHost();
199
- const getGraphOpts = pick(opts, ['host']);
200
- const graph = await this.graphBuilder.getGraph(seeders, getGraphOpts);
201
- const successorsSubgraph = graph.successorsSubgraph(seeders.map((id) => id.toString()));
202
- const compsAndDeps = successorsSubgraph.nodes.map((node) => node.attr);
203
- // do not ignore the version here. a component might be in .bitmap with one version and
204
- // installed as a package with another version. we don't want them both.
205
- const existingCompsP = compsAndDeps.map(async (c) => {
206
- let existing;
207
- if (opts.includeFromNestedHosts) {
208
- existing = await host.hasIdNested(c.id, true);
209
- } else {
210
- existing = await host.hasId(c.id);
211
- }
212
- if (existing) return c;
213
- return undefined;
214
- });
215
- const existingComps = await Promise.all(existingCompsP);
216
- return compact(existingComps);
217
- }
218
-
219
- /**
220
- * Create capsules for the provided components
221
- * do not use this outside directly, use isolate components which build the entire network
222
- * @param components
223
- * @param opts
224
- * @param legacyScope
225
- */
226
- private async createCapsules(
227
- components: Component[],
228
- opts: IsolateComponentsOptions,
229
- legacyScope?: Scope
230
- ): Promise<CapsuleList> {
231
- const config = { installPackages: true, ...opts };
232
- const capsulesDir = this.getCapsulesRootDir(opts.baseDir as string, opts.rootBaseDir);
233
- if (opts.emptyRootDir) {
234
- await fs.emptyDir(capsulesDir);
235
- }
236
- const capsules = await this.createCapsulesFromComponents(components, capsulesDir, config);
237
- const capsuleList = CapsuleList.fromArray(capsules);
238
- if (opts.getExistingAsIs) {
239
- return capsuleList;
240
- }
241
-
242
- if (opts.skipIfExists) {
243
- const existingCapsules = CapsuleList.fromArray(
244
- capsuleList.filter((capsule) => capsule.fs.existsSync('package.json'))
245
- );
246
-
247
- if (existingCapsules.length === capsuleList.length) return existingCapsules;
248
- }
249
- const capsulesWithPackagesData = await this.getCapsulesPreviousPackageJson(capsules);
250
-
251
- await this.writeComponentsInCapsules(components, capsuleList, legacyScope);
252
- await this.updateWithCurrentPackageJsonData(capsulesWithPackagesData, capsuleList);
253
- const installOptions = Object.assign({}, DEFAULT_ISOLATE_INSTALL_OPTIONS, opts.installOptions || {});
254
- if (installOptions.installPackages) {
255
- await this.installInCapsules(capsulesDir, capsuleList, installOptions, opts.cachePackagesOnCapsulesRoot ?? false);
256
- await this.linkInCapsules(capsulesDir, capsuleList, capsulesWithPackagesData, opts.linkingOptions ?? {});
257
- }
258
-
259
- // rewrite the package-json with the component dependencies in it. the original package.json
260
- // that was written before, didn't have these dependencies in order for the package-manager to
261
- // be able to install them without crushing when the versions don't exist yet
262
- capsulesWithPackagesData.forEach((capsuleWithPackageData) => {
263
- capsuleWithPackageData.capsule.fs.writeFileSync(
264
- PACKAGE_JSON,
265
- JSON.stringify(capsuleWithPackageData.currentPackageJson, null, 2)
266
- );
267
- });
268
-
269
- return capsuleList;
270
- }
271
-
272
- private async installInCapsules(
273
- capsulesDir: string,
274
- capsuleList: CapsuleList,
275
- isolateInstallOptions: IsolateComponentsInstallOptions,
276
- cachePackagesOnCapsulesRoot: boolean
277
- ) {
278
- const installer = this.dependencyResolver.getInstaller({
279
- rootDir: capsulesDir,
280
- cacheRootDirectory: cachePackagesOnCapsulesRoot ? capsulesDir : undefined,
281
- });
282
- // When using isolator we don't want to use the policy defined in the workspace directly,
283
- // we only want to instal deps from components and the peer from the workspace
284
-
285
- const peerOnlyPolicy = this.getPeersOnlyPolicy();
286
- const installOptions: InstallOptions = {
287
- installTeambitBit: !!isolateInstallOptions.installTeambitBit,
288
- };
289
- const packageManagerInstallOptions = {
290
- dedupe: isolateInstallOptions.dedupe,
291
- copyPeerToRuntimeOnComponents: isolateInstallOptions.copyPeerToRuntimeOnComponents,
292
- copyPeerToRuntimeOnRoot: isolateInstallOptions.copyPeerToRuntimeOnRoot,
293
- };
294
- await installer.install(
295
- capsulesDir,
296
- peerOnlyPolicy,
297
- this.toComponentMap(capsuleList),
298
- installOptions,
299
- packageManagerInstallOptions
300
- );
301
- }
302
-
303
- private async linkInCapsules(
304
- capsulesDir: string,
305
- capsuleList: CapsuleList,
306
- capsulesWithPackagesData: CapsulePackageJsonData[],
307
- linkingOptions: LinkingOptions
308
- ) {
309
- const linker = this.dependencyResolver.getLinker({
310
- rootDir: capsulesDir,
311
- linkingOptions,
312
- });
313
- const peerOnlyPolicy = this.getPeersOnlyPolicy();
314
- const capsulesWithModifiedPackageJson = this.getCapsulesWithModifiedPackageJson(capsulesWithPackagesData);
315
- await linker.link(capsulesDir, peerOnlyPolicy, this.toComponentMap(capsuleList), {
316
- ...linkingOptions,
317
- legacyLink: false,
318
- });
319
- await symlinkOnCapsuleRoot(capsuleList, this.logger, capsulesDir);
320
- await symlinkDependenciesToCapsules(capsulesWithModifiedPackageJson, capsuleList, this.logger);
321
- // TODO: this is a hack to have access to the bit bin project in order to access core extensions from user extension
322
- // TODO: remove this after exporting core extensions as components
323
- await symlinkBitLegacyToCapsules(capsulesWithModifiedPackageJson, this.logger);
324
- // await copyBitLegacyToCapsuleRoot(capsulesDir, this.logger);
325
- }
326
-
327
- private getCapsulesWithModifiedPackageJson(capsulesWithPackagesData: CapsulePackageJsonData[]) {
328
- const capsulesWithModifiedPackageJson: Capsule[] = capsulesWithPackagesData
329
- .filter((capsuleWithPackageData) => {
330
- const packageJsonHasChanged = this.wereDependenciesInPackageJsonChanged(capsuleWithPackageData);
331
- // @todo: when a component is tagged, it changes all package-json of its dependents, but it
332
- // should not trigger any "npm install" because they dependencies are symlinked by us
333
- return packageJsonHasChanged;
334
- })
335
- .map((capsuleWithPackageData) => capsuleWithPackageData.capsule);
336
- return capsulesWithModifiedPackageJson;
337
- }
338
-
339
- private async writeComponentsInCapsules(components: Component[], capsuleList: CapsuleList, legacyScope?: Scope) {
340
- const legacyComponents = components.map((component) => component.state._consumer.clone());
341
- if (legacyScope) await importMultipleDistsArtifacts(legacyScope, legacyComponents);
342
- const allIds = BitIds.fromArray(legacyComponents.map((c) => c.id));
343
- await Promise.all(
344
- components.map(async (component) => {
345
- const capsule = capsuleList.getCapsule(component.id);
346
- if (!capsule) return;
347
- const params = this.getComponentWriteParams(component.state._consumer, allIds, legacyScope);
348
- const componentWriter = new ComponentWriter(params);
349
- await componentWriter.populateComponentsFilesToWrite();
350
- await component.state._consumer.dataToPersist.persistAllToCapsule(capsule, { keepExistingCapsule: true });
351
- })
352
- );
353
- }
354
-
355
- private getPeersOnlyPolicy(): WorkspacePolicy {
356
- const workspacePolicy = this.dependencyResolver.getWorkspacePolicy();
357
- const peerOnlyPolicy = workspacePolicy.byLifecycleType('peer');
358
- return peerOnlyPolicy;
359
- }
360
-
361
- private getComponentWriteParams(
362
- component: ConsumerComponent,
363
- ids: BitIds,
364
- legacyScope?: Scope
365
- ): ComponentWriterProps {
366
- return {
367
- component,
368
- // @ts-ignore
369
- bitMap: new BitMap(undefined, undefined, undefined, false),
370
- writeToPath: '.',
371
- origin: 'IMPORTED',
372
- consumer: undefined,
373
- scope: legacyScope,
374
- override: false,
375
- writePackageJson: true,
376
- writeConfig: false,
377
- ignoreBitDependencies: ids,
378
- excludeRegistryPrefix: false,
379
- isolated: true,
380
- };
381
- }
382
-
383
- private toComponentMap(capsuleList: CapsuleList): ComponentMap<string> {
384
- const tuples: [Component, string][] = capsuleList.map((capsule) => {
385
- return [capsule.component, capsule.path];
386
- });
387
-
388
- return ComponentMap.create(tuples);
389
- }
390
-
391
- async list(workspacePath: string): Promise<ListResults> {
392
- try {
393
- const workspaceCapsuleFolder = this.getCapsulesRootDir(workspacePath);
394
- const capsules = await fs.readdir(workspaceCapsuleFolder);
395
- const capsuleFullPaths = capsules.map((c) => path.join(workspaceCapsuleFolder, c));
396
- return {
397
- workspace: workspacePath,
398
- capsules: capsuleFullPaths,
399
- };
400
- } catch (e: any) {
401
- if (e.code === 'ENOENT') {
402
- return { workspace: workspacePath, capsules: [] };
403
- }
404
- throw e;
405
- }
406
- }
407
-
408
- getCapsulesRootDir(baseDir: string, rootBaseDir?: string): PathOsBasedAbsolute {
409
- const capsulesRootBaseDir =
410
- rootBaseDir || this.globalConfig.getSync(CFG_CAPSULES_ROOT_BASE_DIR) || DEFAULT_CAPSULES_BASE_DIR;
411
- return path.join(capsulesRootBaseDir, hash(baseDir));
412
- }
413
-
414
- private async createCapsulesFromComponents(
415
- components: Component[],
416
- baseDir: string,
417
- opts: IsolateComponentsOptions
418
- ): Promise<Capsule[]> {
419
- const capsules: Capsule[] = await Promise.all(
420
- components.map((component: Component) => {
421
- return Capsule.createFromComponent(component, baseDir, opts);
422
- })
423
- );
424
- return capsules;
425
- }
426
-
427
- private wereDependenciesInPackageJsonChanged(capsuleWithPackageData: CapsulePackageJsonData): boolean {
428
- const { previousPackageJson, currentPackageJson } = capsuleWithPackageData;
429
- if (!previousPackageJson) return true;
430
- // @ts-ignore at this point, currentPackageJson is set
431
- return DEPENDENCIES_FIELDS.some((field) => !equals(previousPackageJson[field], currentPackageJson[field]));
432
- }
433
-
434
- private async getCapsulesPreviousPackageJson(capsules: Capsule[]): Promise<CapsulePackageJsonData[]> {
435
- return Promise.all(
436
- capsules.map(async (capsule) => {
437
- const packageJsonPath = path.join(capsule.path, 'package.json');
438
- let previousPackageJson: any = null;
439
- try {
440
- const previousPackageJsonRaw = await capsule.fs.promises.readFile(packageJsonPath, { encoding: 'utf8' });
441
- previousPackageJson = JSON.parse(previousPackageJsonRaw);
442
- } catch (e: any) {
443
- // package-json doesn't exist in the capsule, that's fine, it'll be considered as a cache miss
444
- }
445
- return {
446
- capsule,
447
- previousPackageJson,
448
- };
449
- })
450
- );
451
- }
452
-
453
- private async updateWithCurrentPackageJsonData(
454
- capsulesWithPackagesData: CapsulePackageJsonData[],
455
- capsules: CapsuleList
456
- ) {
457
- const updateP = capsules.map(async (capsule) => {
458
- const packageJson = await this.getCurrentPackageJson(capsule, capsules);
459
- const found = capsulesWithPackagesData.find((c) => c.capsule.component.id.isEqual(capsule.component.id));
460
- if (!found) throw new Error(`updateWithCurrentPackageJsonData unable to find ${capsule.component.id}`);
461
- found.currentPackageJson = packageJson.packageJsonObject;
462
- });
463
- return Promise.all(updateP);
464
- }
465
-
466
- private async getCurrentPackageJson(capsule: Capsule, capsules: CapsuleList): Promise<PackageJsonFile> {
467
- const component: Component = capsule.component;
468
- const currentVersion = await this.getComponentPackageVersionWithCache(component);
469
- // const newVersion = '0.0.1-new';
470
- const getComponentDepsManifest = async (dependencies: DependencyList) => {
471
- const manifest = {
472
- dependencies: {},
473
- devDependencies: {},
474
- };
475
- const compDeps = dependencies.toTypeArray<ComponentDependency>('component');
476
- const promises = compDeps.map(async (dep) => {
477
- const depCapsule = capsules.getCapsule(dep.componentId);
478
- let version = dep.version;
479
- if (depCapsule) {
480
- version = await this.getComponentPackageVersionWithCache(depCapsule?.component);
481
- }
482
- const keyName = KEY_NAME_BY_LIFECYCLE_TYPE[dep.lifecycle];
483
- const entry = dep.toManifest();
484
- if (entry) {
485
- manifest[keyName][entry.packageName] = version;
486
- }
487
- });
488
- await Promise.all(promises);
489
- return manifest;
490
- };
491
- const deps = await this.dependencyResolver.getDependencies(component);
492
- const manifest = await getComponentDepsManifest(deps);
493
-
494
- // unfortunately, component.packageJsonFile is not available here.
495
- // the reason is that `writeComponentsToCapsules` clones the component before writing them
496
- // also, don't use `PackageJsonFile.createFromComponent`, as it looses the intermediate changes
497
- // such as postInstall scripts for custom-module-resolution.
498
- const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);
499
-
500
- const addDependencies = (packageJsonFile: PackageJsonFile) => {
501
- packageJsonFile.addDependencies(manifest.dependencies);
502
- packageJsonFile.addDevDependencies(manifest.devDependencies);
503
- };
504
- addDependencies(packageJson);
505
- packageJson.addOrUpdateProperty('version', currentVersion);
506
- return packageJson;
507
- }
508
-
509
- private async getComponentPackageVersionWithCache(component: Component): Promise<string> {
510
- const idStr = component.id.toString();
511
- if (this._componentsPackagesVersionCache[idStr]) {
512
- return this._componentsPackagesVersionCache[idStr];
513
- }
514
- const version = await getComponentPackageVersion(component);
515
- this._componentsPackagesVersionCache[idStr] = version;
516
- return version;
517
- }
518
- }
519
-
520
- IsolatorAspect.addRuntime(IsolatorMain);
package/network.ts DELETED
@@ -1,35 +0,0 @@
1
- import { ComponentID } from '@teambit/component';
2
- import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
3
- import CapsuleList from './capsule-list';
4
-
5
- export class Network {
6
- constructor(
7
- private _graphCapsules: CapsuleList,
8
- private seedersIds: ComponentID[],
9
- private _capsulesRootDir: string
10
- ) {}
11
-
12
- /**
13
- * seeders capsules only without the entire graph. normally, this includes the capsules of one
14
- * env.
15
- */
16
- get seedersCapsules(): CapsuleList {
17
- const capsules = this.seedersIds.map((seederId) => {
18
- const capsule = this.graphCapsules.getCapsule(seederId);
19
- if (!capsule) throw new Error(`unable to find ${seederId.toString()} in the capsule list`);
20
- return capsule;
21
- });
22
- return CapsuleList.fromArray(capsules);
23
- }
24
-
25
- /**
26
- * all capsules, including the dependencies of the seeders. (even when they belong to another env)
27
- */
28
- get graphCapsules(): CapsuleList {
29
- return this._graphCapsules;
30
- }
31
-
32
- get capsulesRootDir(): PathOsBasedAbsolute {
33
- return this._capsulesRootDir;
34
- }
35
- }
@@ -1,53 +0,0 @@
1
- import { Logger } from '@teambit/logger';
2
- import createSymlinkOrCopy from '@teambit/legacy/dist/utils/fs/create-symlink-or-copy';
3
- import fs from 'fs-extra';
4
- import path from 'path';
5
-
6
- import { Capsule } from './capsule';
7
-
8
- export async function symlinkBitLegacyToCapsules(capsules: Capsule[], logger: Logger) {
9
- logger.debug(`symlink bit bin to capsules, ${capsules.length} capsules`);
10
- const linksP = capsules.map(async (capsule) => linkBitLegacyInCapsule(capsule));
11
- return Promise.all(linksP);
12
- }
13
-
14
- export async function copyBitLegacyToCapsuleRoot(root: string, logger: Logger) {
15
- logger.debug(`symlink @teambit/legacy package to capsule root`);
16
- const localBitLegacyPath = path.join(__dirname, '@teambit/legacy/dist/..');
17
- const targetPath = path.join(root, './node_modules/@teambit/legacy');
18
- await fs.copy(localBitLegacyPath, targetPath);
19
- }
20
-
21
- async function linkBitLegacyInCapsule(capsule: Capsule) {
22
- const bitLegacyPath = path.join(capsule.wrkDir, './node_modules/@teambit/legacy');
23
- const getLocalBitLegacyPath = () => {
24
- const pathOutsideNodeModules = path.join(__dirname, '@teambit/legacy/dist/..');
25
- const dirInIsolator = path.normalize('node_modules/@teambit/isolator/dist/@teambit/legacy');
26
- if (pathOutsideNodeModules.includes(dirInIsolator)) {
27
- return pathOutsideNodeModules.replace(dirInIsolator, '');
28
- }
29
- return pathOutsideNodeModules;
30
- // if (pathOutsideNodeModules.endsWith(`${path.sep}dist`)) {
31
- // return pathOutsideNodeModules;
32
- // }
33
- // if (__dirname.includes('build-harmony')) {
34
- // // for @teambit/legacy development, the cli extension is installed as a package in build-harmony directory
35
- // return path.join(__dirname.split('build-harmony')[0], 'dist');
36
- // }
37
- // throw new Error('unable to link @teambit/legacy to the capsule, the location of @teambit/legacy is unknown');
38
- };
39
- const localBitLegacyPath = getLocalBitLegacyPath();
40
- // if there are no deps, sometimes the node_modules folder is not created
41
- // and we need it in order to perform the linking
42
- try {
43
- capsule.fs.mkdirSync('node_modules');
44
- } catch (e: any) {
45
- // fail silently - we only need to create it if it doesn't already exist
46
- }
47
-
48
- // we use fs directly here rather than the capsule.fs because there are some edge cases
49
- // that the capsule fs does not deal with well (eg. identifying and deleting
50
- // a symlink rather than the what the symlink links to)
51
- await fs.remove(bitLegacyPath);
52
- createSymlinkOrCopy(localBitLegacyPath, bitLegacyPath);
53
- }
@@ -1,58 +0,0 @@
1
- import { ComponentID } from '@teambit/component';
2
- import { Logger } from '@teambit/logger';
3
- import { BitId } from '@teambit/legacy-bit-id';
4
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
5
- import Symlink from '@teambit/legacy/dist/links/symlink';
6
- import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
7
- import path from 'path';
8
-
9
- import { Capsule } from './capsule';
10
- import CapsuleList from './capsule-list';
11
-
12
- export async function symlinkDependenciesToCapsules(capsules: Capsule[], capsuleList: CapsuleList, logger: Logger) {
13
- logger.debug(`symlinkDependenciesToCapsules, ${capsules.length} capsules`);
14
- await Promise.all(
15
- capsules.map((capsule) => {
16
- return symlinkComponent(capsule.component.state._consumer, capsuleList, logger);
17
- })
18
- );
19
- }
20
-
21
- export async function symlinkOnCapsuleRoot(capsuleList: CapsuleList, logger: Logger, capsuleRoot: string) {
22
- const modulesPath = path.join(capsuleRoot, 'node_modules');
23
- const symlinks = capsuleList.map((capsule) => {
24
- const packageName = componentIdToPackageName(capsule.component.state._consumer);
25
- const dest = path.join(modulesPath, packageName);
26
- const src = path.relative(path.resolve(dest, '..'), capsule.path);
27
-
28
- return new Symlink(src, dest, capsule.component.id._legacy);
29
- });
30
-
31
- await Promise.all(symlinks.map((symlink) => symlink.write()));
32
- }
33
-
34
- async function symlinkComponent(component: ConsumerComponent, capsuleList: CapsuleList, logger: Logger) {
35
- const componentCapsule = capsuleList.getCapsuleIgnoreScopeAndVersion(new ComponentID(component.id));
36
- if (!componentCapsule) throw new Error(`unable to find the capsule for ${component.id.toString()}`);
37
- const allDeps = component.getAllDependenciesIds();
38
- const symlinks = allDeps.map((depId: BitId) => {
39
- // TODO: this is dangerous - we might have 2 capsules for the same component with different version, then we might link to the wrong place
40
- const devCapsule = capsuleList.getCapsuleIgnoreScopeAndVersion(new ComponentID(depId));
41
- if (!devCapsule) {
42
- // happens when a dependency is not in the workspace. (it gets installed via the package manager)
43
- logger.debug(
44
- `symlinkComponentToCapsule: unable to find the capsule for ${depId.toStringWithoutVersion()}. skipping`
45
- );
46
- return null;
47
- }
48
- const packageName = componentIdToPackageName(devCapsule.component.state._consumer);
49
- const devCapsulePath = devCapsule.path;
50
- // @todo: this is a hack, the capsule should be the one responsible to symlink, this works only for FS capsules.
51
- const dest = path.join(componentCapsule.path, 'node_modules', packageName);
52
- // use relative symlink in capsules to make it really isolated from the machine fs
53
- const src = path.relative(path.resolve(dest, '..'), devCapsulePath);
54
- return new Symlink(src, dest, component.id);
55
- });
56
-
57
- await Promise.all(symlinks.map((symlink) => symlink && symlink.write()));
58
- }
package/tsconfig.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
9
- ],
10
- "target": "es2015",
11
- "module": "commonjs",
12
- "jsx": "react",
13
- "declaration": true,
14
- "sourceMap": true,
15
- "skipLibCheck": true,
16
- "moduleResolution": "node",
17
- "esModuleInterop": true,
18
- "outDir": "dist",
19
- "composite": true,
20
- "emitDeclarationOnly": true,
21
- "experimentalDecorators": true,
22
- "emitDecoratorMetadata": true,
23
- "allowSyntheticDefaultImports": true,
24
- "strictPropertyInitialization": false,
25
- "strict": true,
26
- "noImplicitAny": false,
27
- "rootDir": ".",
28
- "preserveConstEnums": true,
29
- "resolveJsonModule": true
30
- },
31
- "exclude": [
32
- "dist"
33
- ]
34
- }
package/types/asset.d.ts DELETED
@@ -1,29 +0,0 @@
1
- declare module '*.png' {
2
- const value: any;
3
- export = value;
4
- }
5
- declare module '*.svg' {
6
- import type { FunctionComponent, SVGProps } from 'react';
7
-
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
- const src: string;
10
- export default src;
11
- }
12
-
13
- // @TODO Gilad
14
- declare module '*.jpg' {
15
- const value: any;
16
- export = value;
17
- }
18
- declare module '*.jpeg' {
19
- const value: any;
20
- export = value;
21
- }
22
- declare module '*.gif' {
23
- const value: any;
24
- export = value;
25
- }
26
- declare module '*.bmp' {
27
- const value: any;
28
- export = value;
29
- }
package/types/style.d.ts DELETED
@@ -1,42 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: { readonly [key: string]: string };
3
- export default classes;
4
- }
5
- declare module '*.module.scss' {
6
- const classes: { readonly [key: string]: string };
7
- export default classes;
8
- }
9
- declare module '*.module.sass' {
10
- const classes: { readonly [key: string]: string };
11
- export default classes;
12
- }
13
-
14
- declare module '*.module.less' {
15
- const classes: { readonly [key: string]: string };
16
- export default classes;
17
- }
18
-
19
- declare module '*.less' {
20
- const classes: { readonly [key: string]: string };
21
- export default classes;
22
- }
23
-
24
- declare module '*.css' {
25
- const classes: { readonly [key: string]: string };
26
- export default classes;
27
- }
28
-
29
- declare module '*.sass' {
30
- const classes: { readonly [key: string]: string };
31
- export default classes;
32
- }
33
-
34
- declare module '*.scss' {
35
- const classes: { readonly [key: string]: string };
36
- export default classes;
37
- }
38
-
39
- declare module '*.mdx' {
40
- const component: any;
41
- export default component;
42
- }