diff options
author | 2021-10-06 15:11:34 -0700 | |
---|---|---|
committer | 2021-10-06 15:11:34 -0700 | |
commit | 96736b70788afcaec00fdfaaa3f2c65e7a1c3230 (patch) | |
tree | baefc090706dee0d9c85dbb06d0ebc2910d316b7 | |
parent | 0afec7739b9f1df8d9cf565f3fed19e663162734 (diff) | |
download | bun-jarred/bunfig.tar.gz bun-jarred/bunfig.tar.zst bun-jarred/bunfig.zip |
Start bunfig workjarred/bunfig
-rw-r--r-- | src/resolver/bunfig.example.json | 88 | ||||
-rw-r--r-- | src/resolver/bunfig_json.zig | 23 | ||||
-rw-r--r-- | src/resolver/tsconfig_json.zig | 5 |
3 files changed, 111 insertions, 5 deletions
diff --git a/src/resolver/bunfig.example.json b/src/resolver/bunfig.example.json new file mode 100644 index 000000000..c929d34c9 --- /dev/null +++ b/src/resolver/bunfig.example.json @@ -0,0 +1,88 @@ +// Everything in here is optional! This entire file is optional! +{ + "extends": "./bunfig.base.json", + "use": "next", + + // what to write import URLs as + "server": { + "origin": "http://localhost:3000/", + // port is automatically inferred from the origin + "port": 3000 + }, + + // What other tools call "entry points", Bun calls "routes" + // This is optional when you set "use" + // You can also pass it a directory and it will infer via the filesystem router + // Option 1: + // "routes": "./pages", + // Option 2: + // "routes": { + // "/[foo]": "./pages/[foo].js" + // }, + + "macros": { + "react-relay": { + // import {graphql} from "react-relay" + // ⬇ + // import {graphql} from "bun-macro-relay" + "graphql": "bun-macro-relay" + } + }, + ".env": { + // default: ".env", ".env.development", ".env.local" + "files": [".env"], + "prefix": "NEXT" + }, + "env": { + // this is defined by default + "NODE_ENV": "'development'" + }, + + "jsx": { + "factory": "React.createElement", + "fragment": "React.Fragment", + // "preact" + "importSource": "react", + "classicImportSource": "react", + "refresh": "react-refresh", + "runtime": "automatic" + }, + + "alwaysBundle": ["@mybigco/myworkspacepackage"], + + "external": [], + ".bun": "node_modules.bun", + "loaders": { + ".js": "js", + ".jsx": "jsx", + ".tsx": "tsx", + ".ts": "ts", + ".json": "json", + ".tcjs": "ts", + ".tmjs": "ts", + ".css": "css" + }, + + "override": { + // platform-specific overrides that inherit from top-level + "browser": { + "env": { + "prefix": "NEXT_PUBLIC_", + "vars": { + // this is defined by default + "process.env.NODE_ENV": "'development'" + } + } + }, + // platform-specific overrides that inherit from top-level + "bun.js": { + ".bun": "node_modules.server.bun" + }, + // platform-specific overrides that inherit from top-level + "node": { + ".bun": "node_modules.node.bun" + }, + // platform-specific overrides that inherit from top-level + "bun-macro": {} + } +} diff --git a/src/resolver/bunfig_json.zig b/src/resolver/bunfig_json.zig new file mode 100644 index 000000000..3ef1faffd --- /dev/null +++ b/src/resolver/bunfig_json.zig @@ -0,0 +1,23 @@ +usingnamespace @import("../global.zig"); +const std = @import("std"); +const options = @import("../options.zig"); +const logger = @import("../logger.zig"); +const cache = @import("../cache.zig"); +const js_ast = @import("../js_ast.zig"); +const js_lexer = @import("../js_lexer.zig"); +const Api = @import("../api/schema.zig").Api; + +pub const Bunfig = struct { + pub fn parse(allocator: *std.mem.Allocator, path: string, transform: *Api.TransformOptions, log: *logger.Log, comptime required: bool) !void { + var cwd = std.fs.cwd(); + cwd.openFile(path, .{ .read = true }) catch |err| { + switch (err) { + error.FileNotFound => { + if (comptime required) { + log.addErrorFmt(null, logger.Loc.Empty, allocator, "bunfig \"{s}\" not found", args: anytype) + } + }, + } + }; + } +}; diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index f61b48eb5..276726e44 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -5,7 +5,6 @@ const logger = @import("../logger.zig"); const cache = @import("../cache.zig"); const js_ast = @import("../js_ast.zig"); const js_lexer = @import("../js_lexer.zig"); -const alloc = @import("../alloc.zig"); // Heuristic: you probably don't have 100 of these // Probably like 5-10 @@ -340,7 +339,3 @@ pub const TSConfigJSON = struct { return false; } }; - -test "tsconfig.json" { - try alloc.setup(default_allocator); -} |