feat: introduce browser support (#201)
This commit introduces a second `tsc` execution which generates JS in ES5 form. Then, webpack is used to generate a browser bundle. Fixes: https://github.com/cloudevents/sdk-javascript/issues/94 Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
parent
0378f4cdf9
commit
8b2725b10a
|
@ -9,6 +9,8 @@ yarn-error.log*
|
|||
*.d.ts
|
||||
index.js
|
||||
/lib
|
||||
/browser
|
||||
/bundles
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"watch": "tsc --project tsconfig.json --watch",
|
||||
"build": "tsc --project tsconfig.json",
|
||||
"build": "tsc --project tsconfig.json && tsc --project tsconfig.browser.json && webpack",
|
||||
"prelint": "npm run build",
|
||||
"lint": "standardx src examples",
|
||||
"fix": "standardx --fix",
|
||||
|
@ -119,7 +119,9 @@
|
|||
"standardx": "^5.0.0",
|
||||
"ts-node": "^8.10.2",
|
||||
"typedoc": "^0.17.7",
|
||||
"typescript": "^3.8.3"
|
||||
"typescript": "^3.8.3",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
"checkJs": false, /* Report errors in .js files. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"baseUrl": ".",
|
||||
"outDir": "./browser",
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"lib": ["es2016", "dom", "es5"]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
"cloudevents-sdk": "./browser/index.js"
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "_bundles"),
|
||||
filename: "[name].js",
|
||||
libraryTarget: "umd",
|
||||
library: "cloudevents-sdk",
|
||||
umdNamedDefine: true
|
||||
},
|
||||
devtool: "source-map",
|
||||
mode: "production"
|
||||
};
|
Loading…
Reference in New Issue