Skip to content

Commit 43a19fb

Browse files
committed
Add browser build with webpack
1 parent c7d3728 commit 43a19fb

File tree

7 files changed

+2504
-22
lines changed

7 files changed

+2504
-22
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"plugin:@typescript-eslint/eslint-recommended",
88
"plugin:@typescript-eslint/recommended"
99
],
10-
"ignorePatterns": ["**/tests/*.ts"],
10+
"ignorePatterns": ["**/tests/*.ts", "webpack.config.js"],
1111
"rules": {
1212
"@typescript-eslint/no-unused-vars": [
1313
"error",

browser/boilingdata.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/*!
7+
* JavaScript Cookie v2.2.1
8+
* https://github.com/js-cookie/js-cookie
9+
*
10+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
11+
* Released under the MIT license
12+
*/
13+
14+
/*!
15+
* The buffer module from node.js, for the browser.
16+
*
17+
* @author Feross Aboukhadijeh <http://feross.org>
18+
* @license MIT
19+
*/
20+
21+
/*! *****************************************************************************
22+
Copyright (c) Microsoft Corporation.
23+
24+
Permission to use, copy, modify, and/or distribute this software for any
25+
purpose with or without fee is hereby granted.
26+
27+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
28+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
30+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33+
PERFORMANCE OF THIS SOFTWARE.
34+
***************************************************************************** */
35+
36+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"scripts": {
3030
"release": "standard-version",
3131
"prebuild": "yarn install --frozen-lockfile",
32-
"build": "rimraf dist/ && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
32+
"build": "yarn build:node && yarn build:browser",
33+
"build:node": "rimraf dist/ && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
34+
"build:browser": "rimraf browser/ && webpack",
3335
"build:watch": "npx onchange 'src/**/*.ts' -- yarn build",
3436
"prettier": "prettier --check 'src/**/*.{js,ts}'",
3537
"prettier:fix": "prettier --write 'src/**/*.{js,ts}'",
@@ -71,6 +73,7 @@
7173
"@types/ws": "8.5.4",
7274
"@typescript-eslint/eslint-plugin": "^5.20.0",
7375
"@typescript-eslint/parser": "^5.20.0",
76+
"browserify": "^17.0.0",
7477
"eslint": "^8.13.0",
7578
"eslint-config-prettier": "^8.5.0",
7679
"eslint-plugin-jest": "^26.1.4",
@@ -80,7 +83,10 @@
8083
"onchange": "^7.0.2",
8184
"prettier": "^2.0.5",
8285
"rimraf": "^3.0.2",
83-
"typescript": "^4.1.3"
86+
"ts-loader": "^9.5.1",
87+
"typescript": "^4.1.3",
88+
"webpack": "^5.90.1",
89+
"webpack-cli": "^5.1.4"
8490
},
8591
"bugs": {
8692
"url": "https://github.com/boilingdata/node-boilingdata/issues"

src/browser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { BoilingData } from "./boilingdata/boilingdata";
2+
3+
export default BoilingData;

webpack.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
entry: "./src/browser.ts",
5+
module: {
6+
rules: [
7+
{
8+
test: /\.tsx?$/,
9+
use: "ts-loader",
10+
exclude: /node_modules/,
11+
},
12+
],
13+
},
14+
resolve: {
15+
extensions: [".tsx", ".ts", ".js"],
16+
},
17+
target: "web",
18+
mode: "production",
19+
output: {
20+
path: path.resolve(__dirname, "./browser"),
21+
filename: "boilingdata.min.js",
22+
libraryTarget: "umd",
23+
globalObject: "this",
24+
umdNamedDefine: true,
25+
libraryExport: "default",
26+
library: "BoilingData",
27+
},
28+
};

0 commit comments

Comments
 (0)