Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Trying to hack the way around Webpack build #42

Closed
acailly opened this issue Oct 27, 2017 · 3 comments
Closed

Trying to hack the way around Webpack build #42

acailly opened this issue Oct 27, 2017 · 3 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up

Comments

@acailly
Copy link

acailly commented Oct 27, 2017

Trying to find a workaround for the issue #38, I made a script to babelify every script that couldn't be parsed by webpack:

fix.js, click to expand
var exec = require('child_process').exec;

var files = [
"node_modules/cids/src/index.js",
"node_modules/borc/src/utils.js",
"node_modules/datastore-core/src/keytransform.js",
"node_modules/datastore-core/src/shard.js",
"node_modules/datastore-level/src/index.js",
"node_modules/interface-datastore/src/key.js",
"node_modules/interface-datastore/src/utils.js",
"node_modules/ipfs-bitswap/src/utils.js",
"node_modules/ipfs-bitswap/src/types/message/index.js",
"node_modules/ipfs-bitswap/src/types/wantlist/index.js",
"node_modules/ipfs-block/src/index.js",
"node_modules/ipfs-block-service/src/index.js",
"node_modules/ipfs-repo/src/index.js",
"node_modules/ipfs-repo/src/lock-memory.js",
"node_modules/ipfs-unixfs/src/index.js",
"node_modules/ipfs-unixfs-engine/src/importer/dir.js",
"node_modules/ipld-ethereum/util/createTrieResolver.js",
"node_modules/ipld-ethereum/util/createResolver.js",
"node_modules/ipld-dag-cbor/src/util.js",
"node_modules/ipld-dag-pb/src/dag-link/index.js",
"node_modules/ipld-dag-pb/src/dag-node/create.js",
"node_modules/ipld-dag-pb/src/dag-node/util.js",
"node_modules/ipld-dag-pb/src/dag-node/index.js",
"node_modules/ipld-dag-pb/src/util.js",
"node_modules/ipld-git/src/util/util.js",
"node_modules/libp2p-crypto/src/nodeify.js",
"node_modules/libp2p-crypto/src/webcrypto.js",
"node_modules/libp2p-crypto/src/keys/keys.proto.js",
"node_modules/libp2p-secio/src/support.js",
"node_modules/libp2p-secio/src/handshake/crypto.js",
"node_modules/libp2p-swarm/src/protocol-muxer.js",
"node_modules/mafmt/src/index.js --out-file node_modules/mafmt/src/index.js",
"node_modules/multiaddr/src/index.js",
"node_modules/multicodec/src/name-table.js",
"node_modules/multicodec/src/util.js",
"node_modules/multicodec/src/varint-table.js",
"node_modules/multihashes/src/index.js",
"node_modules/multihashing-async/src/index.js",
"node_modules/multihashing-async/src/utils.js",
"node_modules/multistream-select/src/util.js",
"node_modules/peer-id/src/index.js",
"node_modules/peer-info/src/index.js",
"node_modules/smart-buffer/build/smartbuffer.js",
"node_modules/borc/src/simple.js",
"node_modules/borc/src/tagged.js",
"node_modules/ipld-dag-cbor/src/resolver.js",
"node_modules/ipld-git/src/util.js",
"node_modules/ipld-git/src/resolver.js",
"node_modules/ipld-ethereum/util/createIsLink.js",
"node_modules/ipld-ethereum/util/createUtil.js",
"node_modules/libp2p-crypto/src/hmac/index-browser.js",
"node_modules/libp2p-crypto/src/keys/rsa-browser.js",
"node_modules/libp2p-crypto/src/util.js",
"node_modules/peer-book/src/index.js",
"node_modules/multistream-select/src/select.js",
"node_modules/libp2p-identify/src/message.js",
"node_modules/libp2p-swarm/src/plaintext.js",
"node_modules/libp2p-swarm/src/get-peer-info.js",
"node_modules/ipfs-pubsub-room/src/encoding.js",
"node_modules/ipfs/src/core/index.js",
"node_modules/ipld-resolver/src/index.js",
"node_modules/multibase/src/index.js",
"node_modules/multibase/src/constants.js",
"node_modules/multibase/src/base.js",
"node_modules/multibase/src/base16.js",
"node_modules/multicodec/src/index.js",
"node_modules/ipfs-repo/src/version.js",
"node_modules/interface-datastore/src/memory.js",
"node_modules/ipfs-repo/src/config.js",
"node_modules/ipfs-repo/src/api-addr.js",
"node_modules/ipfs-repo/src/blockstore.js",
"node_modules/datastore-core/src/sharding.js",
"node_modules/datastore-core/src/shard-readme.js",
"node_modules/datastore-core/src/mount.js",
"node_modules/datastore-core/src/tiered.js",
"node_modules/datastore-core/src/namespace.js",
"node_modules/multihashing-async/src/crypto-sha1-2-browser.js",
"node_modules/multihashing-async/src/blake.js",
"node_modules/ipld-dag-pb/src/dag.proto.js",
"node_modules/ipld-dag-pb/src/dag-node/rmLink.js",
"node_modules/ipld-dag-pb/src/resolver.js",
"node_modules/borc/src/diagnose.js",
"node_modules/borc/src/encoder.js",
"node_modules/borc/src/decoder.js",
"node_modules/ipld-git/src/util/commit.js",
"node_modules/ipld-git/src/util/tag.js",
"node_modules/ipld-git/src/util/tree.js",
"node_modules/ipld-ethereum/eth-block-list/index.js",
"node_modules/ipld-ethereum/util/toIpfsBlock.js",
"node_modules/ipld-raw/src/index.js",
"node_modules/libp2p-crypto/src/aes/index.js",
"node_modules/libp2p-crypto/src/keys/index.js",
"node_modules/libp2p-crypto/src/keys/rsa-class.js",
"node_modules/libp2p-crypto/src/keys/ed25519-class.js",
"node_modules/libp2p-crypto/src/keys/ed25519.js",
"node_modules/libp2p-crypto-secp256k1/src/index.js",
"node_modules/libp2p-crypto-secp256k1/src/crypto.js",
"node_modules/libp2p-crypto/src/keys/key-stretcher.js",
"node_modules/libp2p-crypto/src/keys/ephemeral-keys.js",
"node_modules/libp2p-crypto/src/keys/ecdh-browser.js",
"node_modules/multiaddr/src/codec.js",
"node_modules/peer-info/src/multiaddr-set.js",
"node_modules/ipfs/src/core/boot.js",
"node_modules/ipfs/src/core/components/pre-start.js",
"node_modules/ipfs/src/core/components/start.js",
"node_modules/ipfs-bitswap/src/index.js",
"node_modules/ipfs-bitswap/src/want-manager/index.js",
"node_modules/varint-decoder/src/index.js",
"node_modules/ipfs-bitswap/src/types/message/message.proto.js",
"node_modules/ipfs-bitswap/src/types/message/entry.js",
"node_modules/ipfs-bitswap/src/types/wantlist/entry.js",
"node_modules/ipfs-bitswap/src/want-manager/msg-queue.js",
"node_modules/ipfs-bitswap/src/network.js",
"node_modules/pull-length-prefixed/src/encode.js",
"node_modules/pull-length-prefixed/src/decode.js",
"node_modules/ipfs-bitswap/src/decision-engine/index.js",
"node_modules/ipfs-bitswap/src/decision-engine/ledger.js",
"node_modules/ipfs-bitswap/src/notifications.js",
"node_modules/libp2p-floodsub/src/index.js",
"node_modules/time-cache/src/index.js",
"node_modules/libp2p-floodsub/src/peer.js",
"node_modules/libp2p-floodsub/src/message/rpc.proto.js",
"node_modules/libp2p-floodsub/src/message/topic-descriptor.proto.js",
"node_modules/libp2p-floodsub/src/utils.js",
"node_modules/ipfs/src/core/components/stop.js",
"node_modules/ipfs/src/core/components/is-online.js",
"node_modules/ipfs/src/core/components/version.js",
"node_modules/ipfs/src/core/components/id.js",
"node_modules/ipfs/src/core/components/repo.js",
"node_modules/ipfs/src/core/components/init.js",
"node_modules/ipfs/src/core/components/bootstrap.js",
"node_modules/ipfs/src/core/components/config.js",
"node_modules/ipfs/src/core/components/block.js",
"node_modules/ipfs/src/core/components/object.js",
"node_modules/ipfs-unixfs/src/unixfs.proto.js",
"node_modules/ipfs/src/core/components/dag.js",
"node_modules/ipfs/src/core/components/libp2p.js",
"node_modules/ipfs/src/core/runtime/libp2p-browser.js",
"node_modules/libp2p-websockets/src/index.js",
"node_modules/interface-connection/src/connection.js",
"node_modules/libp2p-websockets/src/ma-to-url.js",
"node_modules/libp2p-websockets/src/listener.js",
"node_modules/libp2p-webrtc-star/src/index.js",
"node_modules/libp2p-webrtc-star/src/utils.js",
"node_modules/libp2p-multiplex/src/index.js",
"node_modules/multiplex/src/index.js",
"node_modules/multiplex/src/channel.js",
"node_modules/libp2p-multiplex/src/muxer.js",
"node_modules/libp2p-secio/src/index.js",
"node_modules/libp2p-secio/src/handshake/index.js",
"node_modules/libp2p-secio/src/handshake/propose.js",
"node_modules/libp2p-secio/src/handshake/secio.proto.js",
"node_modules/libp2p-secio/src/handshake/exchange.js",
"node_modules/libp2p-secio/src/handshake/finish.js",
"node_modules/libp2p-secio/src/etm.js",
"node_modules/libp2p-secio/src/state.js",
"node_modules/libp2p-railing/src/index.js",
"node_modules/libp2p/src/index.js",
"node_modules/libp2p-ping/src/handler.js",
"node_modules/libp2p-ping/src/ping.js",
"node_modules/libp2p-ping/src/util.js",
"node_modules/libp2p-swarm/src/index.js",
"node_modules/libp2p-swarm/src/transport.js",
"node_modules/multistream-select/src/listener/index.js",
"node_modules/multistream-select/src/listener/select-handler.js",
"node_modules/multistream-select/src/listener/ls-handler.js",
"node_modules/multistream-select/src/dialer/index.js",
"node_modules/libp2p-swarm/src/limit-dialer/index.js",
"node_modules/libp2p-swarm/src/limit-dialer/queue.js",
"node_modules/libp2p-swarm/src/connection.js",
"node_modules/libp2p-identify/src/listener.js",
"node_modules/libp2p-identify/src/dialer.js",
"node_modules/libp2p-swarm/src/dial.js",
"node_modules/ipfs/src/core/components/swarm.js",
"node_modules/ipfs/src/core/components/ping.js",
"node_modules/ipfs/src/core/components/files.js",
"node_modules/ipfs-unixfs-engine/src/importer/index.js",
"node_modules/ipfs-unixfs-engine/src/builder/create-build-stream.js",
"node_modules/ipfs-unixfs-engine/src/builder/builder.js",
"node_modules/ipfs-unixfs-engine/src/builder/reduce.js",
"node_modules/ipfs-unixfs-engine/src/builder/flat/index.js",
"node_modules/ipfs-unixfs-engine/src/builder/balanced/balanced-reducer.js",
"node_modules/ipfs-unixfs-engine/src/builder/trickle/trickle-reducer.js",
"node_modules/ipfs-unixfs-engine/src/importer/tree-builder.js",
"node_modules/ipfs-unixfs-engine/src/importer/dir-flat.js",
"node_modules/ipfs-unixfs-engine/src/importer/flat-to-shard.js",
"node_modules/ipfs-unixfs-engine/src/importer/dir-sharded.js",
"node_modules/ipfs-unixfs-engine/src/hamt/bucket.js",
"node_modules/sparse-array/index.js",
"node_modules/ipfs-unixfs-engine/src/hamt/consumable-hash.js",
"node_modules/ipfs-unixfs-engine/src/hamt/consumable-buffer.js",
"node_modules/ipfs-unixfs-engine/src/chunker/fixed-size.js",
"node_modules/ipfs-unixfs-engine/src/exporter/index.js",
"node_modules/ipfs-unixfs-engine/src/exporter/dir-flat.js",
"node_modules/ipfs-unixfs-engine/src/exporter/dir-hamt-sharded.js",
"node_modules/ipfs-unixfs-engine/src/exporter/clean-multihash.js",
"node_modules/ipfs-unixfs-engine/src/exporter/file.js",
"node_modules/ipfs-unixfs-engine/src/exporter/object.js",
"node_modules/ipfs/src/core/components/bitswap.js",
"node_modules/ipfs/src/core/components/pubsub.js",
"node_modules/ipfs/src/core/components/dht.js",
"node_modules/ipfs/src/core/runtime/repo-browser.js",
"node_modules/ipfs/src/core/state.js",
"node_modules/y-ipfs-connector/src/index.js",
"node_modules/ipfs-pubsub-room/src/index.js",
"node_modules/hyperdiff/lib/index.js",
"node_modules/ipfs-pubsub-room/src/connection.js",
"node_modules/y-ipfs-connector/src/encode.js",
"node_modules/y-ipfs-connector/src/decode.js",
"node_modules/cids/node_modules/multicodec/src/varint-table.js",
"node_modules/cids/node_modules/multicodec/src/util.js",
"node_modules/ipfs-block/node_modules/cids/src/index.js",
"node_modules/cids/node_modules/multicodec/src/index.js",
"node_modules/cids/node_modules/multicodec/src/name-table.js"
]

files.map(function(file){
console.log("Fixing " + file)
exec("node_modules\.bin\babel " + file + " --out-file " + file + " --presets=es2015",
function(err, stdout, stderr){
if (stdout) console.log(stdout)
if (stderr) console.error(stderr)
if (err) console.error(err)
}
)
})

I just added babel as dev dependency (yarn add babel-cli --dev) and run this script (node fix).

However, I still have an error:

Uncaught Error: second argument must be a CID
    at new e (index.js:29) // ipfs-block
    at index.js:381 // ipld-resolver
    at n (waterfall.js:16) // async
    at r (waterfall.js:23) // async
    at onlyOnce.js:12 // async/internal
    at Object.o [as serialize] (util.js:27) //ipld-dag-pb
    at index.js:379 //ipld-resolver
    at n (waterfall.js:16) // async
    at t.default (waterfall.js:26) // async
    at e.value (index.js:378) //ipld-resolver

I don't know the internal of ipfs (yet), so if anyone has an idea of what could cause this bug, I take it 😉

@acailly
Copy link
Author

acailly commented Oct 27, 2017

To others facing the same issue, the only way I've found to make my app work was to eject the configuration of create-react-app and delete the UglifyJsPlugin call from the webpack prod config.

@daviddias daviddias added ready kind/bug A bug in existing code (including security flaws) help wanted Seeking public contribution on this issue exp/expert Having worked on the specific codebase is important P2 Medium: Good to have, but can wait until someone steps up labels Jan 25, 2018
@daviddias
Copy link
Member

Related --> ipfs/js-ipfs#938 (comment)

@daviddias daviddias added P1 High: Likely tackled by core team if no one steps up and removed P2 Medium: Good to have, but can wait until someone steps up labels Mar 21, 2018
@fsdiogo
Copy link
Member

fsdiogo commented Apr 23, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up
Projects
None yet
Development

No branches or pull requests

4 participants