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

Use relative path for browser alias to fix webpack module resolution. #404

Merged
merged 1 commit into from
Jun 29, 2017

Conversation

mckaydavis
Copy link
Contributor

No description provided.

@SimonWoolf
Copy link
Member

Hi @mckaydavis, sorry for the delay, this slipped under the radar -- I'll have a look at this today or tomorrow

@mckaydavis
Copy link
Contributor Author

@SimonWoolf No problem. Sorry for the somewhat terse pull message. Here's some more info on why I made the pull request.

I can't share the code-base for a repro, but this is the original build error:

ERROR in ./src/sync/AblySyncTransport.ts
Module not found: Error: Can't resolve 'ably' in '/tmp/myproject/src/sync'
 @ ./src/sync/AblySyncTransport.ts 12:0-29
 @ ./src/store/StateSync.ts
 @ ./src/Session.ts
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/vue/App.vue
 @ ./src/vue/App.vue
 @ ./src/index.js
 @ multi webpack-hot-middleware/client?reload=true ./src/index.js

The project's TypeScript tsconfig.json has "moduleResolution": "node" and correctly finds Ably in node_modules, but webpack's module resolution does not.

I've attached ably.webpack.error.log.txt, a log of the relevant Ably module resolution path failure output provided by webpack --display-error-details.

After looking at the log I prefixed the "browser" alias in ably-js/package.json with ./ and everything worked.

Looking at the other paths, the 'react-native' alias may have the same issue.

I checked out the package-browser-field-spec where it states "All paths for browser fields are relative to the package.json file location (and usually project root as a result)." -- and it seems to me that the non-prefixed non-absolute path should work, but I guess it fails in whatever code implements it. Unfortunately the spec doesn't specify the resolution behavior if the path provided is not prefixed with ./.

Hopefully this info helps future searchers (even outside Ably-js) who run into this error!

@SimonWoolf SimonWoolf merged commit 1639c2e into ably:master Jun 29, 2017
@SimonWoolf
Copy link
Member

Thanks @mckaydavis! Made the equivalent change to other paths in 465cdda.

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

Successfully merging this pull request may close these issues.

2 participants