-
-
Notifications
You must be signed in to change notification settings - Fork 57
Draft: adds a --platform flag to js #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1. Fixed missing type export (platforms/node.d.ts) - Exported DefaultNodeSetupOptions type that is referenced in index.js 2. Updated index.d.ts to support both platforms - Made init() function accept DefaultNodeSetupOptions for node platform - Made init() function accept Options for browser platform 3. Fixed conditional compilation in node.js - Wrapped getImports() in HAS_IMPORTS conditional (platforms/node.js)
test both browser and node platform variants
/// Name of the package (default: lowercased Package.swift name) | ||
var packageName: String? | ||
/// Target platform for the generated JavaScript (default: browser) | ||
var platform: String? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this become an enum Platform: CaseIterable
, so then you would rely on .allCases
to dynamically compute help string for all available platforms in the help output you've added below for this new option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Will do
Please run |
Currently
swift package js
only generates code for the "browser" platform.This PR adds a
--platform node|browser [default: browser]
argument that lets you control this behaviour. In case ofnode
it will generate ainit
function that callsdefaultNodeSetup
instead ofdefaultBrowserSetup
.