@teambit/preview.cli.webpack-events-listener 0.0.0-5aa6db2c5c0b7667f28024dece927a09f1f95d01

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,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SubscribeToWebpackEvents", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _webpackEventsListener().SubscribeToWebpackEvents;
10
+ }
11
+ });
12
+ function _webpackEventsListener() {
13
+ const data = require("./webpack-events-listener");
14
+ _webpackEventsListener = function () {
15
+ return data;
16
+ };
17
+ return data;
18
+ }
19
+
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_webpackEventsListener","data","require"],"sources":["index.ts"],"sourcesContent":["export { SubscribeToWebpackEvents } from './webpack-events-listener';\nexport type { CompilationResult, Handlers } from './webpack-events-listener';\n"],"mappings":";;;;;;;;;;;AAAA,SAAAA,uBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,sBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
@@ -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,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SubscribeToWebpackEvents = SubscribeToWebpackEvents;
7
+ function _webpack() {
8
+ const data = require("@teambit/webpack");
9
+ _webpack = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ /**
15
+ * Listen for Webpack compilation pub sub events.
16
+ */
17
+ function SubscribeToWebpackEvents(pubsub, handlers = {}) {
18
+ pubsub.sub(_webpack().WebpackAspect.id, event => {
19
+ if (event.type === _webpack().WebpackCompilationDoneEvent.TYPE) {
20
+ const {
21
+ stats,
22
+ devServerID
23
+ } = event.data;
24
+ const results = {
25
+ errors: stats.compilation.errors,
26
+ warnings: stats.compilation.warnings,
27
+ compiling: false
28
+ };
29
+ handlers.onDone?.(devServerID, results);
30
+ }
31
+ if (event.type === _webpack().WebpackCompilationStartedEvent.TYPE) {
32
+ const {
33
+ devServerID
34
+ } = event.data;
35
+ handlers.onStart?.(devServerID);
36
+ }
37
+ });
38
+ }
39
+
40
+ //# sourceMappingURL=webpack-events-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_webpack","data","require","SubscribeToWebpackEvents","pubsub","handlers","sub","WebpackAspect","id","event","type","WebpackCompilationDoneEvent","TYPE","stats","devServerID","results","errors","compilation","warnings","compiling","onDone","WebpackCompilationStartedEvent","onStart"],"sources":["webpack-events-listener.ts"],"sourcesContent":["import { WebpackAspect, WebpackCompilationDoneEvent, WebpackCompilationStartedEvent } from '@teambit/webpack';\nimport type { PubsubMain, BitBaseEvent } from '@teambit/pubsub';\n\nexport type CompilationResult = {\n errors?: Error[];\n warnings?: Error[];\n compiling: boolean;\n};\n\nexport type Handlers = {\n /**\n * emitted when compilation completes. Might happen after server is already up and running.\n */\n onDone?: (serverId: string, stats: CompilationResult) => void;\n /**\n * happens whenever compilation starts, e.g. when a file changes, or on initial compilation\n */\n onStart?: (serverId: string) => void;\n};\n\n/**\n * Listen for Webpack compilation pub sub events.\n */\nexport function SubscribeToWebpackEvents(pubsub: PubsubMain, handlers: Handlers = {}) {\n pubsub.sub(WebpackAspect.id, (event: BitBaseEvent<any>) => {\n if (event.type === WebpackCompilationDoneEvent.TYPE) {\n const { stats, devServerID } = event.data;\n\n const results = {\n errors: stats.compilation.errors,\n warnings: stats.compilation.warnings,\n compiling: false,\n };\n\n handlers.onDone?.(devServerID, results);\n }\n\n if (event.type === WebpackCompilationStartedEvent.TYPE) {\n const { devServerID } = event.data;\n handlers.onStart?.(devServerID);\n }\n });\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAoBA;AACA;AACA;AACO,SAASE,wBAAwBA,CAACC,MAAkB,EAAEC,QAAkB,GAAG,CAAC,CAAC,EAAE;EACpFD,MAAM,CAACE,GAAG,CAACC,wBAAa,CAACC,EAAE,EAAGC,KAAwB,IAAK;IACzD,IAAIA,KAAK,CAACC,IAAI,KAAKC,sCAA2B,CAACC,IAAI,EAAE;MACnD,MAAM;QAAEC,KAAK;QAAEC;MAAY,CAAC,GAAGL,KAAK,CAACR,IAAI;MAEzC,MAAMc,OAAO,GAAG;QACdC,MAAM,EAAEH,KAAK,CAACI,WAAW,CAACD,MAAM;QAChCE,QAAQ,EAAEL,KAAK,CAACI,WAAW,CAACC,QAAQ;QACpCC,SAAS,EAAE;MACb,CAAC;MAEDd,QAAQ,CAACe,MAAM,GAAGN,WAAW,EAAEC,OAAO,CAAC;IACzC;IAEA,IAAIN,KAAK,CAACC,IAAI,KAAKW,yCAA8B,CAACT,IAAI,EAAE;MACtD,MAAM;QAAEE;MAAY,CAAC,GAAGL,KAAK,CAACR,IAAI;MAClCI,QAAQ,CAACiB,OAAO,GAAGR,WAAW,CAAC;IACjC;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
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,46 @@
1
+ {
2
+ "name": "@teambit/preview.cli.webpack-events-listener",
3
+ "version": "0.0.0-5aa6db2c5c0b7667f28024dece927a09f1f95d01",
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": "5aa6db2c5c0b7667f28024dece927a09f1f95d01"
10
+ },
11
+ "dependencies": {},
12
+ "devDependencies": {
13
+ "@types/mocha": "9.1.0",
14
+ "chai": "5.2.1",
15
+ "@teambit/node.envs.node-babel-mocha": "0.2.10"
16
+ },
17
+ "peerDependencies": {},
18
+ "license": "Apache-2.0",
19
+ "optionalDependencies": {},
20
+ "peerDependenciesMeta": {},
21
+ "exports": {
22
+ ".": {
23
+ "types": "./index.ts",
24
+ "require": "./dist/index.js",
25
+ "import": "./dist/esm.mjs"
26
+ }
27
+ },
28
+ "private": false,
29
+ "engines": {
30
+ "node": ">=12.22.0"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/teambit/bit"
35
+ },
36
+ "keywords": [
37
+ "bit",
38
+ "components",
39
+ "collaboration",
40
+ "web",
41
+ "react",
42
+ "react-components",
43
+ "angular",
44
+ "angular-components"
45
+ ]
46
+ }
@@ -0,0 +1,41 @@
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<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
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
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -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
+ }