apollo-client
apollo-client copied to clipboard
Apollo Client 3.4.0 and higher breaks use of pkg
Intended outcome: Use the pkg to build native executables. My project depended on @apollo/[email protected] for many months, with no issues.
Actual outcome: I upgraded to 3.5.10 and now the pkg output executable throws an related to apollo/client's use of ts-invariant/process.
./dist/apollo-client-error-tsinvariant-process-pkg-macos
pkg/prelude/bootstrap.js:1740
throw error;
^
Error: Cannot find module 'ts-invariant/process'
Require stack:
- /snapshot/react-apollo-error-template/node_modules/@apollo/client/utilities/utilities.cjs.js
- /snapshot/react-apollo-error-template/node_modules/@apollo/client/core/core.cjs.js
- /snapshot/react-apollo-error-template/node_modules/@apollo/client/main.cjs.js
- /snapshot/react-apollo-error-template/src/index.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1819:46)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Module.require (pkg/prelude/bootstrap.js:1719:31)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/snapshot/react-apollo-error-template/node_modules/@apollo/client/utilities/utilities.cjs.js)
at Module._compile (pkg/prelude/bootstrap.js:1794:22)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/snapshot/react-apollo-error-template/node_modules/@apollo/client/utilities/utilities.cjs.js',
'/snapshot/react-apollo-error-template/node_modules/@apollo/client/core/core.cjs.js',
'/snapshot/react-apollo-error-template/node_modules/@apollo/client/main.cjs.js',
'/snapshot/react-apollo-error-template/src/index.js'
],
pkg: true
}
How to reproduce the issue:
https://github.com/traviscollins/react-apollo-error-template
Versions
Affects 3.4.0 and higher.
Same problem with apollo client > 3.4.x but with 3.3.21 it works
pkg/prelude/bootstrap.js:1833
throw error;
^
Error: Cannot find module 'ts-invariant/process'
Require stack:
- /snapshot/project/tool/node_modules/@apollo/client/utilities/globals/globals.cjs.js
- /snapshot/project/tool/node_modules/@apollo/client/core/core.cjs.js
- /snapshot/project/tool/node_modules/apollo-upload-client/public/createUploadLink.js
- /snapshot/project/tool/node_modules/apollo-upload-client/public/index.js
- /snapshot/project/tool/build/apollo.js
- /snapshot/project/tool/build/export-order.js
- /snapshot/project/tool/build/boot.js
- /snapshot/project/tool/build/index.js
Hello! Please try upgrading to the most current version 3.6.8
, You can review our changelog for details on what was released recently. If you still have any issue just let us know. Thank you!
I still have issues with server-side rendering. I'm using the latest version 3.7.1
/Users/fullstack-pro/servers/frontend-server/dist/main.js:1
Error: Cannot find module './core/index.js'
Require stack:
- /Users/fullstack-pro/servers/frontend-server/dist/main.js
- /Users/fullstack-pro/servers/frontend-server/dist/index.js
at Object.6082 (/Users/fullstack-pro/servers/frontend-server/dist/webpack:/sample-stack-frontend-server/src/index.ts:1)
at __webpack_require__ (/Users/fullstack-pro/servers/frontend-server/dist/webpack:/sample-stack-frontend-server/webpack/bootstrap:19:1)
at Object.1005 (/Users/fullstack-pro/servers/frontend-server/dist/webpack:/sample-stack-frontend-server/src/backend/website.tsx:3:1)
at __webpack_require__ (/Users/fullstack-pro/servers/frontend-server/dist/webpack:/sample-stack-frontend-server/webpack/bootstrap:19:1)
error Command failed with exit code 1.
The issue is in my end. Not issue for me now.
Any update on this? I confirm that all is fine on 3.3.21. 3.6.8 is broken.
I confirm that using [email protected] all is fine using @apollo/[email protected] and breaks using @apollo/[email protected].
Cheking the file difference between 3.3.21 and 3.4.0 I don't see any mentioning of the ts-invariant/process except in one place. src/utilities/globals/graphql.ts
I also see that there is a normalization process happening for ts-invariant/process, not sure if it would affect pkg: https://github.com/apollographql/apollo-client/blob/792ac32f5b5d23b3346fa07a4d8ac35f0e7e8d70/config/postprocessDist.ts#L100-L122