mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 02:21:05 +08:00
Since we have the major version jump, we needed to update quite
a few things to make this work:
1. rollup4 ships with native binaries. We can't check them into
our node_modules for all platforms. Luckily they also ship a
a wasm version. This requires us to adjust the 'binary' path
to `node_modules/@rollup/wasm-node/dist/bin/rollup` instead.
2. rollup4 is more strict when it comes to ES modules vs
CommonJS. We adjust this by renaming the rollup config files.
3. Some plugins got deprecated so we had to replace them with
the newer versions (source maps and terser).
Bug: None
Change-Id: If13d590c8185db6ad85b3992d0a869111909dc8c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5999255
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
1 line
5.2 KiB
Plaintext
1 line
5.2 KiB
Plaintext
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { promisify } from 'node:util';\nimport pluginUtils, { type CreateFilter } from '@rollup/pluginutils';\nimport type { ExistingRawSourceMap, Plugin, PluginContext } from 'rollup';\nimport { resolveSourceMap, resolveSources } from './source-map-resolve.js';\n\nconst { createFilter } = pluginUtils;\n\nexport interface SourcemapsPluginOptions {\n include?: Parameters<CreateFilter>[0];\n exclude?: Parameters<CreateFilter>[1];\n readFile?(path: string, callback: (error: Error | null, data: Buffer | string) => void): void;\n}\n\nexport default function sourcemaps(\n // eslint-disable-next-line @typescript-eslint/unbound-method\n { include, exclude, readFile = fs.readFile }: SourcemapsPluginOptions = {},\n): Plugin {\n // Create a filter function based on the include and exclude options\n const filter = createFilter(include, exclude);\n\n // Promisify the readFile function\n const promisifiedReadFile = promisify(readFile);\n\n return {\n name: 'sourcemaps',\n\n load: async function (this: PluginContext, id: string) {\n let code: string;\n // If the id does not pass the filter, return null\n if (!filter(id)) {\n return null;\n }\n\n try {\n // Try to read the file with the given id\n code = (await promisifiedReadFile(id)).toString();\n // Add the file to the watch list\n this.addWatchFile(id);\n } catch {\n try {\n // If reading fails, try again without a query suffix that some plugins use\n const cleanId = id.replace(/\\?.*$/, '');\n code = (await promisifiedReadFile(cleanId)).toString();\n // Add the file to the watch list\n this.addWatchFile(cleanId);\n } catch {\n // If reading still fails, warn and return null\n this.warn('Failed reading file');\n return null;\n }\n }\n\n let map: ExistingRawSourceMap;\n try {\n // Try to resolve the source map for the code\n const result = await resolveSourceMap(code, id, promisifiedReadFile);\n\n // If the code contained no sourceMappingURL, return the code\n if (result === null) {\n return code;\n }\n\n // If the source map was resolved, assign it to map\n map = result.map;\n } catch {\n // If resolving the source map fails, warn and return the code\n this.warn('Failed resolving source map');\n return code;\n }\n\n // If the sources are not included in the map, try to resolve them\n if (map.sourcesContent === undefined) {\n try {\n const { sourcesContent } = await resolveSources(map, id, promisifiedReadFile);\n // If all sources are strings, assign them to map.sourcesContent\n if (sourcesContent.every(item => typeof item === 'string')) {\n map.sourcesContent = sourcesContent;\n }\n } catch {\n // If resolving the sources fails, warn\n this.warn('Failed resolving sources for source map');\n }\n }\n\n // Return the code and the map\n return { code, map };\n },\n };\n}\n"],"names":["createFilter","pluginUtils","sourcemaps","include","exclude","readFile","fs","filter","promisifiedReadFile","promisify","name","load","id","code","toString","addWatchFile","cleanId","replace","warn","map","result","resolveSourceMap","sourcesContent","undefined","resolveSources","every","item"],"mappings":";;;;;;;AAMA,MAAM,EAAEA,YAAY,EAAE,GAAGC,WAAAA,CAAAA;AAQV,SAASC;AAEtB,EAAEC,OAAO,EAAEC,OAAO,EAAEC,QAAAA,GAAWC,GAAGD,QAAQ,EAA2B,GAAG,EAAE,EAAA;;IAG1E,MAAME,MAAAA,GAASP,aAAaG,OAASC,EAAAA,OAAAA,CAAAA,CAAAA;;AAGrC,IAAA,MAAMI,sBAAsBC,mBAAUJ,CAAAA,QAAAA,CAAAA,CAAAA;IAEtC,OAAO;QACLK,IAAM,EAAA,YAAA;AAENC,QAAAA,IAAAA,EAAM,eAAqCC,EAAU,EAAA;YACnD,IAAIC,IA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