aboutsummaryrefslogtreecommitdiff
path: root/src/resolver/package_json.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolver/package_json.zig')
-rw-r--r--src/resolver/package_json.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig
index 303ffc2d4..21f4c0906 100644
--- a/src/resolver/package_json.zig
+++ b/src/resolver/package_json.zig
@@ -16,6 +16,7 @@ pub const PackageJSON = struct {
source: logger.Source,
main_fields: MainFieldMap,
module_type: options.ModuleType,
+ version: string = "",
// Present if the "browser" field is present. This field is intended to be
// used by bundlers and lets you redirect the paths of certain 3rd-party
@@ -81,6 +82,12 @@ pub const PackageJSON = struct {
.main_fields = MainFieldMap.init(r.allocator),
};
+ if (json.asProperty("version")) |version_json| {
+ if (version_json.expr.asString(r.allocator)) |version_str| {
+ package_json.version = r.allocator.dupe(u8, version_str) catch unreachable;
+ }
+ }
+
if (json.asProperty("type")) |type_json| {
if (type_json.expr.asString(r.allocator)) |type_str| {
switch (options.ModuleType.List.get(type_str) orelse options.ModuleType.unknown) {