Skip to content

Commit 421892a

Browse files
authored
feat: create the main entrypoint module (#3376)
The main entry and the type commonjs would allow older runtimes to import the CJS version. For ESM imports, the exports field is used. This allows clients to import data using the module name.
1 parent 557fcf0 commit 421892a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@
2525
"wpt:all": "wireit",
2626
"yapf": "yapf -i --parallel --recursive --exclude=wpt examples/ tests/"
2727
},
28+
"type": "commonjs",
29+
"main": "./lib/cjs/index.js",
2830
"exports": {
31+
".": {
32+
"import": "./lib/esm/index.js",
33+
"require": "./lib/cjs/index.js"
34+
},
2935
"./*": {
3036
"import": "./lib/esm/*",
3137
"require": "./lib/cjs/*"
3238
},
3339
"./lib/cjs/*": {
34-
"types": "./lib/cjs/*",
3540
"import": "./lib/cjs/*",
3641
"require": "./lib/cjs/*"
3742
}

src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright 2025 Google LLC.
3+
* Copyright (c) Microsoft Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export * as BidiMapper from './bidiMapper/BidiMapper.js';
19+
export * as Protocol from './protocol/protocol.js';

0 commit comments

Comments
 (0)