Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #27 from CosmWasm/create-umd-module
Browse files Browse the repository at this point in the history
Add UMD Module
  • Loading branch information
msteiner96 authored Mar 8, 2022
2 parents aeae1cf + 6bd5d04 commit f5519d8
Show file tree
Hide file tree
Showing 9 changed files with 846 additions and 82 deletions.
3 changes: 3 additions & 0 deletions dist/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/bundle.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/bundle.node.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/bundle.node.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ So your `package.json` should look like:
}
```

**CosmWasmJS in the browser**
You can access all the objects of the cosmwasm from the global `cosmwasm` object if you load CosmWasmJS with a `<script>` tag.

Include the following in your browser:
```html
<script
crossorigin
src="https://unpkg.com/cosmwasm/dist/bundle.js"
></script>
```

# Basics

## Clients
Expand Down
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -rf ./build && tsc",
"lint": "eslint --max-warnings 0 \"./src/**/*.ts\""
"lint": "eslint --max-warnings 0 \"./src/**/*.ts\"",
"webpack": "npx webpack"
},
"bin": "src/cli/bin/cli",
"repository": {
Expand Down Expand Up @@ -34,21 +35,23 @@
"homepage": "https://github.com/CosmWasm/CosmWasmJS#readme",
"dependencies": {
"@cosmjs/amino": "0.28.0-rc1",
"@cosmjs/cli": "0.28.0-rc1",
"@cosmjs/cosmwasm-stargate": "0.28.0-rc1",
"@cosmjs/crypto": "0.28.0-rc1",
"@cosmjs/encoding": "0.28.0-rc1",
"@cosmjs/faucet-client": "0.28.0-rc1",
"@cosmjs/ledger-amino": "0.28.0-rc1",
"@cosmjs/math": "0.28.0-rc1",
"@cosmjs/proto-signing": "0.28.0-rc1",
"@cosmjs/stargate": "0.28.0-rc1",
"@cosmjs/cli": "0.28.0-rc1",
"@cosmjs/math": "0.28.0-rc1",
"@cosmjs/utils": "0.28.0-rc1"
"@cosmjs/utils": "0.28.0-rc1",
"bufferutil": "^4.0.6"
},
"devDependencies": {
"@types/ledgerhq__hw-transport": "^4.21.4",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"buffer": "^6.0.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
Expand All @@ -57,7 +60,15 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"path-browserify": "^1.0.1",
"prettier": "^2.5.1",
"typescript": "^4.5.5"
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"ts-loader": "^9.2.7",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"typescript": "^4.5.5",
"utf-8-validate": "^5.0.8",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
}
}
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"declaration": true,
"outDir": "./build",
"strict": true,
"esModuleInterop": true
"esModuleInterop": true,
"baseUrl": "./",
"paths": {
"*": ["src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
Expand Down
66 changes: 66 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const webpack = require("webpack");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const commonConfig = {
mode: "production",
entry: "./src/index.ts",
devtool: "source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
plugins: [new TsconfigPathsPlugin()],
},
plugins: [
new webpack.IgnorePlugin({
resourceRegExp:
/wordlists\/(french|spanish|italian|korean|chinese_simplified|chinese_traditional|japanese)\.json$/,
}),
],
};

const webConfig = {
...commonConfig,
target: "web",
output: {
filename: "bundle.js",
libraryTarget: "umd",
library: "CosmWasmJS",
},
resolve: {
...commonConfig.resolve,
fallback: {
stream: require.resolve("stream-browserify"),
buffer: require.resolve("buffer"),
path: require.resolve("path-browserify"),
},
},
plugins: [
...commonConfig.plugins,
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
};

const nodeConfig = {
...commonConfig,
target: "node",
output: {
libraryTarget: "commonjs",
filename: "bundle.node.js",
},
};

module.exports = [webConfig, nodeConfig];
Loading

0 comments on commit f5519d8

Please sign in to comment.