MCPcopy Index your code
hub / github.com/CoderLine/alphaTab / renderChunk

Function renderChunk

packages/vite/src/workerPlugin.ts:138–186  ·  view source on GitHub ↗
(code, chunk, outputOptions)

Source from the content-addressed store, hash-verified

136 },
137
138 renderChunk(code, chunk, outputOptions) {
139 // when building the worker URLs are replaced with some placeholders
140 // here we replace those placeholders with the final file names respecting chunks
141
142 let s: MagicString;
143 const result = () => {
144 return (
145 s && {
146 code: s.toString(),
147 map: resolvedConfig.build.sourcemap ? s.generateMap({ hires: 'boundary' }) : null
148 }
149 );
150 };
151 workerAssetUrlRE.lastIndex = 0;
152 if (workerAssetUrlRE.test(code)) {
153 const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(
154 outputOptions.format,
155 resolvedConfig.isWorker
156 );
157
158 s = new MagicString(code);
159 workerAssetUrlRE.lastIndex = 0;
160
161 // Replace "VITE_WORKER_ASSET__5aa0ddc0" using relative paths
162 const workerMap = workerCache.get(resolvedConfig.mainConfig || resolvedConfig)!;
163 const { fileNameHash } = workerMap;
164
165 let match: RegExpExecArray | null = workerAssetUrlRE.exec(code);
166 while (match) {
167 const [full, hash] = match;
168 const filename = fileNameHash.get(hash)!;
169 const replacement = toOutputFilePathInJS(
170 filename,
171 'asset',
172 chunk.fileName,
173 'js',
174 resolvedConfig,
175 toRelativeRuntime
176 );
177 const replacementString =
178 typeof replacement === 'string'
179 ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
180 : `"+${replacement.runtime}+"`;
181 s.update(match.index, match.index + full.length, replacementString);
182 match = workerAssetUrlRE.exec(code);
183 }
184 }
185 return result();
186 },
187
188 generateBundle(_, bundle) {
189 if (isWorker) {

Callers

nothing calls this directly

Calls 10

toOutputFilePathInJSFunction · 0.90
encodeURIPathFunction · 0.90
resultFunction · 0.85
stringifyMethod · 0.80
testMethod · 0.65
getMethod · 0.65
updateMethod · 0.65
execMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected