MCPcopy
hub / github.com/webpack/sass-loader / mockModuleOptions

Function mockModuleOptions

test/implementation-option.test.js:90–110  ·  view source on GitHub ↗

* Build a `mock.module` options bag whose exports read live from the * given wrapper object. * @param {Record } target wrapped namespace * @returns {Record } options accepted by the running Node's `mock.module`

(target)

Source from the content-addressed store, hash-verified

88 * @returns {Record<string, unknown>} options accepted by the running Node's `mock.module`
89 */
90function mockModuleOptions(target) {
91 if (NODE_MAJOR < 24) {
92 return { namedExports: target, defaultExport: target };
93 }
94
95 const liveExports = {};
96
97 for (const key of Object.keys(target)) {
98 Object.defineProperty(liveExports, key, {
99 enumerable: true,
100 get: () => target[key],
101 });
102 }
103
104 Object.defineProperty(liveExports, "default", {
105 enumerable: true,
106 get: () => target,
107 });
108
109 return { exports: liveExports };
110}
111
112mock.module(sassEsmURL, mockModuleOptions(sass));
113mock.module(sassEmbeddedEsmURL, mockModuleOptions(sassEmbedded));

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…