@sentry/wizard 3.22.2 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/package.json +1 -1
- package/dist/src/nextjs/templates.js +2 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/react-native/javascript.js +1 -1
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.d.ts +6 -1
- package/dist/src/react-native/metro.js +166 -17
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -0
- package/dist/src/react-native/react-native-wizard.js +19 -20
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +1 -1
- package/dist/src/utils/ast-utils.js +2 -2
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.js +1 -1
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +115 -0
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/package.json +1 -1
- package/src/nextjs/templates.ts +2 -5
- package/src/react-native/javascript.ts +3 -0
- package/src/react-native/metro.ts +208 -18
- package/src/react-native/react-native-wizard.ts +24 -7
- package/src/utils/ast-utils.ts +2 -2
- package/src/utils/clack-utils.ts +1 -1
- package/test/react-native/javascript.test.ts +3 -0
- package/test/react-native/metro.test.ts +113 -0
|
@@ -9,11 +9,124 @@ import {
|
|
|
9
9
|
addSentrySerializerRequireToMetroConfig,
|
|
10
10
|
addSentrySerializerToMetroConfig,
|
|
11
11
|
getMetroConfigObject,
|
|
12
|
+
patchMetroWithSentryConfigInMemory,
|
|
12
13
|
removeSentryRequire,
|
|
13
14
|
removeSentrySerializerFromMetroConfig,
|
|
14
15
|
} from '../../src/react-native/metro';
|
|
15
16
|
|
|
16
17
|
describe('patch metro config - sentry serializer', () => {
|
|
18
|
+
describe('patchMetroWithSentryConfigInMemory', () => {
|
|
19
|
+
it('patches react native 0.72 default metro config', async () => {
|
|
20
|
+
const mod =
|
|
21
|
+
parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Metro configuration
|
|
25
|
+
* https://reactnative.dev/docs/metro
|
|
26
|
+
*
|
|
27
|
+
* @type {import('metro-config').MetroConfig}
|
|
28
|
+
*/
|
|
29
|
+
const config = {};
|
|
30
|
+
|
|
31
|
+
module.exports = mergeConfig(getDefaultConfig(__dirname), config);`);
|
|
32
|
+
|
|
33
|
+
const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
|
|
34
|
+
/* noop */
|
|
35
|
+
});
|
|
36
|
+
expect(result).toBe(true);
|
|
37
|
+
expect(generateCode(mod.$ast).code)
|
|
38
|
+
.toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
withSentryConfig
|
|
42
|
+
} = require("@sentry/react-native/metro");
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Metro configuration
|
|
46
|
+
* https://reactnative.dev/docs/metro
|
|
47
|
+
*
|
|
48
|
+
* @type {import('metro-config').MetroConfig}
|
|
49
|
+
*/
|
|
50
|
+
const config = {};
|
|
51
|
+
|
|
52
|
+
module.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('patches react native 0.65 default metro config', async () => {
|
|
56
|
+
const mod = parseModule(`/**
|
|
57
|
+
* Metro configuration for React Native
|
|
58
|
+
* https://github.com/facebook/react-native
|
|
59
|
+
*
|
|
60
|
+
* @format
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
transformer: {
|
|
65
|
+
getTransformOptions: async () => ({
|
|
66
|
+
transform: {
|
|
67
|
+
experimentalImportSupport: false,
|
|
68
|
+
inlineRequires: true,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
};`);
|
|
73
|
+
|
|
74
|
+
const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
|
|
75
|
+
/* noop */
|
|
76
|
+
});
|
|
77
|
+
expect(result).toBe(true);
|
|
78
|
+
expect(generateCode(mod.$ast).code).toBe(`const {
|
|
79
|
+
withSentryConfig
|
|
80
|
+
} = require("@sentry/react-native/metro");
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Metro configuration for React Native
|
|
84
|
+
* https://github.com/facebook/react-native
|
|
85
|
+
*
|
|
86
|
+
* @format
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
module.exports = withSentryConfig({
|
|
90
|
+
transformer: {
|
|
91
|
+
getTransformOptions: async () => ({
|
|
92
|
+
transform: {
|
|
93
|
+
experimentalImportSupport: false,
|
|
94
|
+
inlineRequires: true,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
});`);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('patches react native metro config exported variable', async () => {
|
|
102
|
+
const mod = parseModule(`const testConfig = {};
|
|
103
|
+
|
|
104
|
+
module.exports = testConfig;`);
|
|
105
|
+
|
|
106
|
+
const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
|
|
107
|
+
/* noop */
|
|
108
|
+
});
|
|
109
|
+
expect(result).toBe(true);
|
|
110
|
+
expect(generateCode(mod.$ast).code).toBe(`const {
|
|
111
|
+
withSentryConfig
|
|
112
|
+
} = require("@sentry/react-native/metro");
|
|
113
|
+
|
|
114
|
+
const testConfig = {};
|
|
115
|
+
|
|
116
|
+
module.exports = withSentryConfig(testConfig);`);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('does not patch react native metro config exported as factory function', async () => {
|
|
120
|
+
const mod = parseModule(`module.exports = () => ({});`);
|
|
121
|
+
|
|
122
|
+
const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
|
|
123
|
+
/* noop */
|
|
124
|
+
});
|
|
125
|
+
expect(result).toBe(false);
|
|
126
|
+
expect(generateCode(mod.$ast).code).toBe(`module.exports = () => ({});`);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
17
130
|
describe('addSentrySerializerToMetroConfig', () => {
|
|
18
131
|
it('add to empty config', () => {
|
|
19
132
|
const mod = parseModule(`module.exports = {
|