@farmfe/runtime
Version:
Runtime of Farm
101 lines • 3.28 kB
JavaScript
/* eslint-disable @typescript-eslint/no-explicit-any */
export class Module {
constructor(id, require) {
this.resource_pot = "";
this.id = id;
this.exports = {};
this.meta = {
env: {}
};
this.require = require;
}
o(to, to_k, get) {
Object.defineProperty(to, to_k, {
enumerable: true,
get
});
}
// exports.xx = xx
d(to, to_k, val) {
this.o(to, to_k, function () {
return val;
});
}
// exports.__esModule
_m(to) {
const key = '__esModule';
if (to[key])
return;
Object.defineProperty(to, key, { value: true });
}
// `export * from` helper
_e(to, from) {
Object.keys(from).forEach(function (k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, { value: from[k], enumerable: true, configurable: true });
}
});
return from;
}
// `import xxx from` helper
i(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
// `import * as xx` helper, copied from @swc/helper
_g(nodeInterop) {
if (typeof WeakMap !== "function")
return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (this._g = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
// `import * as xx` helper, copied from @swc/helper
w(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule)
return obj;
if (obj === null || typeof obj !== "object" && typeof obj !== "function")
return { default: obj };
var cache = this._g(nodeInterop);
if (cache && cache.has(obj))
return cache.get(obj);
var newObj = { __proto__: null };
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set))
Object.defineProperty(newObj, key, desc);
else
newObj[key] = obj[key];
}
}
newObj.default = obj;
if (cache)
cache.set(obj, newObj);
return newObj;
}
// `export { xx } from` helper
_(to, to_k, from, from_k) {
this.d(to, to_k, from[from_k || to_k]);
}
// revert imports/exports minify helper
p(to, val) {
for (const key of Object.keys(val)) {
const newKey = to[key];
if (newKey && !Object.prototype.hasOwnProperty.call(val, newKey)) {
this.d(val, newKey, val[key]);
}
}
}
// minify x.default
f(v) {
if (typeof v.default !== 'undefined') {
return v.default;
}
// compatible `import default from "module"`
return v;
}
}
//# sourceMappingURL=module.js.map