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

Add browser field to package.json's of modules with browser builds #921

Merged
merged 4 commits into from
Oct 21, 2020

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Oct 20, 2020

Addresses leftover review comment from #913/886.

Follows pattern established in merkle-patricia-tree 117.

Per clarifying comment there:

Web bundlers just use the browser version when resolving requires/imports. Then they pass those versions to the rest of the toolchain, like uglify

There are 4 packages with browser builds:

  • block
  • common
  • ethash
  • tx

@codecov
Copy link

codecov bot commented Oct 20, 2020

Codecov Report

Merging #921 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

Flag Coverage Δ
#block 76.26% <ø> (+0.26%) ⬆️
#blockchain 80.72% <ø> (ø)
#common 91.79% <ø> (-0.25%) ⬇️
#ethash 82.08% <ø> (ø)
#tx 88.37% <ø> (+0.18%) ⬆️
#vm 86.89% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@@ -1,6 +1,6 @@
{
"extends": "@ethereumjs/config-typescript/tsconfig.browser.json",
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "src/**/*.json"],
Copy link
Contributor Author

@cgewecke cgewecke Oct 20, 2020

Choose a reason for hiding this comment

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

These jsons were accidentally missing from the tsc browser config.

The errors looked like:

20 10 2020 15:04:25.170:ERROR [framework.browserify]: bundle error
20 10 2020 15:04:25.172:ERROR [framework.browserify]: Error: Can't walk dependency graph: Cannot find 
module './mainnet.json' from '/ethereumjs-vm/packages/common/dist.browser/chains/index.js'
    required by /ethereumjs-vm/packages/common/dist.browser/chains/index.js

...and the stack trace shows karma/browserfiy pulling files from dist.browser so that's 👍 .

@holgerd77
Copy link
Member

Will push some additional commits here in the next 15-20 min, please don't merge or rebase in between.

@@ -5,8 +5,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
"dist",
"dist.browser"
Copy link
Member

Choose a reason for hiding this comment

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

dist.browser fields were missing here, added these in 4f33ced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah!!! Good catch!

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

@cgewecke Thanks! 😄

These browser builds should actually be available, added these on two subsequent commits also for blockchain and vm.

Before we release anything here we should actually do at least manual checks on all build types (node + browser) for all the packages - so minimally do a distribution, import from the respective dist or dist.browser directory, do an instantiation and execute at least one function - or alternatively integrate something like this into CI.

@holgerd77 holgerd77 merged commit 2f0e6d0 into master Oct 21, 2020
@holgerd77 holgerd77 deleted the add-browser-field branch October 21, 2020 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants