From 2a16756cd862d7ee4df715baea736a36b06ab1ee Mon Sep 17 00:00:00 2001 From: Geoffrey Casper Date: Fri, 18 Feb 2022 19:36:48 -0500 Subject: [PATCH] feat: update build to support tree-shaking --- .gitignore | 1 + packages/sdk/webpack.config.js | 9 ++++++++- packages/wallet/webpack.config.js | 9 ++++++++- tsconfig.json | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5ee52eee1..4e2540088 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ coverage/ # Build build/ +esm/ umd/ test-reports/ cypress/screenshots/ diff --git a/packages/sdk/webpack.config.js b/packages/sdk/webpack.config.js index a56fe00cf..f8903ea2a 100644 --- a/packages/sdk/webpack.config.js +++ b/packages/sdk/webpack.config.js @@ -3,13 +3,20 @@ const webpack = require("webpack") module.exports = { entry: "./build/index.js", + experiments: { + outputModule: true, + }, output: { path: path.resolve(__dirname, "umd"), filename: "rarible-sdk.js", library: { - name: "raribleSdk", type: "umd", }, + path: path.resolve(__dirname, "esm"), + filename: "rarible-sdk.js", + library: { + type: "module", + }, }, resolve: { fallback: { diff --git a/packages/wallet/webpack.config.js b/packages/wallet/webpack.config.js index a2c93ae38..c84db43e1 100644 --- a/packages/wallet/webpack.config.js +++ b/packages/wallet/webpack.config.js @@ -3,13 +3,20 @@ const webpack = require("webpack") module.exports = { entry: "./build/index.js", + experiments: { + outputModule: true, + }, output: { path: path.resolve(__dirname, "umd"), filename: "rarible-wallet-sdk.js", library: { - name: "raribleWalletSdk", type: "umd", }, + path: path.resolve(__dirname, "esm"), + filename: "rarible-wallet-sdk.js", + library: { + type: "module", + }, }, resolve: { fallback: { diff --git a/tsconfig.json b/tsconfig.json index 4853b43a5..493c19d0b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "lib": ["es6", "dom", "esnext"], - "module": "commonjs", - "target": "es5", + "module": "ESNEXT", + "target": "es2015", "incremental": true, "skipLibCheck": true, "importHelpers": true,