Skip to content

Commit 10a0240

Browse files
committed
fix: tests
1 parent af31e4e commit 10a0240

2 files changed

Lines changed: 36 additions & 34 deletions

File tree

packages/repack/src/loaders/assetsLoader/__tests__/__snapshots__/assetsLoader.test.ts.snap

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`assetLoader on android should load and extract asset with scales 1`] =
55
"__packager_asset": true,
66
"hash": "86abef08a42e972a96c958d6fa9d43da,02ad731a8881911e488b51c48a4cc6c1,d9f7c31eebb3a41cc180431867b04f38",
77
"height": 272,
8-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-2f60a7fc/__fixtures__",
8+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-0bfdf553/__fixtures__",
99
"name": "star",
1010
"scales": [
1111
1,
@@ -21,11 +21,11 @@ exports[`assetLoader on android should load and extract asset with scales 2`] =
2121
"/
2222
└─ out/
2323
├─ drawable-mdpi/
24-
│ └─ node_modules_rspackvirtualmodule2f60a7fc___fixtures___star.png
24+
│ └─ node_modules_rspackvirtualmodule0bfdf553___fixtures___star.png
2525
├─ drawable-xhdpi/
26-
│ └─ node_modules_rspackvirtualmodule2f60a7fc___fixtures___star.png
26+
│ └─ node_modules_rspackvirtualmodule0bfdf553___fixtures___star.png
2727
├─ drawable-xxhdpi/
28-
│ └─ node_modules_rspackvirtualmodule2f60a7fc___fixtures___star.png
28+
│ └─ node_modules_rspackvirtualmodule0bfdf553___fixtures___star.png
2929
└─ main.js"
3030
`;
3131

@@ -34,7 +34,7 @@ exports[`assetLoader on android should load and extract asset without scales 1`]
3434
"__packager_asset": true,
3535
"hash": "30be0ddcd5932e77845666e7b6f6a863",
3636
"height": 51,
37-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-dede2d21/__fixtures__",
37+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-cc4162dd/__fixtures__",
3838
"name": "logo",
3939
"scales": [
4040
1,
@@ -48,7 +48,7 @@ exports[`assetLoader on android should load and extract asset without scales 2`]
4848
"/
4949
└─ out/
5050
├─ drawable-mdpi/
51-
│ └─ node_modules_rspackvirtualmoduledede2d21___fixtures___logo.png
51+
│ └─ node_modules_rspackvirtualmodulecc4162dd___fixtures___logo.png
5252
└─ main.js"
5353
`;
5454

@@ -57,7 +57,7 @@ exports[`assetLoader on android should prefer platform specific asset 1`] = `
5757
"__packager_asset": true,
5858
"hash": "373411381c08b2c5034c814c24c26b19",
5959
"height": 51,
60-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-acc39058/__fixtures__",
60+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-5963b11e/__fixtures__",
6161
"name": "logo",
6262
"scales": [
6363
1,
@@ -71,7 +71,7 @@ exports[`assetLoader on android should prefer platform specific asset 2`] = `
7171
"/
7272
└─ out/
7373
├─ drawable-mdpi/
74-
│ └─ node_modules_rspackvirtualmoduleacc39058___fixtures___logo.png
74+
│ └─ node_modules_rspackvirtualmodule5963b11e___fixtures___logo.png
7575
└─ main.js"
7676
`;
7777

@@ -80,7 +80,7 @@ exports[`assetLoader on ios should load and extract asset with scales 1`] = `
8080
"__packager_asset": true,
8181
"hash": "86abef08a42e972a96c958d6fa9d43da,02ad731a8881911e488b51c48a4cc6c1,d9f7c31eebb3a41cc180431867b04f38",
8282
"height": 272,
83-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-2f60a7fc/__fixtures__",
83+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-0bfdf553/__fixtures__",
8484
"name": "star",
8585
"scales": [
8686
1,
@@ -97,7 +97,7 @@ exports[`assetLoader on ios should load and extract asset with scales 2`] = `
9797
└─ out/
9898
├─ assets/
9999
│ └─ node_modules/
100-
│ └─ rspack-virtual-module-2f60a7fc/
100+
│ └─ rspack-virtual-module-0bfdf553/
101101
│ └─ __fixtures__/
102102
│ ├─ star.png
103103
│ ├─ star@2x.png
@@ -110,7 +110,7 @@ exports[`assetLoader on ios should load and extract asset without scales 1`] = `
110110
"__packager_asset": true,
111111
"hash": "30be0ddcd5932e77845666e7b6f6a863",
112112
"height": 51,
113-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-dede2d21/__fixtures__",
113+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-cc4162dd/__fixtures__",
114114
"name": "logo",
115115
"scales": [
116116
1,
@@ -125,7 +125,7 @@ exports[`assetLoader on ios should load and extract asset without scales 2`] = `
125125
└─ out/
126126
├─ assets/
127127
│ └─ node_modules/
128-
│ └─ rspack-virtual-module-dede2d21/
128+
│ └─ rspack-virtual-module-cc4162dd/
129129
│ └─ __fixtures__/
130130
│ └─ logo.png
131131
└─ main.js"
@@ -136,7 +136,7 @@ exports[`assetLoader on ios should prefer platform specific asset 1`] = `
136136
"__packager_asset": true,
137137
"hash": "6839dbc2a8dafd50c1d82b7db5fe274a",
138138
"height": 51,
139-
"httpServerLocation": "assets/node_modules/rspack-virtual-module-1d9593d4/__fixtures__",
139+
"httpServerLocation": "assets/node_modules/rspack-virtual-module-e7a866d7/__fixtures__",
140140
"name": "logo",
141141
"scales": [
142142
1,
@@ -151,7 +151,7 @@ exports[`assetLoader on ios should prefer platform specific asset 2`] = `
151151
└─ out/
152152
├─ assets/
153153
│ └─ node_modules/
154-
│ └─ rspack-virtual-module-1d9593d4/
154+
│ └─ rspack-virtual-module-e7a866d7/
155155
│ └─ __fixtures__/
156156
│ └─ logo.png
157157
└─ main.js"
@@ -162,7 +162,7 @@ exports[`assetLoader should convert to remote-asset with URL containing a path a
162162
"__packager_asset": true,
163163
"height": 51,
164164
"scale": 1,
165-
"uri": "http://localhost:9999/remote-assets/assets/node_modules/rspack-virtual-module-dede2d21/__fixtures__/logo.png",
165+
"uri": "http://localhost:9999/remote-assets/assets/node_modules/rspack-virtual-module-cc4162dd/__fixtures__/logo.png",
166166
"width": 297,
167167
}
168168
`;
@@ -174,7 +174,7 @@ exports[`assetLoader should convert to remote-asset with URL containing a path a
174174
└─ remote-assets/
175175
└─ assets/
176176
└─ node_modules/
177-
└─ rspack-virtual-module-dede2d21/
177+
└─ rspack-virtual-module-cc4162dd/
178178
└─ __fixtures__/
179179
└─ logo.png"
180180
`;
@@ -184,7 +184,7 @@ exports[`assetLoader should convert to remote-asset with scales 1 1`] = `
184184
"__packager_asset": true,
185185
"height": 272,
186186
"scale": 1,
187-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-2f60a7fc/__fixtures__/star.png",
187+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-0bfdf553/__fixtures__/star.png",
188188
"width": 286,
189189
}
190190
`;
@@ -196,7 +196,7 @@ exports[`assetLoader should convert to remote-asset with scales 1 2`] = `
196196
└─ remote-assets/
197197
└─ assets/
198198
└─ node_modules/
199-
└─ rspack-virtual-module-2f60a7fc/
199+
└─ rspack-virtual-module-0bfdf553/
200200
└─ __fixtures__/
201201
├─ star.png
202202
├─ star@2x.png
@@ -208,7 +208,7 @@ exports[`assetLoader should convert to remote-asset with scales 2 1`] = `
208208
"__packager_asset": true,
209209
"height": 272,
210210
"scale": 2,
211-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-4e63ce4e/__fixtures__/star@x2.png",
211+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-4fe7a6d4/__fixtures__/star@x2.png",
212212
"width": 286,
213213
}
214214
`;
@@ -220,7 +220,7 @@ exports[`assetLoader should convert to remote-asset with scales 2 2`] = `
220220
└─ remote-assets/
221221
└─ assets/
222222
└─ node_modules/
223-
└─ rspack-virtual-module-4e63ce4e/
223+
└─ rspack-virtual-module-4fe7a6d4/
224224
└─ __fixtures__/
225225
├─ star.png
226226
├─ star@2x.png
@@ -232,7 +232,7 @@ exports[`assetLoader should convert to remote-asset with scales 3 1`] = `
232232
"__packager_asset": true,
233233
"height": 272,
234234
"scale": 3,
235-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-1f80d675/__fixtures__/star@x3.png",
235+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-7abb7f99/__fixtures__/star@x3.png",
236236
"width": 286,
237237
}
238238
`;
@@ -244,7 +244,7 @@ exports[`assetLoader should convert to remote-asset with scales 3 2`] = `
244244
└─ remote-assets/
245245
└─ assets/
246246
└─ node_modules/
247-
└─ rspack-virtual-module-1f80d675/
247+
└─ rspack-virtual-module-7abb7f99/
248248
└─ __fixtures__/
249249
├─ star.png
250250
├─ star@2x.png
@@ -256,7 +256,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
256256
"__packager_asset": true,
257257
"height": 272,
258258
"scale": 1,
259-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-2f60a7fc/__fixtures__/nested-folder/star-fake-hash.png",
259+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-0bfdf553/__fixtures__/nested-folder/star-fake-hash.png",
260260
"width": 286,
261261
}
262262
`;
@@ -268,7 +268,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
268268
└─ remote-assets/
269269
└─ assets/
270270
└─ node_modules/
271-
└─ rspack-virtual-module-2f60a7fc/
271+
└─ rspack-virtual-module-0bfdf553/
272272
└─ __fixtures__/
273273
└─ nested-folder/
274274
├─ star-fake-hash.png
@@ -281,7 +281,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
281281
"__packager_asset": true,
282282
"height": 272,
283283
"scale": 2,
284-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-4e63ce4e/__fixtures__/nested-folder/star-fake-hash@x2.png",
284+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-4fe7a6d4/__fixtures__/nested-folder/star-fake-hash@x2.png",
285285
"width": 286,
286286
}
287287
`;
@@ -293,7 +293,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
293293
└─ remote-assets/
294294
└─ assets/
295295
└─ node_modules/
296-
└─ rspack-virtual-module-4e63ce4e/
296+
└─ rspack-virtual-module-4fe7a6d4/
297297
└─ __fixtures__/
298298
└─ nested-folder/
299299
├─ star-fake-hash.png
@@ -306,7 +306,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
306306
"__packager_asset": true,
307307
"height": 272,
308308
"scale": 3,
309-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-1f80d675/__fixtures__/nested-folder/star-fake-hash@x3.png",
309+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-7abb7f99/__fixtures__/nested-folder/star-fake-hash@x3.png",
310310
"width": 286,
311311
}
312312
`;
@@ -318,7 +318,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
318318
└─ remote-assets/
319319
└─ assets/
320320
└─ node_modules/
321-
└─ rspack-virtual-module-1f80d675/
321+
└─ rspack-virtual-module-7abb7f99/
322322
└─ __fixtures__/
323323
└─ nested-folder/
324324
├─ star-fake-hash.png
@@ -331,7 +331,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
331331
"__packager_asset": true,
332332
"height": 51,
333333
"scale": 1,
334-
"uri": "http://localhost:9999/remote-assets/assets/node_modules/rspack-virtual-module-dede2d21/__fixtures__/nested-folder/logo-fake-hash.png",
334+
"uri": "http://localhost:9999/remote-assets/assets/node_modules/rspack-virtual-module-cc4162dd/__fixtures__/nested-folder/logo-fake-hash.png",
335335
"width": 297,
336336
}
337337
`;
@@ -343,7 +343,7 @@ exports[`assetLoader should convert to remote-asset with specified assetPath wit
343343
└─ remote-assets/
344344
└─ assets/
345345
└─ node_modules/
346-
└─ rspack-virtual-module-dede2d21/
346+
└─ rspack-virtual-module-cc4162dd/
347347
└─ __fixtures__/
348348
└─ nested-folder/
349349
└─ logo-fake-hash.png"
@@ -354,7 +354,7 @@ exports[`assetLoader should convert to remote-asset without scales 1`] = `
354354
"__packager_asset": true,
355355
"height": 51,
356356
"scale": 1,
357-
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-dede2d21/__fixtures__/logo.png",
357+
"uri": "http://localhost:9999/assets/node_modules/rspack-virtual-module-cc4162dd/__fixtures__/logo.png",
358358
"width": 297,
359359
}
360360
`;
@@ -366,7 +366,7 @@ exports[`assetLoader should convert to remote-asset without scales 2`] = `
366366
└─ remote-assets/
367367
└─ assets/
368368
└─ node_modules/
369-
└─ rspack-virtual-module-dede2d21/
369+
└─ rspack-virtual-module-cc4162dd/
370370
└─ __fixtures__/
371371
└─ logo.png"
372372
`;

packages/repack/src/loaders/assetsLoader/__tests__/assetsLoader.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ async function compileBundle(
6969
plugins: [
7070
new RspackVirtualModulePlugin({
7171
'package.json': '{ "type": "module" }',
72+
'node_modules/@react-native/assets-registry/package.json':
73+
'{ "name": "@react-native/assets-registry" }',
74+
'node_modules/@react-native/assets-registry/registry.js':
75+
'module.exports = { registerAsset: (spec) => spec };',
7276
'node_modules/react-native/package.json':
7377
'{ "name": "react-native", "main": "./index.js" }',
7478
'node_modules/react-native/index.js':
7579
'module.exports = { PixelRatio: { get: () => 1 } };',
76-
'node_modules/react-native/Libraries/Image/AssetRegistry.js':
77-
'module.exports = { registerAsset: (spec) => spec };',
7880
'node_modules/react-native/Libraries/Image/AssetSourceResolver.js': `
7981
module.exports = class AssetSourceResolver {
8082
constructor(a, b, c) {

0 commit comments

Comments
 (0)