MCPcopy
hub / github.com/stenciljs/core / transform

Function transform

src/compiler/bundle/ext-format-plugin.ts:11–37  ·  view source on GitHub ↗
(code: string, importPath: string)

Source from the content-addressed store, hash-verified

9 name: 'extFormatPlugin',
10
11 transform(code: string, importPath: string): TransformResult {
12 if (/\0/.test(importPath)) {
13 return null;
14 }
15
16 const { ext, filePath, format } = normalizeFsPathQuery(importPath);
17
18 // ?format= param takes precedence before file extension
19 switch (format) {
20 case 'url':
21 return { code: formatUrl(config, this, code, filePath, ext), map: null };
22 case 'text':
23 return { code: formatText(code, filePath), map: null };
24 }
25
26 // didn't provide a ?format= param
27 // check if it's a known extension we should format
28 if (ext != null && FORMAT_TEXT_EXTS.includes(ext)) {
29 return { code: formatText(code, filePath), map: null };
30 }
31
32 if (ext != null && FORMAT_URL_MIME[ext]) {
33 return { code: formatUrl(config, this, code, filePath, ext), map: null };
34 }
35
36 return null;
37 },
38 };
39};
40

Callers

nothing calls this directly

Calls 3

normalizeFsPathQueryFunction · 0.85
formatUrlFunction · 0.85
formatTextFunction · 0.85

Tested by

no test coverage detected