aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-25 19:08:11 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-25 19:08:11 -0700
commit029ba1ea4439dff3943b053848901d0391912037 (patch)
tree449f4d4975679c74b9e036162fdd8f623ab6b260
parent454160646923e98f00e53df025e324d3d2c585d0 (diff)
downloadbun-029ba1ea4439dff3943b053848901d0391912037.tar.gz
bun-029ba1ea4439dff3943b053848901d0391912037.tar.zst
bun-029ba1ea4439dff3943b053848901d0391912037.zip
Fix scoped packages with `bun bun`
Former-commit-id: c29ff9ff602aeed4f9b19e4f003a20effcf70c0a
-rw-r--r--.gitignore9
-rw-r--r--.vscode/launch.json10
-rw-r--r--examples/lotta-modules/package.json1
-rw-r--r--src/bun_queue.zig8
-rw-r--r--src/resolver/resolver.zig11
5 files changed, 27 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 423739243..1a677dd0b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,4 +49,11 @@ txt.js
node_modules_*
*.jsb
-*.zip \ No newline at end of file
+*.zip
+bun-zigld
+bun-singlehtreaded
+bun-nomimalloc
+bun-mimalloc
+examples/lotta-modules/bun-yday
+examples/lotta-modules/bun-old
+examples/lotta-modules/bun-nofscache
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 763640c48..912ebf7b6 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -149,7 +149,15 @@
"cwd": "${workspaceFolder}/examples/lotta-modules/",
"console": "internalConsole"
},
-
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "Build .bun lotta-modules",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
+ "args": ["bun", "./index.js", "--platform=browser"],
+ "cwd": "${workspaceFolder}/examples/lotta-modules/",
+ "console": "internalConsole"
+ },
{
"type": "lldb",
"request": "launch",
diff --git a/examples/lotta-modules/package.json b/examples/lotta-modules/package.json
index 6688548da..3e60aba00 100644
--- a/examples/lotta-modules/package.json
+++ b/examples/lotta-modules/package.json
@@ -1,7 +1,6 @@
{
"name": "lotta-modules",
"version": "1.0.0",
- "main": "index.js",
"license": "MIT",
"dependencies": {
"@babel/standalone": "^7.15.3",
diff --git a/src/bun_queue.zig b/src/bun_queue.zig
index 4c289d511..e602adc6d 100644
--- a/src/bun_queue.zig
+++ b/src/bun_queue.zig
@@ -1,6 +1,5 @@
const std = @import("std");
const Mutex = @import("./lock.zig").Mutex;
-const Channel = @import("./sync.zig").Channel;
const WaitGroup = @import("./sync.zig").WaitGroup;
usingnamespace @import("./global.zig");
const Wyhash = std.hash.Wyhash;
@@ -145,8 +144,6 @@ pub fn NewBunQueue(comptime Value: type) type {
const KeyType = u32;
const BunQueue = @This();
const Queue = NewBlockQueue(Value, 64, 48);
- // pub const Fifo = NewFifo(Value);
-
allocator: *std.mem.Allocator,
queue: Queue,
keys: Keys,
@@ -170,14 +167,12 @@ pub fn NewBunQueue(comptime Value: type) type {
pub const Keys = struct {
pub const OverflowList = std.ArrayList([*]KeyType);
- // Half a page of memory
blocks: [overflow_size][*]KeyType = undefined,
offset: AtomicOffset,
block_overflow: OverflowList,
block_overflow_lock: bool = false,
first_key_list: [block_size]KeyType = undefined,
- mutex: Mutex = Mutex{},
write_lock: bool = false,
append_readers: u8 = 0,
append_lock: bool = false,
@@ -195,7 +190,9 @@ pub fn NewBunQueue(comptime Value: type) type {
}
};
+ // Half a page of memory
pub const block_size = 2048 / @sizeOf(KeyType);
+ // 32 is arbitrary
pub const overflow_size = 32;
// In one atomic load/store, get the length and offset of the keys
@@ -228,7 +225,6 @@ pub fn NewBunQueue(comptime Value: type) type {
inline fn contains(this: *BunQueue, key: KeyType) bool {
@fence(.Acquire);
if (@atomicLoad(KeyType, &this.keys.pending_write, .SeqCst) == key) return true;
- // this.keys.mutex.tryAcquire()
var offset = this.getOffset();
std.debug.assert(&this.keys.first_key_list == this.keys.blocks[0]);
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 46a849dc9..c6daad16e 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -914,14 +914,19 @@ pub fn NewResolver(cache_files: bool) type {
// ^------------^
var end = strings.lastIndexOf(absolute, node_module_root_string) orelse return null;
end += node_module_root_string.len;
+
+ const is_scoped_package = absolute[end] == '@';
end += strings.indexOfChar(absolute[end..], std.fs.path.sep) orelse return null;
- end += 1;
+
// /foo/node_modules/@babel/standalone/index.js
// ^
- if (absolute[end] == '@') {
- end += strings.indexOfChar(absolute[end..], std.fs.path.sep) orelse return null;
+ if (is_scoped_package) {
end += 1;
+ end += strings.indexOfChar(absolute[end..], std.fs.path.sep) orelse return null;
}
+
+ end += 1;
+
// /foo/node_modules/@babel/standalone/index.js
// ^
const slice = absolute[0..end];