@teambit/preview.cli.webpack-events-listener 0.0.0-60fb6aca309851b5c17cb070bf3a2efa31833414

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.
@@ -0,0 +1,2 @@
1
+ export { SubscribeToWebpackEvents } from './webpack-events-listener';
2
+ export type { CompilationResult, Handlers } from './webpack-events-listener';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscribeToWebpackEvents = void 0;
4
+ var webpack_events_listener_1 = require("./webpack-events-listener");
5
+ Object.defineProperty(exports, "SubscribeToWebpackEvents", { enumerable: true, get: function () { return webpack_events_listener_1.SubscribeToWebpackEvents; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AAA5D,mIAAA,wBAAwB,OAAA"}
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,20 @@
1
+ import type { PubsubMain } from '@teambit/pubsub';
2
+ export type CompilationResult = {
3
+ errors?: Error[];
4
+ warnings?: Error[];
5
+ compiling: boolean;
6
+ };
7
+ export type Handlers = {
8
+ /**
9
+ * emitted when compilation completes. Might happen after server is already up and running.
10
+ */
11
+ onDone?: (serverId: string, stats: CompilationResult) => void;
12
+ /**
13
+ * happens whenever compilation starts, e.g. when a file changes, or on initial compilation
14
+ */
15
+ onStart?: (serverId: string) => void;
16
+ };
17
+ /**
18
+ * Listen for Webpack compilation pub sub events.
19
+ */
20
+ export declare function SubscribeToWebpackEvents(pubsub: PubsubMain, handlers?: Handlers): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscribeToWebpackEvents = SubscribeToWebpackEvents;
4
+ const webpack_1 = require("@teambit/webpack");
5
+ /**
6
+ * Listen for Webpack compilation pub sub events.
7
+ */
8
+ function SubscribeToWebpackEvents(pubsub, handlers = {}) {
9
+ pubsub.sub(webpack_1.WebpackAspect.id, (event) => {
10
+ var _a, _b;
11
+ if (event.type === webpack_1.WebpackCompilationDoneEvent.TYPE) {
12
+ const { stats, devServerID } = event.data;
13
+ const results = {
14
+ errors: stats.compilation.errors,
15
+ warnings: stats.compilation.warnings,
16
+ compiling: false,
17
+ };
18
+ (_a = handlers.onDone) === null || _a === void 0 ? void 0 : _a.call(handlers, devServerID, results);
19
+ }
20
+ if (event.type === webpack_1.WebpackCompilationStartedEvent.TYPE) {
21
+ const { devServerID } = event.data;
22
+ (_b = handlers.onStart) === null || _b === void 0 ? void 0 : _b.call(handlers, devServerID);
23
+ }
24
+ });
25
+ }
26
+ //# sourceMappingURL=webpack-events-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack-events-listener.js","sourceRoot":"","sources":["../webpack-events-listener.ts"],"names":[],"mappings":";;AAuBA,4DAmBC;AA1CD,8CAA8G;AAoB9G;;GAEG;AACH,SAAgB,wBAAwB,CAAC,MAAkB,EAAE,WAAqB,EAAE;IAClF,MAAM,CAAC,GAAG,CAAC,uBAAa,CAAC,EAAE,EAAE,CAAC,KAAwB,EAAE,EAAE;;QACxD,IAAI,KAAK,CAAC,IAAI,KAAK,qCAA2B,CAAC,IAAI,EAAE,CAAC;YACpD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;YAE1C,MAAM,OAAO,GAAG;gBACd,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM;gBAChC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ;gBACpC,SAAS,EAAE,KAAK;aACjB,CAAC;YAEF,MAAA,QAAQ,CAAC,MAAM,yDAAG,WAAW,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,wCAA8B,CAAC,IAAI,EAAE,CAAC;YACvD,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;YACnC,MAAA,QAAQ,CAAC,OAAO,yDAAG,WAAW,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { SubscribeToWebpackEvents } from './webpack-events-listener';
2
+ export type { CompilationResult, Handlers } from './webpack-events-listener';
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@teambit/preview.cli.webpack-events-listener",
3
+ "version": "0.0.0-60fb6aca309851b5c17cb070bf3a2efa31833414",
4
+ "homepage": "https://bit.cloud/teambit/preview/cli/webpack-events-listener",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.preview",
8
+ "name": "cli/webpack-events-listener",
9
+ "version": "60fb6aca309851b5c17cb070bf3a2efa31833414"
10
+ },
11
+ "dependencies": {},
12
+ "devDependencies": {
13
+ "@types/mocha": "9.1.0",
14
+ "@types/jest": "26.0.20",
15
+ "@types/node": "22.10.5"
16
+ },
17
+ "peerDependencies": {},
18
+ "license": "Apache-2.0",
19
+ "optionalDependencies": {},
20
+ "peerDependenciesMeta": {},
21
+ "private": false,
22
+ "engines": {
23
+ "node": ">=12.22.0"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/teambit/bit"
28
+ },
29
+ "keywords": [
30
+ "bit",
31
+ "components",
32
+ "collaboration",
33
+ "web",
34
+ "react",
35
+ "react-components",
36
+ "angular",
37
+ "angular-components"
38
+ ]
39
+ }
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,43 @@
1
+ import { WebpackAspect, WebpackCompilationDoneEvent, WebpackCompilationStartedEvent } from '@teambit/webpack';
2
+ import type { PubsubMain, BitBaseEvent } from '@teambit/pubsub';
3
+
4
+ export type CompilationResult = {
5
+ errors?: Error[];
6
+ warnings?: Error[];
7
+ compiling: boolean;
8
+ };
9
+
10
+ export type Handlers = {
11
+ /**
12
+ * emitted when compilation completes. Might happen after server is already up and running.
13
+ */
14
+ onDone?: (serverId: string, stats: CompilationResult) => void;
15
+ /**
16
+ * happens whenever compilation starts, e.g. when a file changes, or on initial compilation
17
+ */
18
+ onStart?: (serverId: string) => void;
19
+ };
20
+
21
+ /**
22
+ * Listen for Webpack compilation pub sub events.
23
+ */
24
+ export function SubscribeToWebpackEvents(pubsub: PubsubMain, handlers: Handlers = {}) {
25
+ pubsub.sub(WebpackAspect.id, (event: BitBaseEvent<any>) => {
26
+ if (event.type === WebpackCompilationDoneEvent.TYPE) {
27
+ const { stats, devServerID } = event.data;
28
+
29
+ const results = {
30
+ errors: stats.compilation.errors,
31
+ warnings: stats.compilation.warnings,
32
+ compiling: false,
33
+ };
34
+
35
+ handlers.onDone?.(devServerID, results);
36
+ }
37
+
38
+ if (event.type === WebpackCompilationStartedEvent.TYPE) {
39
+ const { devServerID } = event.data;
40
+ handlers.onStart?.(devServerID);
41
+ }
42
+ });
43
+ }