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

require fails in webpack due to node imports #45

Open
acthp opened this issue Mar 14, 2018 · 2 comments
Open

require fails in webpack due to node imports #45

acthp opened this issue Mar 14, 2018 · 2 comments

Comments

@acthp
Copy link

acthp commented Mar 14, 2018

Module not found: Error: Can't resolve 'fs' in '/home/brian/tmp/XenaGoWidget/node_modules/jsedn/lib'
 @ ./node_modules/jsedn/lib/reader.js 275:9-22
 @ ./node_modules/jsedn/index.js
 @ ./src/XenaGoApp.js
 @ ./demo/src/index.js
 @ multi ./node_modules/nwb/polyfills.js (webpack)-dev-server/client?/ (webpack)/hot/only-dev-server.js ./demo/src/index.js
Module not found: Error: Can't resolve 'type' in '/home/brian/tmp/XenaGoWidget/node_modules/jsedn/lib'
 @ ./node_modules/jsedn/lib/type.js 3:105-120
 @ ./node_modules/jsedn/lib/reader.js
 @ ./node_modules/jsedn/index.js
 @ ./src/XenaGoApp.js
 @ ./demo/src/index.js
 @ multi ./node_modules/nwb/polyfills.js (webpack)-dev-server/client?/ (webpack)/hot/only-dev-server.js ./demo/src/index.js
@Malabarba
Copy link

has anyone found a solution for this?

@npfitz
Copy link

npfitz commented Mar 17, 2019

So, I seem to have just gotten this working for me, though I'm not totally happy with the solution. The root of the problem seems to be that type-component is in the dependencies, but type isn't. When webpack is going through looking for it's require statements, it's finding a require for both. It doesn't care that we only ever use one or the other, it's going to try to bundle them both anyways. The problem is that type can't be found in that context. I tried having type be a dependency of the parent project, but it didn't seem to care much.

My work-around was to alias "type" to "type-component" in my webpack config. This means type-component probably gets bundled twice... but it bundles. However, it could have strange effects in other dependencies that may also require "type"

resolve: { alias: { type: 'type-component' } },

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

No branches or pull requests

3 participants