diff options
author | 2022-07-11 04:53:45 -0400 | |
---|---|---|
committer | 2022-07-11 01:53:45 -0700 | |
commit | 3abfc3566be8730c9c9d6e57cb355f57e0acb303 (patch) | |
tree | 869c3b388395b8740fa25d2c7d258252001b2037 /src | |
parent | 71992634a641337483d391a552d047bd7f281738 (diff) | |
download | bun-3abfc3566be8730c9c9d6e57cb355f57e0acb303.tar.gz bun-3abfc3566be8730c9c9d6e57cb355f57e0acb303.tar.zst bun-3abfc3566be8730c9c9d6e57cb355f57e0acb303.zip |
add depd browser polyfill (#517)
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/depd.exports.js | 75 | ||||
-rw-r--r-- | src/bun.js/javascript.zig | 14 |
2 files changed, 89 insertions, 0 deletions
diff --git a/src/bun.js/depd.exports.js b/src/bun.js/depd.exports.js new file mode 100644 index 000000000..b44020d9f --- /dev/null +++ b/src/bun.js/depd.exports.js @@ -0,0 +1,75 @@ +/*! + * depd + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); + +// node_modules/depd/lib/browser/index.js +var require_browser = __commonJS({ + "node_modules/depd/lib/browser/index.js"(exports, module) { + "use strict"; + module.exports = depd2; + function depd2(namespace) { + if (!namespace) { + throw new TypeError("argument namespace is required"); + } + function deprecate(message) { + } + deprecate._file = void 0; + deprecate._ignored = true; + deprecate._namespace = namespace; + deprecate._traced = false; + deprecate._warned = /* @__PURE__ */ Object.create(null); + deprecate.function = wrapfunction; + deprecate.property = wrapproperty; + return deprecate; + } + function wrapfunction(fn, message) { + if (typeof fn !== "function") { + throw new TypeError("argument fn must be a function"); + } + return fn; + } + function wrapproperty(obj, prop, message) { + if (!obj || typeof obj !== "object" && typeof obj !== "function") { + throw new TypeError("argument obj must be object"); + } + var descriptor = Object.getOwnPropertyDescriptor(obj, prop); + if (!descriptor) { + throw new TypeError("must call property on owner object"); + } + if (!descriptor.configurable) { + throw new TypeError("property must be configurable"); + } + } + } +}); + +// bundle.js +var import_depd = __toESM(require_browser()); +var bundle_default = import_depd.default; + +depd[Symbol.for("CommonJS")] = true; // TODO: this requires hacky default export + +export default function depd(...args) { + return args.length ? bundle_default(...args) : bundle_default; +}
\ No newline at end of file diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 90356fafa..d295d6c8e 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -952,6 +952,17 @@ pub const VirtualMachine = struct { .hash = 0, }; }, + @"depd" => { + return ResolvedSource{ + .allocator = null, + .source_code = ZigString.init( + @as(string, @embedFile("./depd.exports.js")), + ), + .specifier = ZigString.init("depd"), + .source_url = ZigString.init("depd"), + .hash = 0, + }; + }, } } else if (_specifier.len > js_ast.Macro.namespaceWithColon.len and strings.eqlComptimeIgnoreLen(_specifier[0..js_ast.Macro.namespaceWithColon.len], js_ast.Macro.namespaceWithColon)) @@ -2707,6 +2718,7 @@ pub const HardcodedModule = enum { @"bun:jsc", @"bun:main", @"bun:sqlite", + @"depd", @"detect-libc", @"node:fs", @"node:fs/promises", @@ -2728,6 +2740,7 @@ pub const HardcodedModule = enum { .{ "bun:jsc", HardcodedModule.@"bun:jsc" }, .{ "bun:main", HardcodedModule.@"bun:main" }, .{ "bun:sqlite", HardcodedModule.@"bun:sqlite" }, + .{ "depd", HardcodedModule.@"depd" }, .{ "detect-libc", HardcodedModule.@"detect-libc" }, .{ "ffi", HardcodedModule.@"bun:ffi" }, .{ "fs", HardcodedModule.@"node:fs" }, @@ -2757,6 +2770,7 @@ pub const HardcodedModule = enum { .{ "bun:jsc", "bun:jsc" }, .{ "bun:sqlite", "bun:sqlite" }, .{ "bun:wrap", "bun:wrap" }, + .{ "depd", "depd" }, .{ "detect-libc", "detect-libc" }, .{ "detect-libc/lib/detect-libc.js", "detect-libc" }, .{ "ffi", "bun:ffi" }, |