Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

UglifyJS #611

Closed
povi opened this issue Oct 20, 2017 · 29 comments
Closed

UglifyJS #611

povi opened this issue Oct 20, 2017 · 29 comments

Comments

@povi
Copy link

povi commented Oct 20, 2017

Running npm run build results in error:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

./node_modules/ipfs-api/src/utils/module-config.js:7

when trying to build a react.js project that has ipfs-api as a dependency.

As suggested by https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify , the project should be published pre-compiled.

@atfornes
Copy link
Contributor

I did some work on this, providing a prepublish routine for npm at atfornes@bd3a68e.

Please, let us know if it helped

@adrianmcli
Copy link

@atfornes Can you make a PR and ask the maintainers to republish the package with the pre-compiled code?

@GoodBoy962
Copy link

@atfornes Could I simply add prepublish in node_modules/ipfs-api/package.json file?

@GoodBoy962
Copy link

@povi add help wanted label, please.

@atfornes
Copy link
Contributor

@GoodBoy962, @adrianmcli, I am going to have a look into this today, hopefully sharing a useful pull request.

@atfornes atfornes mentioned this issue Nov 17, 2017
@atfornes
Copy link
Contributor

@GoodBoy962 @adrianmcli, please let me know if the pull request #630 solves your issues.

@GoodBoy962
Copy link

@atfornes Thanks! Waiting for pr confirmation

@daviddias
Copy link
Contributor

Hi all!

For a time, we published all of our dependencies transpiled for a while and then we decided to revert back. The reasons where the following:

  • It would increase bundle size
  • There are no source maps that can bring you back to the original line of code (for when a error happens) forcing you to npm link everything when debugging
  • One more step to maintain

The reality at the time was that there was no uglifyJS with ES6 support, but today (roughly started 6 months ago) there is indeed uglifyJS with ES6 support and we use it for our dist version.

You can use that version by requiring the module as require('ipfs-api/dist/index.min.js') and avoid hitting this problem.

What I would like to see is create-react-app to upgrade to the latest uglifyJS. Asking the entire world to publish ES5 code -- https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify -- specially when pretty much the only thing we do is Arrow Functions. Let me enphasize that there is an update uglifyJS that does indeed support ES6

@daviddias
Copy link
Contributor

@atfornes
Copy link
Contributor

thanks @diasdavid,

The only issue that remains for me is that the dist/ files are only available from official releases, and cannot be accessed from any commit/branch. This would be solved with a npm prepare instruction calling aegir build. Is there any chance that something like that would be merged?

@GoodBoy962
Copy link

@diasdavid
Here is the next fail:
Failed to minify the code from this file: ./node_modules/ipfs-api/dist/index.min.js:1:33639

@atfornes
Copy link
Contributor

@GoodBoy962, using my pull request you could include lib/index.js which is transpiled, so it should not fail.

@daviddias daviddias changed the title React fails to minify projects that have ipfs-api as a dependency UglifyJS Nov 21, 2017
@Timer
Copy link

Timer commented Nov 21, 2017

Let me enphasize that there is an update uglifyJS that does indeed support ES6

Uglify may support minifying ES6, but the code will then not run in IE 9 (syntactically).
We expect support for compiling package code sometime next year, so this package will probably remain broken or require you to eject until then.

@GoodBoy962
Copy link

@atfornes which file should i change in node_modules?

@atfornes
Copy link
Contributor

@GoodBoy962, I would not manually change any file in the node_modules, but instead install the modified branch with:
npm install --save atfornes/js-ipfs-api#transpiled

@GoodBoy962
Copy link

@atfornes I have got such a stack trace:

WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew== integrity checksum failed when using sha512: wanted sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew== but got sha1-Yi4y6CSItJJ5EUpPns9F581rulU=. (6052 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw== integrity checksum failed when using sha512: wanted sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw== but got sha1-qRlH2h9KUW6jjltOwOw3c2deCIY=. (4568 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ== integrity checksum failed when using sha512: wanted sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ== but got sha1-No8lEtefnUb9/HE0mueHi7weuVw=. (25587 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g== integrity checksum failed when using sha512: wanted sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g== but got sha1-PdPT55Crwk17DToDT/q6vijrvAQ=. (8471 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== integrity checksum failed when using sha512: wanted sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== but got sha1-4TjMdeBAxyexlm/l5fjJruJW/js=. (4655 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw== integrity checksum failed when using sha512: wanted sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw== but got sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=. (49753 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== integrity checksum failed when using sha512: wanted sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== but got sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=.MacBook-Pro-Alexander:MedicalCards alex$ npm install --save atfornes/js-ipfs-api#transpiled
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew== integrity checksum failed when using sha512: wanted sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew== but got sha1-Yi4y6CSItJJ5EUpPns9F581rulU=. (6052 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== integrity checksum failed when using sha512: wanted sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== but got sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=. (23213 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== integrity checksum failed when using sha512: wanted sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== but got sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=. (5535 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== integrity checksum failed when using sha512: wanted sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== but got sha1-4TjMdeBAxyexlm/l5fjJruJW/js=. (4655 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw== integrity checksum failed when using sha512: wanted sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw== but got sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=. (49753 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g== integrity checksum failed when using sha512: wanted sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g== but got sha1-PdPT55Crwk17DToDT/q6vijrvAQ=. (8471 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ== integrity checksum failed when using sha512: wanted sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ== but got sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=. (28358 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-scrollbar-size@2.0.2 requires a peer of lodash@^4.17.0 but none is installed. You must install peer dependencies yourself.

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/alex/.npm/_logs/2017-11-22T11_35_10_016Z-debug.log

@atfornes
Copy link
Contributor

atfornes commented Nov 22, 2017

@GoodBoy962 please try a clean npm install, previously removing node_module folder and package-lock.json file. I have installed it with the same instruction without problems.

this issue gives more details about those WARNINGS npm/npm#16861
and this about the ERR: npm/npm#17858

@GoodBoy962
Copy link

@atfornes thanks! That helped me to install your custom dependency.
But the build is still in fail.
./node_modules/ipfs-api/lib/utils/module-config.js:7

@atfornes
Copy link
Contributor

@GoodBoy962, can you share what is the content of that line in that file?

In my instalation is var multiaddr = require('multiaddr'); which should not bring errors.

can you also share what is the error message?

@GoodBoy962
Copy link

@atfornes Here is the whole file. My 7th line is different
`
'use strict';

const getConfig = require('./default-config');
const requestAPI = require('./request-api');
const multiaddr = require('multiaddr');

module.exports = arg => {
const config = getConfig();

if (typeof arg === 'function') {
return arg;
} else if (typeof arg === 'object') {
return requestAPI(arg);
} else if (typeof arg === 'string') {
const maddr = multiaddr(arg).nodeAddress();
config.host = maddr.address;
config.port = maddr.port;
return requestAPI(config);
} else {
throw new Error('Argument must be a send function or a config object.');
}
};
`

@atfornes
Copy link
Contributor

@GoodBoy962, It is weird that a file in lib folder is not transpiled... (does not have arrow functions, for instance).

I am sorry I cannot continue following this issue, please try again to do a clean npm install and check that babel (the transpiler that transforms original code in src/ to transpiled code in lib/) process is run.

Please let us know if you found how to fix that issue.

@GoodBoy962
Copy link

@atfornes are you sure that after installing your custom solution I should have a file which is not the same as I published here?
Which result do you have after making next steps : 1) clean npm install, 2) npm install your custom ipfs ?

@atfornes
Copy link
Contributor

you are right @GoodBoy962, I missed the babel config file, which is fixed now by a1504c6.

Please try again now.

@GoodBoy962
Copy link

@atfornes That helped! Thank you a lot!
Unfortunately there is another the same error with cids(it is ipld) module.

@atfornes
Copy link
Contributor

@GoodBoy962, you can propose a similar PR for that module then. Please let us know when it is ready.

@girards
Copy link

girards commented Jan 17, 2018

Hey I'm getting a :
Module not found: Error: Can't resolve 'ipfs-api' in '/Users/nicolasgirardot/PleaseCom/please-web/src/components/AddListing/Place'

when trying to use your fix, I tried clean installing and all.. Hopefully you can help me fix this !

@GoodBoy962
Copy link

Any changes for that bug?

@Timer
Copy link

Timer commented Feb 24, 2018

We now compile dependencies starting in react-scripts@^2, give it a try!

@fsdiogo
Copy link
Contributor

fsdiogo commented Apr 23, 2018

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

@fsdiogo fsdiogo closed this as completed Apr 23, 2018
@ghost ghost removed the ready label Apr 23, 2018
godfreyhobbs added a commit to ConsenSysMesh/stow-box that referenced this issue Jul 10, 2018
godfreyhobbs added a commit to ConsenSysMesh/stow-box that referenced this issue Jul 11, 2018
…#15)

* adding web3 1.0 as dep and removing truffle-contract.  Adding npm version of linnia-js

* update package-lock.json

* adding config file

* update config.yml

* fixing scrypt test error and cleaning up tests

* udpating dotenv

* remove uglyfy until this is fixed ipfs-inactive/js-ipfs-http-client#611
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants