Skip to content

Commit

Permalink
try webpack4 + EsmWebpackPlugin for ESM package
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Mar 28, 2022
1 parent 7ad4afb commit 7ee0430
Show file tree
Hide file tree
Showing 7 changed files with 1,853 additions and 746 deletions.
37 changes: 35 additions & 2 deletions dist/esm/index.js

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions dist/esm/index.js.LICENSE.txt

This file was deleted.

37 changes: 35 additions & 2 deletions dist/umd/index.js

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions dist/umd/index.js.LICENSE.txt

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@depay/coinbase-wallet-sdk",
"version": "1.0.2",
"version": "1.0.4",
"description": "Coinbase Wallet SDK browser pre-built usable in rollup bundles.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand All @@ -23,8 +23,9 @@
},
"homepage": "https://github.com/DePayFi/coinbase-wallet-sdk#readme",
"devDependencies": {
"webpack": "^5.49.0",
"webpack-cli": "^4.9.2"
"@purtuga/esm-webpack-plugin": "^1.5.0",
"webpack": "^4.46.0",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.0.5"
Expand Down
74 changes: 27 additions & 47 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,31 @@
const webpack = require('webpack');
const path = require('path');
const EsmWebpackPlugin = require("@purtuga/esm-webpack-plugin");

module.exports = [
{
target: "web",
mode: "production",
output: {
filename: 'index.js',
library: 'CoinbaseWalletSdk',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist/umd')
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
LINK_API_URL: JSON.stringify("https://www.walletlink.org"),
SDK_VERSION: JSON.stringify("3.0.5")
}
})
],
const umd = {
output: {
filename: 'index.js',
library: 'CoinbaseWalletSdk',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist/umd')
},
{
target: "web",
mode: "production",
experiments: {
outputModule: true,
},
output: {
filename: 'index.js',
libraryTarget: 'module',
path: path.resolve(__dirname, 'dist/esm')
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
LINK_API_URL: JSON.stringify("https://www.walletlink.org"),
SDK_VERSION: JSON.stringify("3.0.5")
}
})
],
node: {
Buffer: true
}
]
}

const esm = {
output: {
filename: 'index.js',
library: 'CoinbaseWalletSdk',
libraryTarget: 'var',
path: path.resolve(__dirname, 'dist/esm')
},
plugins: [
new EsmWebpackPlugin()
],
node: {
Buffer: true
}
}

module.exports = [umd, esm]
Loading

0 comments on commit 7ee0430

Please sign in to comment.