diff --git a/package.json b/package.json index c984410..2c20854 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "license": "ISC", "main": "dist/index.js", + "browser": "dist/browser.js", "types": "dist/index.d.ts", "files": [ "dist/" diff --git a/src/browser.test.ts b/src/browser.test.ts new file mode 100644 index 0000000..ad45f97 --- /dev/null +++ b/src/browser.test.ts @@ -0,0 +1,22 @@ +import * as PostMessageStream from './browser'; + +describe('post-message-stream', () => { + describe('browser exports', () => { + const expectedExports = [ + 'BasePostMessageStream', + 'WindowPostMessageStream', + 'WebWorkerPostMessageStream', + 'WebWorkerParentPostMessageStream', + ]; + + it('package has expected exports', () => { + expect(Object.keys(PostMessageStream)).toHaveLength( + expectedExports.length, + ); + + for (const exportName of expectedExports) { + expect(exportName in PostMessageStream).toStrictEqual(true); + } + }); + }); +}); diff --git a/src/browser.ts b/src/browser.ts new file mode 100644 index 0000000..5da5dab --- /dev/null +++ b/src/browser.ts @@ -0,0 +1,6 @@ +// Exports a subset of functionality for browsers +export * from './window/WindowPostMessageStream'; +export * from './WebWorker/WebWorkerPostMessageStream'; +export * from './WebWorker/WebWorkerParentPostMessageStream'; +export * from './BasePostMessageStream'; +export { StreamData, StreamMessage } from './utils';