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

Webpack bundle failing at CID: Unexpected token: name (CID) #38

Closed
lightninglu10 opened this Issue Jul 28, 2017 · 27 comments

Comments

@lightninglu10

lightninglu10 commented Jul 28, 2017

Hey guys, I'm trying to bundle https://github.com/ipfs/js-ipfs, and they're using cids.

Whenever I try to build, yarn run build, with create-react-app, I'm getting this error:

static/js/main.d24ead13.js from UglifyJs
Unexpected token: name (CID) [./~/cids/src/index.js:23,0][static/js/main.d24ead13.js:8442,6]

looks like uglifyJS doesn't look CID? tracked it down to your package and was wondering if you had any insights.

Unable to build because of this.

@JohnAllen

This comment has been minimized.

Show comment
Hide comment
@JohnAllen

JohnAllen Aug 23, 2017

Yeah I get something related.

npm run build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file: 
        ./node_modules/cids/src/index.js:23 
Read more here: http://bit.ly/2tRViJ9

From reading that link it sounds like CID doesn't precompile its code and some es6 code can't be run in the browser without using a transpiler and precompiling.

JohnAllen commented Aug 23, 2017

Yeah I get something related.

npm run build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file: 
        ./node_modules/cids/src/index.js:23 
Read more here: http://bit.ly/2tRViJ9

From reading that link it sounds like CID doesn't precompile its code and some es6 code can't be run in the browser without using a transpiler and precompiling.

@diasdavid diasdavid added the bug label Aug 24, 2017

@dignifiedquire

This comment has been minimized.

Show comment
Hide comment
@dignifiedquire

dignifiedquire Aug 24, 2017

Collaborator

You can either transpile all ES6 things using babel or use uglify-es which is the uglify2 version compatible with es6 syntax.

@diasdavid why did you mark this as a bug?

Collaborator

dignifiedquire commented Aug 24, 2017

You can either transpile all ES6 things using babel or use uglify-es which is the uglify2 version compatible with es6 syntax.

@diasdavid why did you mark this as a bug?

@diasdavid diasdavid removed the bug label Aug 24, 2017

@diasdavid

This comment has been minimized.

Show comment
Hide comment
@diasdavid

diasdavid Aug 24, 2017

Member

Picked the wrong issue. Thanks for catching that :)

Member

diasdavid commented Aug 24, 2017

Picked the wrong issue. Thanks for catching that :)

@acailly

This comment has been minimized.

Show comment
Hide comment
@acailly

acailly Sep 2, 2017

I don't get how it is not a bug?

Currently, someone who wants to quickly make a React app with an IPFS hello world and publish it on its github pages to share it (someone like me) will likely fail to do so because of this error.

99% of these guys will not transpile the lib but they will say "IPFS? Nah, not stable enough", leave and don't come back until IPFS makes the headlines.

I think this kind of issue could discourage a lot of early adopters and should not be considered lightly.

My 2 cents 💗

(Additionnal info: this issue tracks the future use of uglify-es in create-react-app)

acailly commented Sep 2, 2017

I don't get how it is not a bug?

Currently, someone who wants to quickly make a React app with an IPFS hello world and publish it on its github pages to share it (someone like me) will likely fail to do so because of this error.

99% of these guys will not transpile the lib but they will say "IPFS? Nah, not stable enough", leave and don't come back until IPFS makes the headlines.

I think this kind of issue could discourage a lot of early adopters and should not be considered lightly.

My 2 cents 💗

(Additionnal info: this issue tracks the future use of uglify-es in create-react-app)

@diasdavid

This comment has been minimized.

Show comment
Hide comment
@diasdavid

diasdavid Sep 2, 2017

Member

Very valuable 2 cents, @acailly.

I agree it should be fixed so that devs don't have to work around it. There is also tracking of the same issue here: libp2p/js-libp2p#65. I can add the label bug if that makes a difference, either way, it requires changing how we do the duck typing throughout the codebase.

I would be very happy to accept a contribution that removes the need to check constructor name.

Member

diasdavid commented Sep 2, 2017

Very valuable 2 cents, @acailly.

I agree it should be fixed so that devs don't have to work around it. There is also tracking of the same issue here: libp2p/js-libp2p#65. I can add the label bug if that makes a difference, either way, it requires changing how we do the duck typing throughout the codebase.

I would be very happy to accept a contribution that removes the need to check constructor name.

@diasdavid diasdavid added the ready label Sep 13, 2017

@chadoh chadoh referenced this issue Oct 11, 2017

Merged

Fix build script #36

@AquiGorka

This comment has been minimized.

Show comment
Hide comment
@AquiGorka

AquiGorka Oct 16, 2017

@dignifiedquire I did what you mention about using uglify-es and the error still shows.

I had to eject the create-react-app, modify the minify step to use Uglify 3 (requiring the webpack plugin). The build process works but the error stills renders to the console and the app was not able to communicate with IPFS (using the files component).

I did try to use Uglify 3s configuration parameter to maintain class names keep_fnames: true but this did not work.

AquiGorka commented Oct 16, 2017

@dignifiedquire I did what you mention about using uglify-es and the error still shows.

I had to eject the create-react-app, modify the minify step to use Uglify 3 (requiring the webpack plugin). The build process works but the error stills renders to the console and the app was not able to communicate with IPFS (using the files component).

I did try to use Uglify 3s configuration parameter to maintain class names keep_fnames: true but this did not work.

@ecarrollcode

This comment has been minimized.

Show comment
Hide comment
@ecarrollcode

ecarrollcode Mar 11, 2018

It seems @dignifiedquire hit the nail on the head - everything I can find indicates that it's a compatibility issue between ES5 and ES6. @AquiGorka already tried uglify-es, but did anyone try using Babel? That seems like a good option for resolving this.

ecarrollcode commented Mar 11, 2018

It seems @dignifiedquire hit the nail on the head - everything I can find indicates that it's a compatibility issue between ES5 and ES6. @AquiGorka already tried uglify-es, but did anyone try using Babel? That seems like a good option for resolving this.

@AquiGorka

This comment has been minimized.

Show comment
Hide comment
@AquiGorka

AquiGorka Mar 11, 2018

I tried Babel too-I mean, I tried almost everything I could think of:

  • uglify @2 and @3
    • using (for each version) the different parameters to maintain/keep class names
  • babel
  • manually transpiling the files that throw the errors (and ALL of their dependencies as well)

I even wrote a blog post about it all: http://bits.citrusbyte.com/the-state-of-frontend-development-with-IPFS-in-2017/

Catching up to this after a while, found this:
probably fixes the issue: libp2p/js-libp2p#177

@abitrolly if you want a workaround:
In my case, I removed the minify step, and when a solution is found I will add it back.
The app works perfectly and with code splitting I was able to split the whole unminified bundle.
Let me know if you want specifics for the workaround.

AquiGorka commented Mar 11, 2018

I tried Babel too-I mean, I tried almost everything I could think of:

  • uglify @2 and @3
    • using (for each version) the different parameters to maintain/keep class names
  • babel
  • manually transpiling the files that throw the errors (and ALL of their dependencies as well)

I even wrote a blog post about it all: http://bits.citrusbyte.com/the-state-of-frontend-development-with-IPFS-in-2017/

Catching up to this after a while, found this:
probably fixes the issue: libp2p/js-libp2p#177

@abitrolly if you want a workaround:
In my case, I removed the minify step, and when a solution is found I will add it back.
The app works perfectly and with code splitting I was able to split the whole unminified bundle.
Let me know if you want specifics for the workaround.

@kidandcat

This comment has been minimized.

Show comment
Hide comment
@kidandcat

kidandcat Mar 16, 2018

Hi, I'm trying to figure what's the problem here and try to help, I did the first step in this issue:

Hey guys, I'm trying to bundle https://github.com/ipfs/js-ipfs, and they're using cids.

Whenever I try to build, yarn run build, with create-react-app, I'm getting this error:

But it compiled without any problem, have that project been updated to fix that bug?

kidandcat commented Mar 16, 2018

Hi, I'm trying to figure what's the problem here and try to help, I did the first step in this issue:

Hey guys, I'm trying to bundle https://github.com/ipfs/js-ipfs, and they're using cids.

Whenever I try to build, yarn run build, with create-react-app, I'm getting this error:

But it compiled without any problem, have that project been updated to fix that bug?

@vs77bb

This comment has been minimized.

Show comment
Hide comment
@vs77bb

vs77bb Mar 20, 2018

Hi all - just as an FYI, there's a bounty of .05ETH on the solve of this issue at: https://gitcoin.co/issue/ipld/js-cid/38

vs77bb commented Mar 20, 2018

Hi all - just as an FYI, there's a bounty of .05ETH on the solve of this issue at: https://gitcoin.co/issue/ipld/js-cid/38

@diasdavid

This comment has been minimized.

Show comment
Hide comment
@diasdavid
Member

diasdavid commented Mar 21, 2018

@dimkk

This comment has been minimized.

Show comment
Hide comment
@dimkk

dimkk Apr 3, 2018

Hey, feels like managed to solve your issue.
You can checkout my repo https://github.com/dimkk/gitcoin-js-scid-38
It's simple and dirty, but looks like job's done.

I can't submit on gitcoin, cuz its require eth to be in my wallet, so i bought it, but need to wait it to arrive - like a day or smth.

dimkk commented Apr 3, 2018

Hey, feels like managed to solve your issue.
You can checkout my repo https://github.com/dimkk/gitcoin-js-scid-38
It's simple and dirty, but looks like job's done.

I can't submit on gitcoin, cuz its require eth to be in my wallet, so i bought it, but need to wait it to arrive - like a day or smth.

@AquiGorka

This comment has been minimized.

Show comment
Hide comment
@AquiGorka

AquiGorka Apr 3, 2018

@dimkk there is no grotesque module in your repo...

AquiGorka commented Apr 3, 2018

@dimkk there is no grotesque module in your repo...

@diasdavid

This comment has been minimized.

Show comment
Hide comment
@diasdavid

diasdavid Apr 3, 2018

Member

@fsdiogo is onto this one and already has a bunch of PRs coming. :)

Member

diasdavid commented Apr 3, 2018

@fsdiogo is onto this one and already has a bunch of PRs coming. :)

@dimkk

This comment has been minimized.

Show comment
Hide comment
@dimkk

dimkk Apr 3, 2018

@AquiGorka sorry mate, fixed it

dimkk commented Apr 3, 2018

@AquiGorka sorry mate, fixed it

@magik6k magik6k referenced this issue Apr 3, 2018

Merged

Setup CI #13

@fsdiogo

This comment has been minimized.

Show comment
Hide comment
@fsdiogo

fsdiogo Apr 4, 2018

The problem was that the repo ipld/eth-hash-to-cid had an older version of js-cid as a dependency, but @diasdavid already updated it.

We'll need to update a bunch of deps in js-ipfs for the whole uglify issue to be solved, but I'm working on that.

Check ipfs/js-ipfs#938 (comment) for reference.

fsdiogo commented Apr 4, 2018

The problem was that the repo ipld/eth-hash-to-cid had an older version of js-cid as a dependency, but @diasdavid already updated it.

We'll need to update a bunch of deps in js-ipfs for the whole uglify issue to be solved, but I'm working on that.

Check ipfs/js-ipfs#938 (comment) for reference.

@dimkk

This comment has been minimized.

Show comment
Hide comment
@dimkk

dimkk Apr 4, 2018

@fsdiogo It's a lot of work and that would be great!

dimkk commented Apr 4, 2018

@fsdiogo It's a lot of work and that would be great!

@abitrolly

This comment has been minimized.

Show comment
Hide comment
@abitrolly

abitrolly Apr 5, 2018

Looks like my comment was removed. Let me know when the bug is fixed, and how should I distribute gitcoin bonus for it. Use https://gitcoin.co/faucet if you need some ether to operate with gitcoin.co

abitrolly commented Apr 5, 2018

Looks like my comment was removed. Let me know when the bug is fixed, and how should I distribute gitcoin bonus for it. Use https://gitcoin.co/faucet if you need some ether to operate with gitcoin.co

@abitrolly abitrolly referenced this issue Apr 6, 2018

Open

Issues Tree #611

@fsdiogo

This comment has been minimized.

Show comment
Hide comment
@fsdiogo

fsdiogo Apr 23, 2018

Check ipfs/js-ipfs#1321 for more info.

fsdiogo commented Apr 23, 2018

Check ipfs/js-ipfs#1321 for more info.

@vmx vmx closed this Apr 23, 2018

@vs77bb

This comment has been minimized.

Show comment
Hide comment
@vs77bb

vs77bb Apr 28, 2018

@abitrolly Did this one need pay out to @dimkk?

@dimkk, if you need ETH, gitcoin.co/faucet should get you there and you can click 'Submit Work' so @abitrolly can pay this out on Gitcoin!

vs77bb commented Apr 28, 2018

@abitrolly Did this one need pay out to @dimkk?

@dimkk, if you need ETH, gitcoin.co/faucet should get you there and you can click 'Submit Work' so @abitrolly can pay this out on Gitcoin!

@gitcoinbot

This comment has been minimized.

Show comment
Hide comment
@gitcoinbot

gitcoinbot Apr 30, 2018

@rrandom are you still working on this issue?

  • warning 1 (3 days)
  • warning 2 (6 days)
  • auto removal (10 days)

gitcoinbot commented Apr 30, 2018

@rrandom are you still working on this issue?

  • warning 1 (3 days)
  • warning 2 (6 days)
  • auto removal (10 days)
@VictorBjelkholm

This comment has been minimized.

Show comment
Hide comment
@VictorBjelkholm

VictorBjelkholm May 7, 2018

Member

Not sure how it got activated, but can we disable gitcoin somehow? Don't think we're actually using it and it just started appear from nowhere, leaving comments about completely unrelated things

Member

VictorBjelkholm commented May 7, 2018

Not sure how it got activated, but can we disable gitcoin somehow? Don't think we're actually using it and it just started appear from nowhere, leaving comments about completely unrelated things

@thelostone-mc

This comment has been minimized.

Show comment
Hide comment
@thelostone-mc

thelostone-mc May 10, 2018

@VictorBjelkholm Ah i guess it came cause @abitrolly put up a bounty on this issue as mentioned here in hopes that someone would pick it up for a reward for 0.05 ETH

What happened probably :

- @lightninglu10 created the issue
- @abitrolly funded it on gitcoin - https://gitcoin.co/issue/ipld/js-cid/38
- @rrandom  picked it up but didn't respond with his plan of action
- @gitcoinbot left a comment asking @rrandom for a PR / action plan

Ideally killing the bounty -> would stop the commenting.

Agreed springing this up out the blue to the repo owner who isn't aware of gitcoin is confusing ! 😓
Need to figure out a nicer way how to notify the github owner that someone is bountying an issue on from their repo

thelostone-mc commented May 10, 2018

@VictorBjelkholm Ah i guess it came cause @abitrolly put up a bounty on this issue as mentioned here in hopes that someone would pick it up for a reward for 0.05 ETH

What happened probably :

- @lightninglu10 created the issue
- @abitrolly funded it on gitcoin - https://gitcoin.co/issue/ipld/js-cid/38
- @rrandom  picked it up but didn't respond with his plan of action
- @gitcoinbot left a comment asking @rrandom for a PR / action plan

Ideally killing the bounty -> would stop the commenting.

Agreed springing this up out the blue to the repo owner who isn't aware of gitcoin is confusing ! 😓
Need to figure out a nicer way how to notify the github owner that someone is bountying an issue on from their repo

@gitcoinbot

This comment has been minimized.

Show comment
Hide comment
@gitcoinbot

gitcoinbot May 12, 2018

Issue Status: 1. Open 2. Cancelled


Work has been started.

  1. @mkeen

has committed to working on this project to be completed 9 months, 4 weeks from now.

gitcoinbot commented May 12, 2018

Issue Status: 1. Open 2. Cancelled


Work has been started.

  1. @mkeen

has committed to working on this project to be completed 9 months, 4 weeks from now.

@abitrolly

This comment has been minimized.

Show comment
Hide comment
@abitrolly

abitrolly May 13, 2018

Ok. To stop spamming this issue I killed the bounty here and will award it according to ipfs/js-ipfs#1321 (comment)

Thanks everyone for your patience. Thanks to that, we've been able to catch a some issues with gitcoin.co, which will surely take some time to fix.

abitrolly commented May 13, 2018

Ok. To stop spamming this issue I killed the bounty here and will award it according to ipfs/js-ipfs#1321 (comment)

Thanks everyone for your patience. Thanks to that, we've been able to catch a some issues with gitcoin.co, which will surely take some time to fix.

@gitcoinbot

This comment has been minimized.

Show comment
Hide comment
@gitcoinbot

gitcoinbot May 13, 2018

Issue Status: 1. Open 2. Cancelled


The funding of 0.05 ETH (34.19 USD @ $683.88/ETH) attached to this issue has been cancelled by the bounty submitter

gitcoinbot commented May 13, 2018

Issue Status: 1. Open 2. Cancelled


The funding of 0.05 ETH (34.19 USD @ $683.88/ETH) attached to this issue has been cancelled by the bounty submitter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment