Skip to content

Commit a64ff54

Browse files
committed
Add comments about env-dependent APIs
1 parent 6407bf0 commit a64ff54

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/v1/internal/browser/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ import WebSocketChannel from './browser-channel';
2222
import BrowserHosNameResolver from './browser-host-name-resolver';
2323
import utf8Codec from './browser-utf8';
2424

25+
/*
26+
27+
This module exports a set of components to be used in browser environment.
28+
They are not compatible with NodeJS environment.
29+
All files import/require APIs from `node/index.js` by default.
30+
Such imports are replaced at build time with `browser/index.js` when building a browser bundle.
31+
32+
NOTE: exports in this module should have exactly the same names/structure as exports in `node/index.js`.
33+
34+
*/
35+
2536
export const alloc = arg => new HeapBuffer(arg);
2637
export const Channel = WebSocketChannel;
2738
export const HostNameResolver = BrowserHosNameResolver;

src/v1/internal/node/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ import NodeChannel from './node-channel';
2222
import NodeHostNameResolver from './node-host-name-resolver';
2323
import utf8Codec from './node-utf8';
2424

25+
/*
26+
27+
This module exports a set of components to be used in NodeJS environment.
28+
They are not compatible with browser environment.
29+
All files that require environment-dependent APIs should import this file by default.
30+
Imports/requires are replaced at build time with `browser/index.js` when building a browser bundle.
31+
32+
NOTE: exports in this module should have exactly the same names/structure as exports in `browser/index.js`.
33+
34+
*/
35+
2536
export const alloc = arg => new NodeBuffer(arg);
2637
export const Channel = NodeChannel;
2738
export const HostNameResolver = NodeHostNameResolver;

0 commit comments

Comments
 (0)