-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Remove conditional require()s from SSR #9975
Remove conditional require()s from SSR #9975
Conversation
src/__tests__/exports.ts
Outdated
/** @jest-environment node */ | ||
// We run this in a node environment because: | ||
// A) JSDOM doesn't yet support the TextEncoder/TextDecoder elements, meaning certain imports will fail (See https://github.com/jsdom/jsdom/issues/2524) | ||
// B) We're just testing imports/exports, so we don't need to slow down the test with a browser environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side note, if we did still want to run this with JSDOM, we can manually add TextEncoder to the jest environment in the config/jest/setup.ts
file like so:
if (typeof global.TextEncoder === 'undefined') {
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
}
Given the scope of this it seemed unnecessary to me, but let me know if you think otherwise.
Just dropping this here: apollographql/react-apollo#2627 - it shows that one of the original motivations for the conditional |
Looking at apollographql/react-apollo#2627 (thanks @hwillson), I see the @MrDoomBringer I wonder if that |
@benjamn Thanks for the callout! I was actually just looking at the commit that we lost it in here - apollographql/react-apollo@29a4536. Will take a look. |
36574b8
to
1f8d742
Compare
09ed134
to
475f2f8
Compare
Gets rid of some conditional require()s from getDataFromTree and renderToStringWithData, which won't get bundled properly by webpack.
Checklist:
See #9952 for more information