I am trying to build a simple tool with typescript, react and apollo.
But when I follow the guidelines on how to use react-apollo I get a lot of warnings when building my app with webpack.
I'm not sure if this is a bug or of this is something that is I am misunderstanding. But hopefully someone can give me a hint(?)
WARNING in ./~/apollo-client/index.js
(Emitted value instead of an instance of Error) Cannot find source file '../../src/index.ts': Error: Can't resolve '../../src/index.ts' in 'C:\Dev\app_ma
nager\ui\node_modules\apollo-client'
@ ./~/react-apollo/lib/browser.js 10:22-46
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/transport/networkInterface.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/transport/networkInterface.ts': Error: Can't resolve '../../../src/
transport/networkInterface.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\transport'
@ ./~/apollo-client/index.js 1:0-98
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/transport/batchedNetworkInterface.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/transport/batchedNetworkInterface.ts': Error: Can't resolve '../../
../src/transport/batchedNetworkInterface.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\transport'
@ ./~/apollo-client/index.js 2:0-115
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/store.js
(Emitted value instead of an instance of Error) Cannot find source file '../../src/store.ts': Error: Can't resolve '../../src/store.ts' in 'C:\Dev\app_ma
nager\ui\node_modules\apollo-client'
@ ./~/apollo-client/index.js 4:0-66
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/core/ObservableQuery.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/core/ObservableQuery.ts': Error: Can't resolve '../../../src/core/O
bservableQuery.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\core'
@ ./~/apollo-client/index.js 5:0-58
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/readFromStore.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/readFromStore.ts': Error: Can't resolve '../../../src/data/rea
dFromStore.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/index.js 6:0-59
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/writeToStore.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/writeToStore.ts': Error: Can't resolve '../../../src/data/writ
eToStore.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/index.js 7:0-57
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/queries/getFromAST.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/queries/getFromAST.ts': Error: Can't resolve '../../../src/queries/
getFromAST.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\queries'
@ ./~/apollo-client/index.js 8:0-102
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/queries/networkStatus.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/queries/networkStatus.ts': Error: Can't resolve '../../../src/queri
es/networkStatus.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\queries'
@ ./~/apollo-client/index.js 9:0-57
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/queries/queryTransform.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/queries/queryTransform.ts': Error: Can't resolve '../../../src/quer
ies/queryTransform.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\queries'
@ ./~/apollo-client/index.js 10:0-66
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/errors/ApolloError.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/errors/ApolloError.ts': Error: Can't resolve '../../../src/errors/A
polloError.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\errors'
@ ./~/apollo-client/index.js 11:0-52
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/ApolloClient.js
(Emitted value instead of an instance of Error) Cannot find source file '../../src/ApolloClient.ts': Error: Can't resolve '../../src/ApolloClient.ts' in
'C:\Dev\app_manager\ui\node_modules\apollo-client'
@ ./~/apollo-client/index.js 12:0-42
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/storeUtils.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/storeUtils.ts': Error: Can't resolve '../../../src/data/storeU
tils.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/index.js 13:0-47
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/fragmentMatcher.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/fragmentMatcher.ts': Error: Can't resolve '../../../src/data/f
ragmentMatcher.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/index.js 14:0-71
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/transport/batching.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/transport/batching.ts': Error: Can't resolve '../../../src/transpor
t/batching.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\transport'
@ ./~/apollo-client/transport/batchedNetworkInterface.js 21:0-43
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/assign.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/assign.ts': Error: Can't resolve '../../../src/util/assign.ts'
in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/transport/batchedNetworkInterface.js 22:0-40
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/store.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/store.ts': Error: Can't resolve '../../../src/data/store.ts' i
n 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/store.js 10:0-37
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/queries/store.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/queries/store.ts': Error: Can't resolve '../../../src/queries/store
.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\queries'
@ ./~/apollo-client/store.js 11:0-43
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/mutations/store.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/mutations/store.ts': Error: Can't resolve '../../../src/mutations/s
tore.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\mutations'
@ ./~/apollo-client/store.js 12:0-47
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/optimistic-data/store.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/optimistic-data/store.ts': Error: Can't resolve '../../../src/optim
istic-data/store.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\optimistic-data'
@ ./~/apollo-client/store.js 13:0-84
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/Observable.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/Observable.ts': Error: Can't resolve '../../../src/util/Observ
able.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/core/ObservableQuery.js 19:0-48
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/core/types.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/core/types.ts': Error: Can't resolve '../../../src/core/types.ts' i
n 'C:\Dev\app_manager\ui\node_modules\apollo-client\core'
@ ./~/apollo-client/core/ObservableQuery.js 21:0-37
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/errorHandling.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/errorHandling.ts': Error: Can't resolve '../../../src/util/err
orHandling.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/core/ObservableQuery.js 22:0-62
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/isEqual.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/isEqual.ts': Error: Can't resolve '../../../src/util/isEqual.t
s' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/data/readFromStore.js 13:0-43
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/maybeDeepFreeze.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/maybeDeepFreeze.ts': Error: Can't resolve '../../../src/util/m
aybeDeepFreeze.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/core/ObservableQuery.js 24:0-54
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/queries/directives.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/queries/directives.ts': Error: Can't resolve '../../../src/queries/
directives.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\queries'
@ ./~/apollo-client/data/writeToStore.js 12:0-55
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/cloneDeep.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/cloneDeep.ts': Error: Can't resolve '../../../src/util/cloneDe
ep.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/queries/queryTransform.js 2:0-46
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/core/QueryManager.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/core/QueryManager.ts': Error: Can't resolve '../../../src/core/Quer
yManager.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\core'
@ ./~/apollo-client/ApolloClient.js 12:0-52
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/util/environment.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/util/environment.ts': Error: Can't resolve '../../../src/util/envir
onment.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\util'
@ ./~/apollo-client/ApolloClient.js 13:0-51
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/proxy.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/proxy.ts': Error: Can't resolve '../../../src/data/proxy.ts' i
n 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/ApolloClient.js 15:0-47
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/actions.js
(Emitted value instead of an instance of Error) Cannot find source file '../../src/actions.ts': Error: Can't resolve '../../src/actions.ts' in 'C:\Dev\ap
p_manager\ui\node_modules\apollo-client'
@ ./~/apollo-client/data/store.js 9:0-164
@ ./~/apollo-client/store.js
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/replaceQueryResults.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/replaceQueryResults.ts': Error: Can't resolve '../../../src/da
ta/replaceQueryResults.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/data/store.js 14:0-61
@ ./~/apollo-client/store.js
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/transport/Deduplicator.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/transport/Deduplicator.ts': Error: Can't resolve '../../../src/tran
sport/Deduplicator.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\transport'
@ ./~/apollo-client/core/QueryManager.js 9:0-58
@ ./~/apollo-client/ApolloClient.js
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/data/resultReducers.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/data/resultReducers.ts': Error: Can't resolve '../../../src/data/re
sultReducers.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\data'
@ ./~/apollo-client/core/QueryManager.js 16:0-61
@ ./~/apollo-client/ApolloClient.js
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
WARNING in ./~/apollo-client/scheduler/scheduler.js
(Emitted value instead of an instance of Error) Cannot find source file '../../../src/scheduler/scheduler.ts': Error: Can't resolve '../../../src/schedul
er/scheduler.ts' in 'C:\Dev\app_manager\ui\node_modules\apollo-client\scheduler'
@ ./~/apollo-client/core/QueryManager.js 23:0-57
@ ./~/apollo-client/ApolloClient.js
@ ./~/apollo-client/index.js
@ ./~/react-apollo/lib/browser.js
@ ./src/index.tsx
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
webpack: Compiled with warnings.
This is the react entry point code (works without any warnings):
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
When I add this I get the warnings:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import {
ApolloClient,
createNetworkInterface,
gql,
graphql,
ApolloProvider,
} from 'react-apollo';
const client = new ApolloClient({
networkInterface: createNetworkInterface({
uri: 'http://localhost:3000/graphql',
}),
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
There are warnings I know nothing about...
No warnings
I'm seeing the exact same problem using basically the same versions of react-apollo, typescript and webpack (I don't have apollo-client as a direct dependency since the guide didn't mention it).
I'm on node v6.10.1 and npm v3.10.10.
I'm seeing the same issues using:
"apollo-client": "^0.8.2",
"graphql-tag": "^1.2.4",
"react-apollo": "^0.10.1",
When using those versions I also got some other errors about duplicate definitions but after downgrading to [email protected] those went away but the "Cannot find source file" warnings are still present.
I just noticed something, our output says:
"Cannot find source file '../../../src/data/resultReducers.ts': Error: Can't resolve '../../../src/data/resultReducers.ts'" which makes sense since the file is resultReducers.js.
Something tells me it's some error in our webpack/typescript configs with how they allow module resolving?
I found the problem in my build config based on this thread https://github.com/angular-redux/store/issues/64.
In my webpack config I have the source-maps-loader but didn't exclude node_modules and this seemed to be causing the issue. Adding the exclude fixed it for me.
Yes, that did it :) Thanks!
Hi @Ramzeus! Sorry for the late response. Has this issue been resolved for you?
@helfer Yes, it was resolved.
@miltonhultgren Can you show me, how did you exlude the node_modules ? It doens't work for me
@miltonhultgren My module rule looks something like this. Hope it can help you:
{
enforce: 'pre',
test: /\.js$/,
loader: "source-map-loader",
exclude: [/node_modules/, /build/, /__test__/],
},
Most helpful comment
@miltonhultgren My module rule looks something like this. Hope it can help you: