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

Experimental scope hoisting: importing Web3 causes error #2696

Closed
codydjango opened this issue Feb 28, 2019 · 3 comments
Closed

Experimental scope hoisting: importing Web3 causes error #2696

codydjango opened this issue Feb 28, 2019 · 3 comments

Comments

@codydjango
Copy link

🐛 bug report

I'm trying out the --experimental-scope-hoisting flag, and it doesn't play nice with Web3. Can't say I'm surprised, Web3 is quite a large library and still in a beta stage. When I saw it wasn't working, I starting cutting out code until I was only importing Web3 and nothing else, which still resulted in an error during packaging with Property name expected type of string but got null.

I think I'll simply remove Web3 as an NPM dependency and load it temporarily from a CDN. It would be awesome to see them play nicely together at some point :)

🎛 Configuration (.babelrc, package.json, cli command)

web3@1.0.0-beta.46 in package.json

.babelrc: just the default provided by ParcelJS. I'm not using a custom .babelrc.

cli: parcel build src/web/index.html --experimental-scope-hoisting"

🤔 Expected Behavior

Expecting a little tree-shaking ;)

😯 Current Behavior

Property name expected type of string but got null
    at validate (/Users/codyredmond/Documents/Work/everyday/node_modules/@babel/types/lib/definitions/utils.js:161:13)
    at Object.validate (/Users/codyredmond/Documents/Work/everyday/node_modules/@babel/types/lib/definitions/utils.js:172:7)
    at validate (/Users/codyredmond/Documents/Work/everyday/node_modules/@babel/types/lib/validators/validate.js:17:9)
    at builder (/Users/codyredmond/Documents/Work/everyday/node_modules/@babel/types/lib/builders/builder.js:46:27)
    at Object.Identifier (/Users/codyredmond/Documents/Work/everyday/node_modules/@babel/types/lib/builders/generated/index.js:321:31)
    at JSConcatPackager.wrapModule (/Users/codyredmond/Documents/Work/everyday/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:292:21)
    at JSConcatPackager.addDeps (/Users/codyredmond/Documents/Work/everyday/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:239:25)
    at JSConcatPackager.addDeps (/Users/codyredmond/Documents/Work/everyday/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:223:27)
    at JSConcatPackager.addDeps (/Users/codyredmond/Documents/Work/everyday/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:223:27)
    at JSConcatPackager.addDeps (/Users/codyredmond/Documents/Work/everyday/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:223:27)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! everyday@0.1.0 build: `parcel build src/web/index.html --experimental-scope-hoisting`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the everyday@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/codyredmond/.npm/_logs/2019-02-28T02_57_40_473Z-debug.log

💁 Possible Solution

I'll be loading web3 temporarily from a CDN. I've been reading over at web3 that they aren't too happy about the large sizes and inaccurate typing, so at least we know they're aware of it. I'm also curious about /~https://github.com/xf00f/web3x, but with the speed of development on web3, I'm not sure about how it can claim parity. I'll be looking into it.

🔦 Context

I just would love to keep using ParcelJS for building out ethereum apps. What an amazing bundler you have :D

💻 Code Sample

This is a work in progress, but feel free trying to create a production build with experimental hoisting turned on using this feature branch: /~https://github.com/codydjango/everyday/tree/feature/experimental-scope-hoisting

🌍 Your Environment

Software Version(s)
Parcel 1.11.0
Node v11.6.0
npm/Yarn 6.7.0
Operating System osx 10.14.3
@mischnic
Copy link
Member

mischnic commented Mar 1, 2019

This is caused by eth-lib using object-spread-assignment on an import:

const { keccak256, keccak256s } = require("./hash");

@devongovett Should this be added to the scope hoisting or is this the "should Babel run on node_modules" discussion ?

@devongovett
Copy link
Member

Yeah seems like a tree shaking bug

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants