Skip to content

Commit 8fbddcf

Browse files
Add an escape hatch for disabling the resources declaration
1 parent 6d4a114 commit 8fbddcf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Package.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,17 @@ let package = Package(
5252
),
5353
]
5454
)
55+
56+
// `resources` implicitly forces the package to link `Foundation` but
57+
// we don't actually need it at runtime since the `resources` declaration
58+
// is just for teaching carton how to bundle .js files into the package.
59+
// For those who really want to avoid linking `Foundation` at all, you can
60+
// set the `JAVASCRIPTKIT_NO_FOUNDATION` environment variable to any value
61+
// before running `swift test` or `swift build` to skip the `resources` declaration.
62+
import Foundation
63+
64+
if ProcessInfo.processInfo.environment["JAVASCRIPTKIT_NO_FOUNDATION"] != nil {
65+
for target in package.targets {
66+
target.resources = nil
67+
}
68+
}

0 commit comments

Comments
 (0)