MCPcopy
hub / github.com/freshframework/fresh / handler

Function handler

packages/plugin-vite/src/plugins/deno.ts:248–287  ·  view source on GitHub ↗
(_, id)

Source from the content-addressed store, hash-verified

246 id: JSX_REG,
247 },
248 async handler(_, id) {
249 // This transform is a hack to be able to re-use Deno's precompile
250 // jsx transform.
251 if (this.environment.name === "client") {
252 return;
253 }
254
255 let actualId = id;
256 if (isDenoSpecifier(id)) {
257 const { specifier } = parseDenoSpecifier(id);
258 actualId = specifier;
259 }
260 actualId = actualId.replace("?commonjs-es-import", "");
261
262 if (actualId.startsWith("\0")) {
263 actualId = actualId.slice(1);
264 }
265 if (path.isAbsolute(actualId)) {
266 actualId = path.toFileUrl(actualId).href;
267 }
268
269 const resolved = await ssrLoader.resolve(
270 actualId,
271 undefined,
272 ResolutionMode.Import,
273 );
274 const result = await ssrLoader.load(
275 resolved,
276 RequestedModuleType.Default,
277 );
278 if (result.kind === "external") {
279 return;
280 }
281
282 const code = new TextDecoder().decode(result.code);
283
284 return {
285 code,
286 };
287 },
288 },
289 };
290}

Callers 1

onwarnFunction · 0.50

Calls 2

isDenoSpecifierFunction · 0.85
parseDenoSpecifierFunction · 0.85

Tested by

no test coverage detected