Skip to content

Commit ad72693

Browse files
committed
feat: introduce browser support
This commit introduces a second `tsc` execution which generates JS in ES5 form. Then, webpack is used to generate a browser bundle. WIP: Tests still pending. Signed-off-by: Lance Ball <[email protected]>
1 parent edad2a6 commit ad72693

18 files changed

+4143
-146
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ yarn-error.log*
88
# Generated files
99
*.d.ts
1010
index.js
11-
lib
11+
/lib
12+
/browser
13+
/_bundles
1214

1315
# Runtime data
1416
pids

package-lock.json

Lines changed: 4088 additions & 130 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"watch": "tsc --project tsconfig.json --watch",
8-
"build": "tsc --project tsconfig.json",
8+
"build": "tsc --project tsconfig.json && tsc --project tsconfig.browser.json && webpack",
99
"prelint": "npm run build",
1010
"lint": "standardx src examples",
1111
"fix": "standardx --fix",
@@ -105,6 +105,7 @@
105105
"@types/ajv": "^1.0.0",
106106
"@types/axios": "^0.14.0",
107107
"@types/node": "^13.13.9",
108+
"awesome-typescript-loader": "^5.2.1",
108109
"chai": "~4.2.0",
109110
"eslint-config-standard": "^14.1.1",
110111
"eslint-plugin-import": "^2.20.2",
@@ -114,7 +115,11 @@
114115
"nyc": "~15.0.0",
115116
"standard-version": "^7.1.0",
116117
"standardx": "^5.0.0",
117-
"typescript": "^3.8.3"
118+
"ts-loader": "^7.0.5",
119+
"typescript": "^3.8.3",
120+
"uglifyjs-webpack-plugin": "^2.2.0",
121+
"webpack": "^4.43.0",
122+
"webpack-cli": "^3.3.11"
118123
},
119124
"publishConfig": {
120125
"access": "public"

src/lib/bindings/http/emitter_binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const {
1111
DATA_ATTRIBUTE,
1212
SPEC_V1,
1313
SPEC_V03
14-
} = require("./constants.js");
14+
} = require("./constants");
1515

1616
const defaults = {
1717
[HEADERS]: {

src/lib/bindings/http/emitter_structured.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const {
77
DEFAULT_CE_CONTENT_TYPE,
88
HEADERS,
99
HEADER_CONTENT_TYPE
10-
} = require("./constants.js");
10+
} = require("./constants");
1111

1212
const defaults = {
1313
[HEADERS]: {

src/lib/bindings/http/receiver_binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const ReceiverV1 = require("./v1/receiver_binary_1.js");
22
const ReceiverV3 = require("./v03/receiver_binary_0_3.js");
33

4-
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
4+
const { SPEC_V03, SPEC_V1 } = require("./constants");
55
const { check, parse } = require("./validation/binary.js");
66

77
/** @typedef {import("../../cloudevent")} CloudEvent */

src/lib/bindings/http/receiver_structured.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const ReceiverV1 = require("./v1/receiver_structured_1.js");
22
const ReceiverV3 = require("./v03/receiver_structured_0_3.js");
33

4-
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
4+
const { SPEC_V03, SPEC_V1 } = require("./constants");
55
const { check, parse } = require("./validation/structured.js");
66

77
/** @typedef {import("../../cloudevent")} CloudEvent */

src/lib/bindings/http/v03/emitter_binary_0_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
TIME,
1111
SCHEMA_URL
1212
}
13-
} = require("../constants.js");
13+
} = require("../constants");
1414

1515
function parser(header, parser = (v) => v) {
1616
return { headerName: header, parse: parser };

src/lib/bindings/http/v03/receiver_binary_0_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {
55
ENCODING_BASE64,
66
HEADER_CONTENT_TYPE,
77
BINARY_HEADERS_03
8-
} = require("../constants.js");
8+
} = require("../constants");
99
const Spec = require("./spec_0_3.js");
1010

1111
const JSONParser = require("../../../formats/json/parser.js");

src/lib/bindings/http/v03/receiver_structured_0_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
SUBJECT,
1414
DATA
1515
}
16-
} = require("../constants.js");
16+
} = require("../constants");
1717
const Spec = require("./spec_0_3.js");
1818
const JSONParser = require("../../../formats/json/parser.js");
1919

0 commit comments

Comments
 (0)