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

Function transform

packages/json/src/index.js:11–31  ·  view source on GitHub ↗
(code, id)

Source from the content-addressed store, hash-verified

9
10 // eslint-disable-next-line no-shadow
11 transform(code, id) {
12 if (id.slice(-5) !== '.json' || !filter(id)) return null;
13
14 try {
15 const parsed = JSON.parse(code);
16 return {
17 code: dataToEsm(parsed, {
18 preferConst: options.preferConst,
19 compact: options.compact,
20 namedExports: options.namedExports,
21 includeArbitraryNames: options.includeArbitraryNames,
22 indent
23 }),
24 map: { mappings: '' }
25 };
26 } catch (err) {
27 const message = 'Could not parse JSON file';
28 this.error({ message, id, cause: err });
29 return null;
30 }
31 }
32 };
33}

Callers

nothing calls this directly

Calls 2

dataToEsmFunction · 0.90
filterFunction · 0.50

Tested by

no test coverage detected