Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update build to support tree-shaking #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage/

# Build
build/
esm/
umd/
test-reports/
cypress/screenshots/
Expand Down
9 changes: 8 additions & 1 deletion packages/sdk/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong code: it duplicates code above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Having umd and esm builds is common practice for libraries.

Umd is compatible with everything. Esm is not, but umd doesn't support tree shaking so adding an esm build is necessary.

Check out this article for more info: link

},
resolve: {
fallback: {
Expand Down
9 changes: 8 additions & 1 deletion packages/wallet/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"lib": ["es6", "dom", "esnext"],
"module": "commonjs",
"target": "es5",
"module": "ESNEXT",
"target": "es2015",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is breaking changes
be careful with it

"incremental": true,
"skipLibCheck": true,
"importHelpers": true,
Expand Down