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

Function load

packages/data-uri/src/index.ts:49–84  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

47 },
48
49 load(id) {
50 if (!resolved[id]) {
51 return null;
52 }
53
54 const { mime, content } = resolved[id];
55
56 if (!content) {
57 return null;
58 }
59
60 if (mime === 'text/javascript') {
61 return content;
62 } else if (mime === 'application/json') {
63 let json = '';
64 try {
65 json = JSON.parse(content);
66 } catch (e: any) {
67 const error: RollupError = {
68 message: e.toString(),
69 cause: e,
70 plugin: '@rollup/plugin-data-uri',
71 pluginCode: 'DU$JSON'
72 };
73 this.error(error);
74 }
75
76 return dataToEsm(json, {
77 preferConst: true,
78 compact: false,
79 namedExports: true,
80 indent: ' '
81 });
82 }
83 return null;
84 }
85 };
86}

Callers

nothing calls this directly

Calls 1

dataToEsmFunction · 0.90

Tested by

no test coverage detected