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

Remove location property in worklets for production builds #4695

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
forgor
  • Loading branch information
tjzel committed Jul 11, 2023
commit 75ed11b5ed77d04ae1b013b433e555c22d1d859a
8 changes: 4 additions & 4 deletions __tests__/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { strict as assert } from 'assert';
import '../plugin/jestUtils';
import { version as packageVersion } from '../package.json';

const mockLocation = '/dev/null';
const MOCK_LOCATION = '/dev/null';

function runPlugin(input: string, opts = {}) {
const transformed = transform(input.replace(/<\/?script[^>]*>/g, ''), {
// Our babel presets require us to specify a filename here
// but it is never used so we put in '/dev/null'
// as a safe fallback.
filename: mockLocation,
filename: MOCK_LOCATION,
compact: false,
plugins: [plugin],
...opts,
Expand Down Expand Up @@ -1137,7 +1137,7 @@ describe('babel plugin', () => {
</script>`;

const { code } = runPlugin(input);
expect(code).toHaveLocation(mockLocation);
expect(code).toHaveLocation(MOCK_LOCATION);
expect(code).toMatchSnapshot();
});

Expand All @@ -1153,7 +1153,7 @@ describe('babel plugin', () => {
const { code } = runPlugin(input, {});
process.env.BABEL_ENV = current;

expect(code).not.toHaveLocation(mockLocation);
expect(code).not.toHaveLocation(MOCK_LOCATION);
expect(code).toMatchSnapshot();
});
});
2 changes: 0 additions & 2 deletions plugin/jestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const WORKLET_REGEX = /var _worklet_[0-9]+_init_data/g;
const INLINE_STYLE_WARNING_REGEX =
/console\.warn\(require\("react-native-reanimated"\)\.getUseOfValueInStyleWarning\(\)\)/g;

expect.extend({});

expect.extend({
toHaveWorkletData(received: string, expectedMatchCount = 1) {
const receivedMatchCount = received.match(WORKLET_REGEX)?.length;
Expand Down