Skip to content

Commit 930462f

Browse files
ECMAScript module (ESM) support
- change compiler options to NodeNext - add .js extensions to all imports - tweak webpack configs (remove fullySpecified: false)
1 parent 3b29c3e commit 930462f

File tree

184 files changed

+1109
-1091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+1109
-1091
lines changed

RELEASE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,11 @@ Instead whitelist files in `package.json`. It's better to be exact about what we
7777

7878
## Update release notes on GitHub
7979

80+
Build the bundle files to upload.
81+
82+
`npm run build-bundles`
83+
8084
* Find 'Releases' on repository page
8185
* Draft and publish release notes for new tag
86+
* Upload bundles for new verison
87+

build/grammarGenerator.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const parser = pegjs.generate(grammarContents, {
5252
plugins: [tspegjs],
5353
"tspegjs": {
5454
"tslintIgnores": "interface-name, trailing-comma, object-literal-sort-keys, max-line-length, only-arrow-functions, one-variable-per-declaration, no-consecutive-blank-lines, align, radix, quotemark, semicolon, object-literal-shorthand, variable-name, no-var-keyword, whitespace, curly, prefer-const, object-literal-key-quotes, no-string-literal, one-line, no-unused-expression, space-before-function-paren, arrow-return-shorthand",
55-
"customHeader": "import { NameAddrHeader } from \"../../name-addr-header\";\nimport { URI } from \"../../uri\";"
55+
"customHeader": "import { NameAddrHeader } from \"../../name-addr-header.js\";\nimport { URI } from \"../../uri.js\";"
5656
},
5757
"returnTypes": {
5858
Contact: "URI | NameAddrHeader",

build/webpack.config.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ module.exports = function (env) {
7272
]
7373
},
7474
resolve: {
75-
extensions: ['.ts', '.d.ts', '.js']
75+
extensions: ['.ts', '.d.ts', '.js'],
76+
extensionAlias: {
77+
'.js': ['.ts', '.js'],
78+
'.mjs': ['.mts', '.mjs']
79+
}
7680
},
7781
optimization: {
7882
minimizer: [

demo/demo-1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-use-before-define */
22
/* eslint-disable no-console */
3-
import { SimpleUser, SimpleUserDelegate, SimpleUserOptions } from "../src/platform/web";
4-
import { getAudio, getButton, getButtons, getInput, getSpan } from "./demo-utils";
3+
import { SimpleUser, SimpleUserDelegate, SimpleUserOptions } from "../lib/platform/web/index.js";
4+
import { getAudio, getButton, getButtons, getInput, getSpan } from "./demo-utils.js";
55

66
const serverSpan = getSpan("server");
77
const targetSpan = getSpan("target");

demo/demo-2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
/* eslint-disable @typescript-eslint/explicit-function-return-type */
33
/* eslint-disable no-console */
44
/* eslint-disable @typescript-eslint/no-use-before-define */
5-
import { SimpleUser, SimpleUserDelegate, SimpleUserOptions } from "../src/platform/web";
6-
import { nameAlice, nameBob, uriAlice, uriBob, webSocketServerAlice, webSocketServerBob } from "./demo-users";
7-
import { getButton, getInput, getVideo } from "./demo-utils";
5+
import { SimpleUser, SimpleUserDelegate, SimpleUserOptions } from "../lib/platform/web/index.js";
6+
import { nameAlice, nameBob, uriAlice, uriBob, webSocketServerAlice, webSocketServerBob } from "./demo-users.js";
7+
import { getButton, getInput, getVideo } from "./demo-utils.js";
88

99
const connectAlice = getButton("connectAlice");
1010
const connectBob = getButton("connectBob");

demo/demo-3.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
SimpleUser,
88
SimpleUserDelegate,
99
SimpleUserOptions
10-
} from "../src/platform/web";
11-
import { nameAlice, nameBob, uriAlice, uriBob, webSocketServerAlice, webSocketServerBob } from "./demo-users";
12-
import { getButton, getDiv, getInput } from "./demo-utils";
10+
} from "../lib/platform/web/index.js";
11+
import { nameAlice, nameBob, uriAlice, uriBob, webSocketServerAlice, webSocketServerBob } from "./demo-users.js";
12+
import { getButton, getDiv, getInput } from "./demo-utils.js";
1313

1414
// A class which extends SimpleUser to handle setup and use of a data channel
1515
class SimpleUserWithDataChannel extends SimpleUser {

demo/webpack.config.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ module.exports = {
1818
]
1919
},
2020
resolve: {
21-
extensions: [ '.tsx', '.ts', '.js' ]
21+
extensions: [ '.tsx', '.ts', '.js' ],
22+
extensionAlias: {
23+
'.js': ['.ts', '.js'],
24+
'.mjs': ['.mts', '.mjs'],
25+
}
2226
},
2327
output: {
2428
filename: '[name].js',

karma.conf.cjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ module.exports = function(config) {
2424

2525
webpack: {
2626
devtool: 'inline-source-map',
27-
module: { rules: [ { test: /\.m?js/,
28-
resolve: {
29-
fullySpecified: false
30-
}
31-
}]},
3227
mode: 'production'
3328
},
3429

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
},
6767
"scripts": {
6868
"prebuild": "npm run lint",
69-
"build-bundles": "npm run build-reg-bundle && npm run build-min-bundle",
69+
"build-bundles": "npm run build-reg-bundle && npm run build-min-bundle && npm run copy-dist-files",
7070
"build-reg-bundle": "webpack --progress --config build/webpack.config.cjs --env buildType=reg",
7171
"build-min-bundle": "webpack --progress --config build/webpack.config.cjs --env buildType=min",
72-
"build-demo": "npm run generate-grammar && webpack --progress --config demo/webpack.config.cjs",
72+
"build-demo": "npm run build && webpack --progress --config demo/webpack.config.cjs",
7373
"build-lib": "tsc -p src",
7474
"build-test": "tsc -p test",
75-
"build": "npm run generate-grammar && npm run build-lib && npm run build-reg-bundle && npm run build-min-bundle && npm run copy-dist-files",
75+
"build": "npm run generate-grammar && npm run build-lib",
7676
"build-and-test": "npm run build && npm run test",
7777
"build-and-test-browser": "npm run build && npm run test-browser",
7878
"build-docs-api": "npm run extract-api && npm run document-api && npm run document-copy-api",

src/api/ack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { IncomingRequestMessage, IncomingAckRequest } from "../core";
1+
import { IncomingAckRequest } from "../core/messages/methods/ack.js";
2+
import { IncomingRequestMessage } from "../core/messages/incoming-request-message.js";
23

34
/**
45
* A request to confirm a {@link Session} (incoming ACK).

0 commit comments

Comments
 (0)