bun 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/README.txt ADDED
@@ -0,0 +1,12 @@
1
+ The 'bun.exe' file is a placeholder for the binary file, which
2
+ is replaced by Bun's 'postinstall' script. For this to work, make
3
+ sure that you do not use --ignore-scripts while installing.
4
+
5
+ The postinstall script is responsible for linking the binary file
6
+ directly into 'node_modules/.bin' and avoiding a Node.js wrapper
7
+ script being called on every invocation of 'bun'. If this wasn't
8
+ done, Bun would seem to be slower than Node.js, because it would
9
+ be executing a copy of Node.js every time!
10
+
11
+ Unfortunately, it is not possible to fix all cases on all platforms
12
+ without *requiring* a postinstall script.
package/bin/bun.exe ADDED
File without changes
package/install.js CHANGED
@@ -1,3 +1,4 @@
1
+ // Source code: https://github.com/oven-sh/bun/blob/main/packages/bun-release/scripts/npm-postinstall.ts
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropNames = Object.getOwnPropertyNames, __getOwnPropSymbols = Object.getOwnPropertySymbols, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -310,7 +311,14 @@ function isRosetta2() {
310
311
  }
311
312
  __name(isRosetta2, "isRosetta2");
312
313
  function isWindowsAVX2() {
313
- return !1;
314
+ try {
315
+ return spawn("powershell", [
316
+ "-c",
317
+ `(Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru)::IsProcessorFeaturePresent(40);`
318
+ ]).stdout == "True";
319
+ } catch (error2) {
320
+ return debug("isWindowsAVX2 failed", error2), !1;
321
+ }
314
322
  }
315
323
  __name(isWindowsAVX2, "isWindowsAVX2");
316
324
 
@@ -368,7 +376,7 @@ function installBun(platform, dst) {
368
376
  write(join(cwd, "package.json"), "{}");
369
377
  let { exitCode } = spawn(
370
378
  "npm",
371
- ["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.1.0`],
379
+ ["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.1.1`],
372
380
  {
373
381
  cwd,
374
382
  stdio: "pipe",
@@ -389,7 +397,7 @@ function installBun(platform, dst) {
389
397
  __name(installBun, "installBun");
390
398
  function downloadBun(platform, dst) {
391
399
  return __async(this, null, function* () {
392
- let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.1.0.tgz`)).arrayBuffer(), buffer;
400
+ let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.1.1.tgz`)).arrayBuffer(), buffer;
393
401
  try {
394
402
  buffer = (0, import_zlib.unzipSync)(tgz);
395
403
  } catch (cause) {
@@ -416,13 +424,9 @@ function downloadBun(platform, dst) {
416
424
  }
417
425
  __name(downloadBun, "downloadBun");
418
426
  function optimizeBun(path2) {
419
- let installScript = os2 === "win32" ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash", { npm_config_user_agent } = process.env;
420
- if (npm_config_user_agent && /\byarn\//.test(npm_config_user_agent))
421
- throw new Error(
422
- `Yarn does not support bun, because it does not allow linking to binaries. To use bun, install using the following command: ${installScript}`
423
- );
427
+ let installScript = os2 === "win32" ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash";
424
428
  try {
425
- rename(path2, join(__dirname, "bin", "bun"));
429
+ rename(path2, join(__dirname, "bin", "bun.exe"));
426
430
  return;
427
431
  } catch (error2) {
428
432
  debug("optimizeBun failed", error2);
package/package.json CHANGED
@@ -1,37 +1,23 @@
1
1
  {
2
2
  "name": "bun",
3
- "version": "1.1.0",
4
3
  "description": "Bun is a fast all-in-one JavaScript runtime.",
5
- "keywords": [
6
- "bun",
7
- "bun.js",
8
- "node",
9
- "node.js",
10
- "runtime",
11
- "bundler",
12
- "transpiler",
13
- "typescript"
14
- ],
15
- "homepage": "https://bun.sh",
16
- "bugs": "https://github.com/oven-sh/issues",
17
- "license": "MIT",
18
- "bin": {
19
- "bun": "bin/bun",
20
- "bunx": "bin/bun"
21
- },
22
- "repository": "https://github.com/oven-sh/bun",
4
+ "version": "1.1.1",
23
5
  "scripts": {
24
6
  "postinstall": "node install.js"
25
7
  },
26
8
  "optionalDependencies": {
27
- "@oven/bun-darwin-aarch64": "1.1.0",
28
- "@oven/bun-darwin-x64": "1.1.0",
29
- "@oven/bun-darwin-x64-baseline": "1.1.0",
30
- "@oven/bun-linux-aarch64": "1.1.0",
31
- "@oven/bun-linux-x64": "1.1.0",
32
- "@oven/bun-linux-x64-baseline": "1.1.0",
33
- "@oven/bun-windows-x64": "1.1.0",
34
- "@oven/bun-windows-x64-baseline": "1.1.0"
9
+ "@oven/bun-darwin-aarch64": "1.1.1",
10
+ "@oven/bun-darwin-x64": "1.1.1",
11
+ "@oven/bun-darwin-x64-baseline": "1.1.1",
12
+ "@oven/bun-linux-aarch64": "1.1.1",
13
+ "@oven/bun-linux-x64": "1.1.1",
14
+ "@oven/bun-linux-x64-baseline": "1.1.1",
15
+ "@oven/bun-windows-x64": "1.1.1",
16
+ "@oven/bun-windows-x64-baseline": "1.1.1"
17
+ },
18
+ "bin": {
19
+ "bun": "bin/bun.exe",
20
+ "bunx": "bin/bun.exe"
35
21
  },
36
22
  "os": [
37
23
  "darwin",
@@ -41,5 +27,19 @@
41
27
  "cpu": [
42
28
  "arm64",
43
29
  "x64"
44
- ]
30
+ ],
31
+ "keywords": [
32
+ "bun",
33
+ "bun.js",
34
+ "node",
35
+ "node.js",
36
+ "runtime",
37
+ "bundler",
38
+ "transpiler",
39
+ "typescript"
40
+ ],
41
+ "homepage": "https://bun.sh",
42
+ "bugs": "https://github.com/oven-sh/issues",
43
+ "license": "MIT",
44
+ "repository": "https://github.com/oven-sh/bun"
45
45
  }
package/bin/bun DELETED
@@ -1,426 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropNames = Object.getOwnPropertyNames, __getOwnPropSymbols = Object.getOwnPropertySymbols, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
6
- for (var prop in b || (b = {}))
7
- __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
8
- if (__getOwnPropSymbols)
9
- for (var prop of __getOwnPropSymbols(b))
10
- __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
11
- return a;
12
- }, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function")
15
- for (let key of __getOwnPropNames(from))
16
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
25
- mod
26
- ));
27
- var __async = (__this, __arguments, generator) => new Promise((resolve, reject) => {
28
- var fulfilled = (value) => {
29
- try {
30
- step(generator.next(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- }, rejected = (value) => {
35
- try {
36
- step(generator.throw(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- }, step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
- step((generator = generator.apply(__this, __arguments)).next());
42
- });
43
-
44
- // src/console.ts
45
- var isAction = !!process.env.GITHUB_ACTION, isDebug = process.env.DEBUG === "1" || process.env.LOG_LEVEL === "debug" || process.env.RUNNER_DEBUG === "1";
46
- function debug(...message) {
47
- isAction ? [...message] : isDebug && [...message];
48
- }
49
- __name(debug, "debug");
50
- function error(...message) {
51
- isAction ? console.error("::error::", ...message) : console.error(...message);
52
- }
53
- __name(error, "error");
54
-
55
- // src/fetch.ts
56
- var fetch = "fetch" in globalThis ? webFetch : nodeFetch;
57
- function webFetch(_0) {
58
- return __async(this, arguments, function* (url, options = {}) {
59
- debug("fetch request", url, options);
60
- let response = yield globalThis.fetch(url, options, { verbose: isDebug });
61
- if (debug("fetch response", response), (options == null ? void 0 : options.assert) !== !1 && !isOk(response.status)) {
62
- try {
63
- debug(yield response.text());
64
- } catch (e) {
65
- }
66
- throw new Error(`${response.status}: ${url}`);
67
- }
68
- return response;
69
- });
70
- }
71
- __name(webFetch, "webFetch");
72
- function nodeFetch(_0) {
73
- return __async(this, arguments, function* (url, options = {}) {
74
- let { get } = yield import("http");
75
- return new Promise((resolve, reject) => {
76
- get(url, (response) => {
77
- var _a;
78
- debug("http.get", url, response.statusCode);
79
- let status = (_a = response.statusCode) != null ? _a : 501;
80
- if (response.headers.location && isRedirect(status))
81
- return nodeFetch(url).then(resolve, reject);
82
- if ((options == null ? void 0 : options.assert) !== !1 && !isOk(status))
83
- return reject(new Error(`${status}: ${url}`));
84
- let body = [];
85
- response.on("data", (chunk) => {
86
- body.push(chunk);
87
- }), response.on("end", () => {
88
- resolve({
89
- ok: isOk(status),
90
- status,
91
- arrayBuffer() {
92
- return __async(this, null, function* () {
93
- return Buffer.concat(body).buffer;
94
- });
95
- },
96
- text() {
97
- return __async(this, null, function* () {
98
- return Buffer.concat(body).toString("utf-8");
99
- });
100
- },
101
- json() {
102
- return __async(this, null, function* () {
103
- let text = Buffer.concat(body).toString("utf-8");
104
- return JSON.parse(text);
105
- });
106
- }
107
- });
108
- });
109
- }).on("error", reject);
110
- });
111
- });
112
- }
113
- __name(nodeFetch, "nodeFetch");
114
- function isOk(status) {
115
- return status >= 200 && status <= 204;
116
- }
117
- __name(isOk, "isOk");
118
- function isRedirect(status) {
119
- switch (status) {
120
- case 301:
121
- case 308:
122
- case 302:
123
- case 307:
124
- case 303:
125
- return !0;
126
- }
127
- return !1;
128
- }
129
- __name(isRedirect, "isRedirect");
130
-
131
- // src/spawn.ts
132
- var import_child_process = __toESM(require("child_process"));
133
- function spawn(cmd, args, options = {}) {
134
- debug("spawn", [cmd, ...args].join(" "));
135
- let { status, stdout, stderr } = import_child_process.default.spawnSync(cmd, args, __spreadValues({
136
- stdio: "pipe",
137
- encoding: "utf-8"
138
- }, options));
139
- return {
140
- exitCode: status != null ? status : 1,
141
- stdout,
142
- stderr
143
- };
144
- }
145
- __name(spawn, "spawn");
146
-
147
- // src/fs.ts
148
- var import_path = __toESM(require("path")), import_fs = __toESM(require("fs")), import_os = __toESM(require("os"));
149
- function join(...paths) {
150
- return import_path.default.join(...paths.flat(2));
151
- }
152
- __name(join, "join");
153
- function tmp() {
154
- var _a;
155
- let tmpdir = (_a = process.env.RUNNER_TEMP) != null ? _a : import_os.default.tmpdir(), dir = import_fs.default.mkdtempSync(join(tmpdir, "bun-"));
156
- return debug("tmp", dir), dir;
157
- }
158
- __name(tmp, "tmp");
159
- function rm(path2) {
160
- debug("rm", path2);
161
- try {
162
- import_fs.default.rmSync(path2, { recursive: !0 });
163
- return;
164
- } catch (error2) {
165
- debug("fs.rmSync failed", error2);
166
- }
167
- let stats;
168
- try {
169
- stats = import_fs.default.lstatSync(path2);
170
- } catch (error2) {
171
- debug("fs.lstatSync failed", error2);
172
- return;
173
- }
174
- if (!stats.isDirectory()) {
175
- import_fs.default.unlinkSync(path2);
176
- return;
177
- }
178
- try {
179
- import_fs.default.rmdirSync(path2, { recursive: !0 });
180
- return;
181
- } catch (error2) {
182
- debug("fs.rmdirSync failed", error2);
183
- }
184
- for (let filename of import_fs.default.readdirSync(path2))
185
- rm(join(path2, filename));
186
- import_fs.default.rmdirSync(path2);
187
- }
188
- __name(rm, "rm");
189
- function rename(path2, newPath) {
190
- debug("rename", path2, newPath);
191
- try {
192
- import_fs.default.renameSync(path2, newPath);
193
- return;
194
- } catch (error2) {
195
- debug("fs.renameSync failed", error2);
196
- }
197
- try {
198
- rm(newPath);
199
- } catch (error2) {
200
- debug("rm failed", error2);
201
- }
202
- import_fs.default.renameSync(path2, newPath);
203
- }
204
- __name(rename, "rename");
205
- function write(dst, content) {
206
- debug("write", dst);
207
- try {
208
- import_fs.default.writeFileSync(dst, content);
209
- return;
210
- } catch (error2) {
211
- debug("fs.writeFileSync failed", error2);
212
- try {
213
- import_fs.default.mkdirSync(import_path.default.dirname(dst), { recursive: !0 });
214
- } catch (error3) {
215
- debug("fs.mkdirSync failed", error3);
216
- }
217
- import_fs.default.writeFileSync(dst, content);
218
- }
219
- }
220
- __name(write, "write");
221
- function read(path2) {
222
- return debug("read", path2), import_fs.default.readFileSync(path2, "utf-8");
223
- }
224
- __name(read, "read");
225
- function chmod(path2, mode) {
226
- debug("chmod", path2, mode), import_fs.default.chmodSync(path2, mode);
227
- }
228
- __name(chmod, "chmod");
229
-
230
- // src/npm/install.ts
231
- var import_zlib = require("zlib");
232
-
233
- // src/platform.ts
234
- var os2 = process.platform, arch = os2 === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch, avx2 = arch === "x64" && (os2 === "linux" && isLinuxAVX2() || os2 === "darwin" && isDarwinAVX2() || os2 === "win32" && isWindowsAVX2()), platforms = [
235
- {
236
- os: "darwin",
237
- arch: "arm64",
238
- bin: "bun-darwin-aarch64",
239
- exe: "bin/bun"
240
- },
241
- {
242
- os: "darwin",
243
- arch: "x64",
244
- avx2: !0,
245
- bin: "bun-darwin-x64",
246
- exe: "bin/bun"
247
- },
248
- {
249
- os: "darwin",
250
- arch: "x64",
251
- bin: "bun-darwin-x64-baseline",
252
- exe: "bin/bun"
253
- },
254
- {
255
- os: "linux",
256
- arch: "arm64",
257
- bin: "bun-linux-aarch64",
258
- exe: "bin/bun"
259
- },
260
- {
261
- os: "linux",
262
- arch: "x64",
263
- avx2: !0,
264
- bin: "bun-linux-x64",
265
- exe: "bin/bun"
266
- },
267
- {
268
- os: "linux",
269
- arch: "x64",
270
- bin: "bun-linux-x64-baseline",
271
- exe: "bin/bun"
272
- },
273
- {
274
- os: "win32",
275
- arch: "x64",
276
- avx2: !0,
277
- bin: "bun-windows-x64",
278
- exe: "bin/bun.exe"
279
- },
280
- {
281
- os: "win32",
282
- arch: "x64",
283
- bin: "bun-windows-x64-baseline",
284
- exe: "bin/bun.exe"
285
- }
286
- ], supportedPlatforms = platforms.filter((platform) => platform.os === os2 && platform.arch === arch && (!platform.avx2 || avx2)).sort((a, b) => a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1);
287
- function isLinuxAVX2() {
288
- try {
289
- return read("/proc/cpuinfo").includes("avx2");
290
- } catch (error2) {
291
- return debug("isLinuxAVX2 failed", error2), !1;
292
- }
293
- }
294
- __name(isLinuxAVX2, "isLinuxAVX2");
295
- function isDarwinAVX2() {
296
- try {
297
- let { exitCode, stdout } = spawn("sysctl", ["-n", "machdep.cpu"]);
298
- return exitCode === 0 && stdout.includes("AVX2");
299
- } catch (error2) {
300
- return debug("isDarwinAVX2 failed", error2), !1;
301
- }
302
- }
303
- __name(isDarwinAVX2, "isDarwinAVX2");
304
- function isRosetta2() {
305
- try {
306
- let { exitCode, stdout } = spawn("sysctl", ["-n", "sysctl.proc_translated"]);
307
- return exitCode === 0 && stdout.includes("1");
308
- } catch (error2) {
309
- return debug("isRosetta2 failed", error2), !1;
310
- }
311
- }
312
- __name(isRosetta2, "isRosetta2");
313
- function isWindowsAVX2() {
314
- return !1;
315
- }
316
- __name(isWindowsAVX2, "isWindowsAVX2");
317
-
318
- // src/npm/install.ts
319
- function importBun() {
320
- return __async(this, null, function* () {
321
- if (!supportedPlatforms.length)
322
- throw new Error(`Unsupported platform: ${os2} ${arch}`);
323
- for (let platform of supportedPlatforms)
324
- try {
325
- return yield requireBun(platform);
326
- } catch (error2) {
327
- debug("requireBun failed", error2);
328
- }
329
- throw new Error('Failed to install package "bun"');
330
- });
331
- }
332
- __name(importBun, "importBun");
333
- function requireBun(platform) {
334
- return __async(this, null, function* () {
335
- let module2 = `@oven/${platform.bin}`;
336
- function resolveBun() {
337
- let exe = require.resolve(join(module2, platform.exe)), { exitCode, stderr, stdout } = spawn(exe, ["--version"]);
338
- if (exitCode === 0)
339
- return exe;
340
- throw new Error(stderr || stdout);
341
- }
342
- __name(resolveBun, "resolveBun");
343
- try {
344
- return resolveBun();
345
- } catch (cause) {
346
- debug("resolveBun failed", cause), error(
347
- `Failed to find package "${module2}".`,
348
- 'You may have used the "--no-optional" flag when running "npm install".'
349
- );
350
- }
351
- let cwd = join("node_modules", module2);
352
- try {
353
- installBun(platform, cwd);
354
- } catch (cause) {
355
- debug("installBun failed", cause), error(`Failed to install package "${module2}" using "npm install".`, cause);
356
- try {
357
- yield downloadBun(platform, cwd);
358
- } catch (cause2) {
359
- debug("downloadBun failed", cause2), error(`Failed to download package "${module2}" from "registry.npmjs.org".`, cause2);
360
- }
361
- }
362
- return resolveBun();
363
- });
364
- }
365
- __name(requireBun, "requireBun");
366
- function installBun(platform, dst) {
367
- let module2 = `@oven/${platform.bin}`, cwd = tmp();
368
- try {
369
- write(join(cwd, "package.json"), "{}");
370
- let { exitCode } = spawn(
371
- "npm",
372
- ["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.1.0`],
373
- {
374
- cwd,
375
- stdio: "pipe",
376
- env: __spreadProps(__spreadValues({}, process.env), {
377
- npm_config_global: void 0
378
- })
379
- }
380
- );
381
- exitCode === 0 && rename(join(cwd, "node_modules", module2), dst);
382
- } finally {
383
- try {
384
- rm(cwd);
385
- } catch (error2) {
386
- debug("rm failed", error2);
387
- }
388
- }
389
- }
390
- __name(installBun, "installBun");
391
- function downloadBun(platform, dst) {
392
- return __async(this, null, function* () {
393
- let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.1.0.tgz`)).arrayBuffer(), buffer;
394
- try {
395
- buffer = (0, import_zlib.unzipSync)(tgz);
396
- } catch (cause) {
397
- throw new Error("Invalid gzip data", { cause });
398
- }
399
- function str(i, n) {
400
- return String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
401
- }
402
- __name(str, "str");
403
- let offset = 0;
404
- for (; offset < buffer.length; ) {
405
- let name = str(offset, 100).replace("package/", ""), size = parseInt(str(offset + 124, 12), 8);
406
- if (offset += 512, !isNaN(size)) {
407
- if (write(join(dst, name), buffer.subarray(offset, offset + size)), name === platform.exe)
408
- try {
409
- chmod(join(dst, name), 493);
410
- } catch (error2) {
411
- debug("chmod failed", error2);
412
- }
413
- offset += size + 511 & -512;
414
- }
415
- }
416
- });
417
- }
418
- __name(downloadBun, "downloadBun");
419
-
420
- // scripts/npm-exec.ts
421
- var import_child_process2 = require("child_process");
422
- importBun().then((bun) => (0, import_child_process2.execFileSync)(bun, process.argv.slice(2), {
423
- stdio: "inherit"
424
- })).catch((error2) => {
425
- console.error(error2), process.exit(1);
426
- });