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

Build issue in Angular 8 project (with resolution) #96

Closed
qu37zal opened this issue Dec 11, 2019 · 9 comments · Fixed by #97
Closed

Build issue in Angular 8 project (with resolution) #96

qu37zal opened this issue Dec 11, 2019 · 9 comments · Fixed by #97

Comments

@qu37zal
Copy link

qu37zal commented Dec 11, 2019

I have an Angular project using some ipfs related packages with cids as a dependency. My ng build fails with the following error:

ERROR in ./node_modules/cids/src/index.js
Module not found: Error: Can't resolve 'multicodec/src/base-table'

Upon investigation, I found that cids has multicodec as a dependency, and attempts to import a json file using require without specifying the file suffix. This results in the file not being identified and the aforementioned error. By specifying 'multicodec/src/base-table.json' the issue can be bypassed.

I'm happy to submit a patch if you like. I'd like to get this fixed in the upstream so I don't have to patch it locally in a postinstall step. I believe it is not considered best practice to import json in this way, so I'd propose it be imported using fs.readFile/JSON.parse, but the remedy above works as well.

@vmx
Copy link
Member

vmx commented Dec 11, 2019

@mikeal What do you think about removing CID.codecs completely?

@mikeal
Copy link
Contributor

mikeal commented Dec 11, 2019

It’s a breaking change so we shouldn’t consider that the fix for this change. I think we should experiment with something like require(‘cids/bare’) first before we go and make a big breaking change. For now let’s just take the easy .json fix.

@vmx
Copy link
Member

vmx commented Dec 11, 2019

I just think that having codecs isn't a good idea anyway, so let's just do that breaking change.

@leandroyalet
Copy link

Same issue on a project using Webpack, I fixed it by adding an alias on webpack.config file:

        resolve: {
            alias: {
                'multicodec/src/base-table': path.dirname(
                    require.resolve('multicodec/src/base-table.json')
                )
            }
        },

@rvagg
Copy link
Member

rvagg commented Dec 30, 2019

let's just get this specific issue fixed before making more radical changes, adding explicit .json extensions in require is good practice anyway #97

@ilirhushi
Copy link

ilirhushi commented Jan 9, 2020

Hi I created a PR to fix this issue: #100

vmx pushed a commit to rvagg/js-cid that referenced this issue Jan 14, 2020
@vmx vmx closed this as completed in #97 Jan 14, 2020
vmx pushed a commit that referenced this issue Jan 14, 2020
@vmx
Copy link
Member

vmx commented Jan 14, 2020

@qu37zal @leandroyalet @ilirhushi I've just released version 0.7.2. Could you please confirm that it fixes this issue?

@leandroyalet
Copy link

@vmx yes, works correctly now

leandroyalet pushed a commit to rsksmart/rif-communications-js that referenced this issue Jan 14, 2020
@ilirhushi
Copy link

@vmx yep for me too, thanks 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants