diff --git a/Package.swift b/Package.swift index aa529c772..220c5213f 100644 --- a/Package.swift +++ b/Package.swift @@ -52,3 +52,17 @@ let package = Package( ), ] ) + +// `resources` implicitly forces the package to link `Foundation` but +// we don't actually need it at runtime since the `resources` declaration +// is just for teaching carton how to bundle .js files into the package. +// For those who really want to avoid linking `Foundation` at all, you can +// set the `JAVASCRIPTKIT_NO_FOUNDATION` environment variable to any value +// before running `swift test` or `swift build` to skip the `resources` declaration. +import Foundation + +if ProcessInfo.processInfo.environment["JAVASCRIPTKIT_NO_FOUNDATION"] != nil { + for target in package.targets { + target.resources = nil + } +}