Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Dec 10, 2023
1 parent 59fa2dc commit b80decc
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
9 changes: 5 additions & 4 deletions packages/@expo/cli/e2e/__tests__/export-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ describe('server', () => {
async () => {
const projectRoot = await setupTestProjectAsync('basic-export', 'with-assets');
// `npx expo export`
await execa('node', [bin, 'export', '--dump-sourcemap', '--dump-assetmap'], {
await execa('node', [bin, 'export', '--source-maps', '--dump-assetmap'], {
cwd: projectRoot,
env: {
NODE_ENV: 'production',
TEST_BABEL_PRESET_EXPO_MODULE_ID: require.resolve('babel-preset-expo'),
EXPO_USE_FAST_RESOLVER: 'false',
},
});
Expand Down Expand Up @@ -197,9 +198,9 @@ describe('server', () => {
'assets/2f334f6c7ca5b2a504bdf8acdee104f3',
'assets/3858f62230ac3c915f300c664312c63f',
'assets/9ce7db807e4147e00df372d053c154c2',
'assets/assets/font.ttf',
'assets/assets/icon.png',
'assets/assets/icon@2x.png',
'assets/assets/font.3858f62230ac3c915f300c664312c63f.ttf',
'assets/assets/icon.8034d8318b239108719ff3f22f31ef15.png',
'assets/assets/icon.8034d8318b239108719ff3f22f31ef15@2x.png',

'assets/fb960eb5e4eb49ec8786c7f6c4a57ce2',
'debug.html',
Expand Down
8 changes: 7 additions & 1 deletion packages/@expo/cli/e2e/fixtures/with-assets/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module.exports = function (api) {
api.cache(true);
return {
presets: [['babel-preset-expo', { web: { disableImportExportTransform: false } }]],
presets: [
[
// `babel-preset-expo` from the monorepo.
process.env.TEST_BABEL_PRESET_EXPO_MODULE_ID,
{ web: { disableImportExportTransform: false } },
],
],
};
};
10 changes: 1 addition & 9 deletions packages/@expo/cli/src/export/persistMetroAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,9 @@ export async function persistMetroAssetsAsync(
for (const asset of assetsToCopy) {
const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));
for (let idx = 0; idx < asset.scales.length; idx++) {
const filePath = asset.files[idx];
const scale = asset.scales[idx];
if (validScales.has(scale)) {
await write(
filePath,
getAssetLocalPath(asset, {
platform,
scale,
baseUrl,
})
);
await write(asset.files[idx], getAssetLocalPath(asset, { platform, scale, baseUrl }));
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ export async function graphToSerialAssetsAsync(
// TODO: Can this be anything besides true?
const isExporting = true;
const baseUrl = getBaseUrlOption(graph, { serializerOptions: serializeChunkOptions });
const assetPublicUrl = (baseUrl.replace(/\/+$/, '') ?? '') + '/assets';
const publicPath = isExporting
? `/assets?export_path=${(baseUrl.replace(/\/+$/, '') ?? '') + '/assets'}`
? graph.transformOptions.platform === 'web'
? `/assets?export_path=${assetPublicUrl}`
: assetPublicUrl
: '/assets/?unstable_path=.';

// TODO: Convert to serial assets
Expand Down
2 changes: 0 additions & 2 deletions packages/@expo/metro-config/src/transform-worker/getAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export async function getUniversalAssetData(

// NOTE(EvanBacon): This is where we modify the asset to include a hash in the name for web cache invalidation.
if (platform === 'web' && publicPath.includes('?export_path=')) {
// Store original name for reading the asset on-disk later.
data._name = data.name;
// `local-image.[contenthash]`. Using `.` but this won't work if we ever apply to Android because Android res files cannot contain `.`.
// TODO: Prevent one multi-res image from updating the hash in all images.
// @ts-expect-error: name is typed as readonly.
Expand Down

0 comments on commit b80decc

Please sign in to comment.