I'm using parcel to manage a react-ts-ssr project. I want to be able to run the server part in dev mode.
The server part of the project also runs a Apollo-graphql
middleware in order to proxy the backend rest API.
no babelrc, or config in package.json.
Package.json
...
"scripts":{
...
"dev:server": "parcel src/server/index.ts"
},
...
tsconfig.json
{
"compilerOptions": {
"lib": ["es2015", "es2016", "es2017", "dom"],
"jsx": "react",
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
parcel compiles the code and fires up a dev server that will watch for changes and restart the node service as needed.
Parcel starts compiling the project, but when it comes to a node_module
that has embed typescript definition files (apollo-graphql
), it starts looking for the .ts
source of the file, instead of using the compiled .js
file that is right next to the definition file.
> [email protected] dev:server /Users/evanion/Projects/Personal/Zeus/frontend/apps/web-apollo
> parcel src/server/index.ts
Server running at http://localhost:1234
⚠️ Could not load source file "../src/index.ts" in source map of "../../node_modules/graphql-tools/dist/index.js".
⚠️ Could not load source file "../src/index.ts" in source map of "../../node_modules/graphql-subscriptions/dist/index.js".
⚠️ Could not load source file "../src/with-filter.ts" in source map of "../../node_modules/graphql-subscriptions/dist/with-filter.js".
⚠️ Could not load source file "../src/pubsub.ts" in source map of "../../node_modules/graphql-subscriptions/dist/pubsub.js".
⚠️ Could not load source file "../src/makeExecutableSchema.ts" in source map of "../../node_modules/graphql-tools/dist/makeExecutableSchema.js".
⚠️ Could not load source file "../src/mock.ts" in source map of "../../node_modules/graphql-tools/dist/mock.js".
⚠️ Could not load source file "../src/schemaVisitor.ts" in source map of "../../node_modules/graphql-tools/dist/schemaVisitor.js".
⚠️ Could not load source file "../../src/transforms/index.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/index.js".
⚠️ Could not load source file "../../src/stitching/index.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/index.js".
⚠️ /Users/evanion/Projects/Personal/Zeus/frontend/apps/web-apollo/node_modules/mime/mime.js:52:32: Cannot statically evaluate fs argument
50 | // Read file and split into lines
51 | var map = {},
> 52 | content = fs.readFileSync(file, 'ascii'),
| ^
53 | lines = content.split(/[\r\n]+/);
54 |
55 | lines.forEach(function(line) {
⚠️ Could not load source file "../src/event-emitter-to-async-iterator.ts" in source map of "../../node_modules/graphql-subscriptions/dist/event-emitter-to-async-iterator.js".
⚠️ Could not load source file "../src/index.ts" in source map of "../../node_modules/@apollographql/graphql-playground-html/dist/index.js".
⚠️ Could not load source file "../src/mergeDeep.ts" in source map of "../../node_modules/graphql-tools/dist/mergeDeep.js".
⚠️ Could not load source file "../../src/transforms/CheckResultAndHandleErrors.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/CheckResultAndHandleErrors.js".
⚠️ Could not load source file "../../src/transforms/transformSchema.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/transformSchema.js".
⚠️ Could not load source file "../../src/transforms/FilterTypes.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/FilterTypes.js".
⚠️ Could not load source file "../../src/transforms/RenameRootFields.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/RenameRootFields.js".
⚠️ Could not load source file "../../src/transforms/TransformRootFields.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/TransformRootFields.js".
⚠️ Could not load source file "../../src/transforms/FilterRootFields.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/FilterRootFields.js".
⚠️ Could not load source file "../../src/transforms/ExtractField.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/ExtractField.js".
⚠️ Could not load source file "../../src/transforms/WrapQuery.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/WrapQuery.js".
⚠️ Could not load source file "../../src/transforms/AddArgumentsAsVariables.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/AddArgumentsAsVariables.js".
⚠️ Could not load source file "../../src/transforms/ReplaceFieldWithFragment.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/ReplaceFieldWithFragment.js".
⚠️ Could not load source file "../../src/transforms/RenameTypes.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/RenameTypes.js".
⚠️ Could not load source file "../../src/transforms/ExpandAbstractTypes.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/ExpandAbstractTypes.js".
⚠️ Could not load source file "../../src/transforms/FilterToSchema.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/FilterToSchema.js".
⚠️ Could not load source file "../../src/generate/index.ts" in source map of "../../node_modules/graphql-tools/dist/generate/index.js".
⚠️ Could not load source file "../../src/stitching/introspectSchema.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/introspectSchema.js".
⚠️ Could not load source file "../../src/stitching/defaultMergedResolver.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/defaultMergedResolver.js".
⚠️ Could not load source file "../../src/stitching/delegateToSchema.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/delegateToSchema.js".
⚠️ Could not load source file "../../src/stitching/makeRemoteExecutableSchema.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/makeRemoteExecutableSchema.js".
⚠️ Could not load source file "../../src/stitching/mergeSchemas.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/mergeSchemas.js".
⚠️ Could not load source file "../../src/transforms/AddTypenameToAbstract.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/AddTypenameToAbstract.js".
⚠️ Could not load source file "../src/render-playground-page.ts" in source map of "../../node_modules/@apollographql/graphql-playground-html/dist/render-playground-page.js".
⚠️ Could not load source file "../../src/transforms/transforms.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/transforms.js".
⚠️ Could not load source file "../../src/stitching/schemaRecreation.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/schemaRecreation.js".
⚠️ Could not load source file "../../src/stitching/resolvers.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/resolvers.js".
⚠️ Could not load source file "../../src/transforms/visitSchema.ts" in source map of "../../node_modules/graphql-tools/dist/transforms/visitSchema.js".
⚠️ Could not load source file "../src/isEmptyObject.ts" in source map of "../../node_modules/graphql-tools/dist/isEmptyObject.js".
⚠️ Could not load source file "../src/isSpecifiedScalarType.ts" in source map of "../../node_modules/graphql-tools/dist/isSpecifiedScalarType.js".
⚠️ Could not load source file "../../src/stitching/errors.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/errors.js".
⚠️ Could not load source file "../src/implementsAbstractType.ts" in source map of "../../node_modules/graphql-tools/dist/implementsAbstractType.js".
⚠️ Could not load source file "../../src/stitching/linkToFetcher.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/linkToFetcher.js".
⚠️ Could not load source file "../../src/stitching/mapAsyncIterator.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/mapAsyncIterator.js".
⚠️ Could not load source file "../../src/generate/assertResolveFunctionsPresent.ts" in source map of "../../node_modules/graphql-tools/dist/generate/assertResolveFunctionsPresent.js".
⚠️ Could not load source file "../../src/generate/addSchemaLevelResolveFunction.ts" in source map of "../../node_modules/graphql-tools/dist/generate/addSchemaLevelResolveFunction.js".
⚠️ Could not load source file "../../src/generate/checkForResolveTypeResolver.ts" in source map of "../../node_modules/graphql-tools/dist/generate/checkForResolveTypeResolver.js".
⚠️ Could not load source file "../../src/generate/decorateWithLogger.ts" in source map of "../../node_modules/graphql-tools/dist/generate/decorateWithLogger.js".
⚠️ Could not load source file "../../src/generate/extendResolversFromInterfaces.ts" in source map of "../../node_modules/graphql-tools/dist/generate/extendResolversFromInterfaces.js".
⚠️ Could not load source file "../../src/generate/extractExtensionDefinitions.ts" in source map of "../../node_modules/graphql-tools/dist/generate/extractExtensionDefinitions.js".
⚠️ Could not load source file "../../src/generate/SchemaError.ts" in source map of "../../node_modules/graphql-tools/dist/generate/SchemaError.js".
⚠️ Could not load source file "../../src/generate/addResolveFunctionsToSchema.ts" in source map of "../../node_modules/graphql-tools/dist/generate/addResolveFunctionsToSchema.js".
⚠️ Could not load source file "../../src/generate/forEachField.ts" in source map of "../../node_modules/graphql-tools/dist/generate/forEachField.js".
⚠️ Could not load source file "../../src/stitching/resolveFromParentTypename.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/resolveFromParentTypename.js".
⚠️ Could not load source file "../../src/generate/attachDirectiveResolvers.ts" in source map of "../../node_modules/graphql-tools/dist/generate/attachDirectiveResolvers.js".
⚠️ Could not load source file "../../src/generate/buildSchemaFromTypeDefinitions.ts" in source map of "../../node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js".
⚠️ Could not load source file "../../src/generate/chainResolvers.ts" in source map of "../../node_modules/graphql-tools/dist/generate/chainResolvers.js".
⚠️ Could not load source file "../../src/stitching/observableToAsyncIterable.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/observableToAsyncIterable.js".
⚠️ Could not load source file "../../src/generate/attachConnectorsToContext.ts" in source map of "../../node_modules/graphql-tools/dist/generate/attachConnectorsToContext.js".
⚠️ Could not load source file "../../src/generate/concatenateTypeDefs.ts" in source map of "../../node_modules/graphql-tools/dist/generate/concatenateTypeDefs.js".
⚠️ Could not load source file "../src/client.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/client.js".
⚠️ Could not load source file "../../src/stitching/typeFromAST.ts" in source map of "../../node_modules/graphql-tools/dist/stitching/typeFromAST.js".
⚠️ Could not load source file "../src/get-loading-markup.ts" in source map of "../../node_modules/@apollographql/graphql-playground-html/dist/get-loading-markup.js".
⚠️ Could not load source file "index.ts" in source map of "../../node_modules/deprecated-decorator/bld/index.js".
⚠️ Could not load source file "../src/message-types.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/message-types.js".
⚠️ Could not load source file "../src/protocol.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/protocol.js".
⚠️ Could not load source file "../src/defaults.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/defaults.js".
⚠️ Could not load source file "../../src/utils/is-string.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/utils/is-string.js".
⚠️ Could not load source file "../../src/utils/is-object.ts" in source map of "../../node_modules/subscriptions-transport-ws/dist/utils/is-object.js".
✨ Built in 27.08s.
no idea ... i'm stumpt
Well I can't run the server side in a dev server, though parcel handles the clientside in a dev server just fine. I have to manually build using parcel build src/server/index.ts -d dist/server --public-url /dist --target=node10
and then node dist/server
in order to run the server .. every time I want to test a code change.
It would also be great if I could set an introspection port when starting parcel to hook in to with the IDE in order to debug and use breakpoints.
The codebase is available here: https://github.com/Evanion/web-apollo
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.10.3 |
| Node | v10.11.0 |
| npm/Yarn | 6.4.1 |
| Operating System | macOS 10.14 Mojave |
I'm running into this as well with React Apollo, which uses TypeScript too (I'm not using any TS in my code). @Evanion have you made any changes that have sorted this out for you?
@visionpoint no :/
Not sure what you want this to be. Parcel tries to resolve sourcemaps for node_modules (and therefore needs the source files to exist)
The code is here: https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/assets/JSAsset.js#L94-L147
They're just warnings, so not sure what the issue is. Modules should include the source if they include sourcemaps otherwise the sourcemaps are useless and shouldn't be in there. To me this seems more like an issue on the module you're using than parcel.
OK, perhaps I should lift the issue with Apollo, and reference this issue.
@Evanion not sure if you found a fix for your specific issue, but for me excluding node_modules in my tsconfig.json did the job:
...
"exclude": [
"**/*.spec.ts",
"./node_modules"
],
...
Like Jasper said, Parcel is using the compiled JS file, but when loading the sourcemap attached to it, it tries to find the original typescript file so it can create the map but it seems to be missing. Probably it isn't included in the published node_modules package. So this is an issue with the module, not with Parcel.
Did you find out the cause of this? Running into the same issue on all Apollo packages if I go above parcel version 1.9.7.
Guys,
if you are only using Apollo without anything else which could lead to warnings you can just suppress them with: --log-level 1.
However keep in mind that you will suppress all warnings, which I do not recommend!
Most helpful comment
Like Jasper said, Parcel is using the compiled JS file, but when loading the sourcemap attached to it, it tries to find the original typescript file so it can create the map but it seems to be missing. Probably it isn't included in the published node_modules package. So this is an issue with the module, not with Parcel.