From dd6e1a8f7915f545998804dcb3f15c6059acf6ae Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:28:53 +0100 Subject: [PATCH] fix(metro-config): Exclude `beforeAssetSerializationPlugins.preModules` from `stableChunkSource` (#33344) # Why Sentry user reported issue with using bundle splitting and `beforeAssetSerializationPlugins` (used by Sentry Expo Metro Plugin). The issue is the `stableChunkSource` becomes unstable due to updated `premodules` by the `beforeAssetSerializationPlugins` https://github.com/getsentry/sentry-react-native/issues/4317 # How This PR ensures the updated `premodules` are not affecting the chunk global `premodules` but only the serialized output. # Test Plan I've added multiple scenarios to the tests to ensure this regression is avoided in the future. I also tried running the fix with https://github.com/getsentry/sentry-react-native/tree/main/samples/expo and the Web Release build is working with the fix. (Debug is not affected, as premodules are changed only for release.) # Checklist - [x] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [x] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). --- packages/@expo/metro-config/CHANGELOG.md | 2 + .../build/serializer/serializeChunks.js | 28 +++-- .../build/serializer/serializeChunks.js.map | 2 +- .../__tests__/withExpoSerializers.test.ts | 119 +++++++++++++++++- .../fork/__tests__/serializer-test-utils.ts | 40 +++++- .../src/serializer/serializeChunks.ts | 33 +++-- 6 files changed, 193 insertions(+), 31 deletions(-) diff --git a/packages/@expo/metro-config/CHANGELOG.md b/packages/@expo/metro-config/CHANGELOG.md index 4ea506df48921..b13968b7c3737 100644 --- a/packages/@expo/metro-config/CHANGELOG.md +++ b/packages/@expo/metro-config/CHANGELOG.md @@ -10,6 +10,8 @@ ### 🐛 Bug fixes +- Exclude `beforeAssetSerializationPlugins.preModules` from `stableChunkSource` ([#33344](https://github.com/expo/expo/pull/33344) by [@krystofwoldrich](https://github.com/krystofwoldrich)) + ### 💡 Others ## 0.19.5 - 2024-11-29 diff --git a/packages/@expo/metro-config/build/serializer/serializeChunks.js b/packages/@expo/metro-config/build/serializer/serializeChunks.js index 141ae85a2abe9..ff9a323788b8a 100644 --- a/packages/@expo/metro-config/build/serializer/serializeChunks.js +++ b/packages/@expo/metro-config/build/serializer/serializeChunks.js @@ -181,13 +181,13 @@ class Chunk { serializeToCodeWithTemplates(serializerConfig, options = {}) { const entryFile = this.name; // TODO: Disable all debugId steps when a dev server is enabled. This is an export-only feature. - const preModules = [...this.preModules.values()]; + const preModules = [...(options.preModules ?? this.preModules).values()]; const dependencies = [...this.deps]; const jsSplitBundle = (0, baseJSBundle_1.baseJSBundleWithDependencies)(entryFile, preModules, dependencies, { ...this.options, runBeforeMainModule: serializerConfig?.getModulesRunBeforeMainModule?.(path_1.default.relative(this.options.projectRoot, entryFile)) ?? [], runModule: this.options.runModule && !this.isVendor && !this.isAsync, - modulesOnly: this.options.modulesOnly || this.preModules.size === 0, + modulesOnly: this.options.modulesOnly || preModules.length === 0, platform: this.getPlatform(), baseUrl: (0, baseJSBundle_1.getBaseUrlOption)(this.graph, this.options), splitChunks: !!this.options.serializerOptions?.splitChunks, @@ -266,12 +266,13 @@ class Chunk { return null; } } - serializeToCode(serializerConfig, { debugId, chunks }) { + serializeToCode(serializerConfig, { debugId, chunks, preModules }) { return this.serializeToCodeWithTemplates(serializerConfig, { skipWrapping: false, sourceMapUrl: this.getAdjustedSourceMapUrl(serializerConfig) ?? undefined, computedAsyncModulePaths: this.getComputedPathsForAsyncDependencies(serializerConfig, chunks), debugId, + preModules, }); } boolishTransformOption(name) { @@ -280,19 +281,24 @@ class Chunk { } async serializeToAssetsAsync(serializerConfig, chunks, { includeSourceMaps, unstable_beforeAssetSerializationPlugins }) { // Create hash without wrapping to prevent it changing when the wrapping changes. - let outputFile = this.getFilenameForConfig(serializerConfig); + const outputFile = this.getFilenameForConfig(serializerConfig); // We already use a stable hash for the output filename, so we'll reuse that for the debugId. const debugId = (0, debugId_1.stringToUUID)(path_1.default.basename(outputFile, path_1.default.extname(outputFile))); - let premodules = [...this.preModules]; + let finalPreModules = [...this.preModules]; if (unstable_beforeAssetSerializationPlugins) { for (const plugin of unstable_beforeAssetSerializationPlugins) { - premodules = plugin({ graph: this.graph, premodules, debugId }); + finalPreModules = plugin({ + graph: this.graph, + premodules: finalPreModules, + debugId, + }); } - this.preModules = new Set(premodules); - // If the premodules have changed, we need to recompute the output file hash. - outputFile = this.getFilenameForConfig(serializerConfig); } - const jsCode = this.serializeToCode(serializerConfig, { chunks, debugId }); + const jsCode = this.serializeToCode(serializerConfig, { + chunks, + debugId, + preModules: new Set(finalPreModules), + }); const relativeEntry = path_1.default.relative(this.options.projectRoot, this.name); const jsAsset = { filename: outputFile, @@ -367,7 +373,7 @@ class Chunk { !this.options.inlineSourceMap && this.options.sourceMapUrl) { const modules = [ - ...this.preModules, + ...finalPreModules, ...getSortedModules([...this.deps], { createModuleId: this.options.createModuleId, }), diff --git a/packages/@expo/metro-config/build/serializer/serializeChunks.js.map b/packages/@expo/metro-config/build/serializer/serializeChunks.js.map index 6eab3ad160938..aaca9044edffc 100644 --- a/packages/@expo/metro-config/build/serializer/serializeChunks.js.map +++ b/packages/@expo/metro-config/build/serializer/serializeChunks.js.map @@ -1 +1 @@ -{"version":3,"file":"serializeChunks.js","sourceRoot":"","sources":["../../src/serializer/serializeChunks.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,oDAA4B;AAS5B,yGAAoF;AACpF,kFAA0D;AAE1D,gDAAwB;AAExB,uCAAyC;AACzC,iDAAwD;AACxD,6CAAqE;AACrE,sDAK6B;AAC7B,6CAAkD;AAGlD,8EAA2D;AAgB3D,wCAAwC;AACxC,SAAS,WAAW,CAAC,IAAY;IAC/B,kDAAkD;IAClD,IAAI,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;IAEpE,sDAAsD;IACtD,aAAa,GAAG,aAAa,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W,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,MAAM,OAAO,CAAC,GAAG,CACf,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9B,QAAQ,CAAC,IAAI,CACX,GAAG,CAAC,MAAM,KAAK,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAChF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAA8B,EAC9B,EACE,cAAc,GAGf;IAED,8CAA8C;IAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KAC7B;IACD,cAAc;IACd,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,CAAc,EAAE,CAAc,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CACpF,CAAC;AACJ,CAAC;AAhBD,4CAgBC"} \ No newline at end of file +{"version":3,"file":"serializeChunks.js","sourceRoot":"","sources":["../../src/serializer/serializeChunks.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,oDAA4B;AAS5B,yGAAoF;AACpF,kFAA0D;AAE1D,gDAAwB;AAExB,uCAAyC;AACzC,iDAAwD;AACxD,6CAAqE;AACrE,sDAK6B;AAC7B,6CAAkD;AAGlD,8EAA2D;AAgB3D,wCAAwC;AACxC,SAAS,WAAW,CAAC,IAAY;IAC/B,kDAAkD;IAClD,IAAI,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;IAEpE,sDAAsD;IACtD,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEnD,kDAAkD;IAClD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E,KAAK,EAAE,EAAE;QAC9B,QAAQ,CAAC,IAAI,CACX,GAAG,CAAC,MAAM,KAAK,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAChF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAA8B,EAC9B,EACE,cAAc,GAGf;IAED,8CAA8C;IAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KAC7B;IACD,cAAc;IACd,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,CAAc,EAAE,CAAc,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CACpF,CAAC;AACJ,CAAC;AAhBD,4CAgBC"} \ No newline at end of file diff --git a/packages/@expo/metro-config/src/serializer/__tests__/withExpoSerializers.test.ts b/packages/@expo/metro-config/src/serializer/__tests__/withExpoSerializers.test.ts index db4a2d8a97adc..d544212c188b7 100644 --- a/packages/@expo/metro-config/src/serializer/__tests__/withExpoSerializers.test.ts +++ b/packages/@expo/metro-config/src/serializer/__tests__/withExpoSerializers.test.ts @@ -1,5 +1,11 @@ +import { Module } from 'metro'; + import { microBundle, projectRoot } from '../fork/__tests__/mini-metro'; -import { serializeSplitAsync, serializeTo } from '../fork/__tests__/serializer-test-utils'; +import { + createJSVirtualModule, + serializeSplitAsync, + serializeTo, +} from '../fork/__tests__/serializer-test-utils'; import { SerialAsset, createSerializerFromSerialProcessors, @@ -44,6 +50,117 @@ jest.mock('../exportHermes', () => { describe('serializes', () => { describe('plugin callbacks', () => { + it(`runs plugin for each chunk`, async () => { + const unstablePlugin = ({ premodules }: { premodules: Module[] }): Module[] => { + return [createJSVirtualModule('__testPreModule', 'testPreModule;'), ...premodules]; + }; + + const artifacts = await serializeSplitAsync( + { + 'index.js': ` + import('./foo') + `, + 'foo.js': ` + export const foo = 'foo'; + `, + }, + { + sourceMaps: true, + }, + [], // processors + { unstable_beforeAssetSerializationPlugins: [unstablePlugin] } + ); + + if (typeof artifacts === 'string') { + throw new Error('wrong type'); + } + + const jsArtifacts = artifacts.filter((artifact) => artifact.type === 'js'); + const mapArtifacts = artifacts.filter((artifact) => artifact.type === 'map'); + + jsArtifacts.forEach((artifact) => { + expect(artifact.source.startsWith('testPreModule;')).toBeTruthy(); + }); + mapArtifacts.forEach((artifact) => { + // Assert each map artifact has __testPreModule in sources + const map = JSON.parse(artifact.source); + expect(map.sources[0]).toEqual('__testPreModule'); + }); + }); + it(`generated async import paths match generated artifacts`, async () => { + const unstablePlugin = ({ premodules }: { premodules: Module[] }): Module[] => { + return [createJSVirtualModule('__testPreModule', 'testPreModule;'), ...premodules]; + }; + + const artifacts = await serializeSplitAsync( + { + 'index.js': ` + import('./foo') + `, + 'foo.js': ` + export const foo = 'foo'; + `, + }, + { + sourceMaps: true, + }, + [], // processors + { unstable_beforeAssetSerializationPlugins: [unstablePlugin] } + ); + + if (typeof artifacts === 'string') { + throw new Error('wrong type'); + } + + const indexJs = artifacts.find((artifact) => artifact.originFilename === 'index.js'); + const fooJs = artifacts.find((artifact) => artifact.originFilename === 'foo.js'); + + const fooJsFilenameImportedFromIndexJs = + // substring(1) to remove the leading '/' + indexJs?.metadata.paths['/app/index.js']['/app/foo.js']?.substring(1); + + expect(fooJsFilenameImportedFromIndexJs).toBeDefined(); + expect(fooJsFilenameImportedFromIndexJs).toEqual(fooJs?.filename); + }); + it('plugin preModules changes are excluded from the file name hash', async () => { + const unstablePlugin = ({ premodules }: { premodules: Module[] }): Module[] => { + return [createJSVirtualModule('__testPreModule', 'testPreModule;'), ...premodules]; + }; + + const options: Partial[0]> = { + options: { + dev: false, + platform: 'ios', + hermes: false, + // Source maps must be enabled otherwise the feature is disabled. + sourceMaps: true, + output: 'static', + }, + }; + + const withoutPlugin = await serializeTo( + options, + [], // processors + { unstable_beforeAssetSerializationPlugins: [] } + ); + + const withPlugin = await serializeTo( + options, + [], // processors + { unstable_beforeAssetSerializationPlugins: [unstablePlugin] } + ); + + if (typeof withoutPlugin === 'string' || typeof withPlugin === 'string') { + throw new Error('wrong type'); + } + + // Get the filenames from both artifacts + const withoutFilename = (withoutPlugin as SerialAsset[]).map((asset) => asset.filename); + const withFilename = (withPlugin as SerialAsset[]).map((asset) => asset.filename); + + // The filenames should be equal since premodules shouldn't affect the hash + expect(withoutFilename).toEqual(withFilename); + }); it(`runs plugin with static output`, async () => { let didPluginRun = false; const unstablePlugin = ({ premodules }) => { diff --git a/packages/@expo/metro-config/src/serializer/fork/__tests__/serializer-test-utils.ts b/packages/@expo/metro-config/src/serializer/fork/__tests__/serializer-test-utils.ts index acbef2299d344..93e0c057b06f1 100644 --- a/packages/@expo/metro-config/src/serializer/fork/__tests__/serializer-test-utils.ts +++ b/packages/@expo/metro-config/src/serializer/fork/__tests__/serializer-test-utils.ts @@ -1,4 +1,7 @@ import assert from 'assert'; +import { Module, MixedOutput } from 'metro'; +import CountingSet from 'metro/src/lib/CountingSet'; +import countLines from 'metro/src/lib/countLines'; import { microBundle, projectRoot } from './mini-metro'; import { reconcileTransformSerializerPlugin } from '../../reconcileTransformSerializerPlugin'; @@ -58,12 +61,18 @@ export async function serializeTo( // Serialize to a split bundle export async function serializeSplitAsync( fs: Record, - options: { isReactServer?: boolean; treeshake?: boolean } = {} + options: Partial[0]['options']> = {}, + processors: SerializerPlugin[] = [], + configOptions: SerializerConfigOptions = {} ) { - return await serializeTo({ - fs, - options: { platform: 'web', dev: false, output: 'static', splitChunks: true, ...options }, - }); + return await serializeTo( + { + fs, + options: { platform: 'web', dev: false, output: 'static', splitChunks: true, ...options }, + }, + processors, + configOptions + ); } // Serialize to a split bundle @@ -114,3 +123,24 @@ export function expectImports(graph, name: string) { if (!graph.dependencies.has(name)) throw new Error(`Module not found: ${name}`); return expect([...graph.dependencies.get(name).dependencies.values()]); } + +export function createJSVirtualModule(path: string, code: string): Module { + return { + path, + output: [ + { + type: 'js/script/virtual', + data: { + code, + // @ts-ignore: Metro types are incomplete + lineCount: countLines(code), + // @ts-ignore: Metro types are incomplete + map: [], + }, + }, + ], + dependencies: new Map(), + inverseDependencies: new CountingSet(), + getSource: () => Buffer.from(code), + }; +} diff --git a/packages/@expo/metro-config/src/serializer/serializeChunks.ts b/packages/@expo/metro-config/src/serializer/serializeChunks.ts index d81e9b3990b42..67c045cc2c84b 100644 --- a/packages/@expo/metro-config/src/serializer/serializeChunks.ts +++ b/packages/@expo/metro-config/src/serializer/serializeChunks.ts @@ -244,13 +244,15 @@ export class Chunk { private serializeToCodeWithTemplates( serializerConfig: Partial, - options: Partial[3]> = {} + options: Partial[3]> & { + preModules?: Set; + } = {} ) { const entryFile = this.name; // TODO: Disable all debugId steps when a dev server is enabled. This is an export-only feature. - const preModules = [...this.preModules.values()]; + const preModules = [...(options.preModules ?? this.preModules).values()]; const dependencies = [...this.deps]; const jsSplitBundle = baseJSBundleWithDependencies(entryFile, preModules, dependencies, { @@ -260,7 +262,7 @@ export class Chunk { path.relative(this.options.projectRoot, entryFile) ) ?? [], runModule: this.options.runModule && !this.isVendor && !this.isAsync, - modulesOnly: this.options.modulesOnly || this.preModules.size === 0, + modulesOnly: this.options.modulesOnly || preModules.length === 0, platform: this.getPlatform(), baseUrl: getBaseUrlOption(this.graph, this.options), splitChunks: !!this.options.serializerOptions?.splitChunks, @@ -367,13 +369,14 @@ export class Chunk { private serializeToCode( serializerConfig: Partial, - { debugId, chunks }: { debugId: string; chunks: Chunk[] } + { debugId, chunks, preModules }: { debugId: string; chunks: Chunk[]; preModules: Set } ) { return this.serializeToCodeWithTemplates(serializerConfig, { skipWrapping: false, sourceMapUrl: this.getAdjustedSourceMapUrl(serializerConfig) ?? undefined, computedAsyncModulePaths: this.getComputedPathsForAsyncDependencies(serializerConfig, chunks), debugId, + preModules, }); } @@ -388,22 +391,26 @@ export class Chunk { { includeSourceMaps, unstable_beforeAssetSerializationPlugins }: SerializeChunkOptions ): Promise { // Create hash without wrapping to prevent it changing when the wrapping changes. - let outputFile = this.getFilenameForConfig(serializerConfig); + const outputFile = this.getFilenameForConfig(serializerConfig); // We already use a stable hash for the output filename, so we'll reuse that for the debugId. const debugId = stringToUUID(path.basename(outputFile, path.extname(outputFile))); - let premodules = [...this.preModules]; + let finalPreModules = [...this.preModules]; if (unstable_beforeAssetSerializationPlugins) { for (const plugin of unstable_beforeAssetSerializationPlugins) { - premodules = plugin({ graph: this.graph, premodules, debugId }); + finalPreModules = plugin({ + graph: this.graph, + premodules: finalPreModules, + debugId, + }); } - this.preModules = new Set(premodules); - - // If the premodules have changed, we need to recompute the output file hash. - outputFile = this.getFilenameForConfig(serializerConfig); } - const jsCode = this.serializeToCode(serializerConfig, { chunks, debugId }); + const jsCode = this.serializeToCode(serializerConfig, { + chunks, + debugId, + preModules: new Set(finalPreModules), + }); const relativeEntry = path.relative(this.options.projectRoot, this.name); @@ -498,7 +505,7 @@ export class Chunk { this.options.sourceMapUrl ) { const modules = [ - ...this.preModules, + ...finalPreModules, ...getSortedModules([...this.deps], { createModuleId: this.options.createModuleId, }),