diff options
author | 2021-06-16 16:23:02 -0700 | |
---|---|---|
committer | 2021-06-16 16:23:02 -0700 | |
commit | e1677bb77414710c1114c3b52b3fa954d9276c45 (patch) | |
tree | 6ec40991e1d3d9fdaa7ec1ddc54a80818f1c40c5 /src/linker.zig | |
parent | 7eb887edd527713214790198de3ccfe828a5768d (diff) | |
download | bun-e1677bb77414710c1114c3b52b3fa954d9276c45.tar.gz bun-e1677bb77414710c1114c3b52b3fa954d9276c45.tar.zst bun-e1677bb77414710c1114c3b52b3fa954d9276c45.zip |
Skeleton!
Former-commit-id: 6e2c6cd6ea1fbda73977f563fc7fbdede1438527
Diffstat (limited to 'src/linker.zig')
-rw-r--r-- | src/linker.zig | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/linker.zig b/src/linker.zig index ac0244922..550b48590 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -17,7 +17,9 @@ const Resolver = @import("./resolver/resolver.zig"); const sync = @import("sync.zig"); const ThreadPool = sync.ThreadPool; const ThreadSafeHashMap = @import("./thread_safe_hash_map.zig"); -const ImportRecord = @import("./import_record.zig").ImportRecord; +const _import_record = @import("./import_record.zig"); +const ImportRecord = _import_record.ImportRecord; +const ImportKind = _import_record.ImportKind; const allocators = @import("./allocators.zig"); const MimeType = @import("./http/mime_type.zig"); const resolve_path = @import("./resolver/resolve_path.zig"); @@ -69,6 +71,37 @@ pub fn NewLinker(comptime BundlerType: type) type { return RequireOrImportMeta{}; } + pub fn resolveCSS( + this: *ThisLinker, + path: Fs.Path, + url: string, + range: logger.Range, + comptime kind: ImportKind, + comptime import_path_format: Options.BundleOptions.ImportPathFormat, + ) !string { + switch (kind) { + .at => { + var resolve_result = try this.resolver.resolve(path.name.dir, url, .at); + var import_record = ImportRecord{ .range = range, .path = resolve_result.path_pair.primary, .kind = kind }; + try this.processImportRecord(path.name.dir, &resolve_result, &import_record, import_path_format); + return import_record.path.text; + }, + .at_conditional => { + var resolve_result = try this.resolver.resolve(path.name.dir, url, .at_conditional); + var import_record = ImportRecord{ .range = range, .path = resolve_result.path_pair.primary, .kind = kind }; + try this.processImportRecord(path.name.dir, &resolve_result, &import_record, import_path_format); + return import_record.path.text; + }, + .url => { + var resolve_result = try this.resolver.resolve(path.name.dir, url, .url); + var import_record = ImportRecord{ .range = range, .path = resolve_result.path_pair.primary, .kind = kind }; + try this.processImportRecord(path.name.dir, &resolve_result, &import_record, import_path_format); + return import_record.path.text; + }, + else => unreachable, + } + } + // pub const Scratch = struct { // threadlocal var externals: std.ArrayList(u32) = undefined; // threadlocal var has_externals: std.ArrayList(u32) = undefined; |