MCPcopy Create free account
hub / github.com/rollup/plugins / transform

Function transform

packages/yaml/src/index.js:30–54  ·  view source on GitHub ↗
(content, id)

Source from the content-addressed store, hash-verified

28 name: 'yaml',
29
30 transform(content, id) {
31 if (!extensions.some((ext) => id.toLowerCase().endsWith(ext))) return null;
32 if (!filter(id)) return null;
33
34 let data = loadMethod(content);
35
36 if (typeof options.transform === 'function') {
37 const result = options.transform(data, id);
38 // eslint-disable-next-line no-undefined
39 if (result !== undefined) {
40 data = result;
41 }
42 }
43
44 const keys = Object.keys(data).filter((key) => key === makeLegalIdentifier(key));
45 const code = `var data = ${toSource(data)};\n\n`;
46 const exports = ['export default data;']
47 .concat(keys.map((key) => `export var ${key} = data.${key};`))
48 .join('\n');
49
50 return {
51 code: code + exports,
52 map: { mappings: '' }
53 };
54 }
55 };
56}

Callers

nothing calls this directly

Calls 3

makeLegalIdentifierFunction · 0.90
keysMethod · 0.80
filterFunction · 0.50

Tested by

no test coverage detected