Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add--default-platform option topackage 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kateinoigakukun merged 11 commits intoswiftwasm:mainfromt089:platform-arg
Oct 24, 2025

Conversation

@t089
Copy link
Contributor

Currentlyswift 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.

1. Fixed missing type export (platforms/node.d.ts)   - Exported DefaultNodeSetupOptions type that is referenced in index.js2. Updated index.d.ts to support both platforms   - Made init() function accept DefaultNodeSetupOptions for node platform   - Made init() function accept Options for browser platform3. 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)
varpackageName:String?
/// Target platform for the generated JavaScript (default: browser)
varplatform:String?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could this become anenum 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?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sounds good! Will do

@MaxDesiatov
Copy link
Member

Please run./Utilities/format.py for the formatting check to pass.

@MaxDesiatovMaxDesiatov added enhancementNew feature or request dependenciesPull requests that update a dependency file labelsOct 20, 2025
@MaxDesiatovMaxDesiatov changed the titleDraft: adds a --platform flag to jsDraft: add--platform option topackage jsOct 20, 2025
@MaxDesiatovMaxDesiatov changed the titleDraft: add--platform option topackage jsAdd--platform option topackage jsOct 20, 2025
@MaxDesiatov
Copy link
Member

MaxDesiatov commentedOct 20, 2025
edited
Loading

Thanks for the updates! Cleaned up the title:

  • "Draft" in the title is not needed, as "Draft" status of PRs already makes that clear.
  • We use infinitive form of verbs in PR and commit titles, as with character limit in this field non-infinitive forms don't bring any useful information.
  • --platform is not a flag, as flags denote binary state and don't take any parameters. E.g.--enable-platform/--disable-platform without any parameters would be a flag, but--platform node/--platform browser is an option. If we were able to use Swift Argument Parser in plugins, this would use the@Option property wrapper.
t089 reacted with thumbs up emoji

Copy link
Member

@kateinoigakukunkateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for putting your effort here! Overall it makes sense to me!

Let me leave a few feedbacks before mering:

  • I'd like to keep the generated JS package to be runtime independent as much as possible, so it might be better to name the option as--default-platform, indicating that only the default entrypointindex.js is platform dependent, and rest of the modules are still platform independent. The clarification would be partuculary helpful for library author publishing a platform-agnostic JS package containing the JSKit genrated code.
  • I'm not a big fan of adding@types/node dependency here because we use only small surface of Node.js API, and most of the usage is not visible from users (except forWorker type). I think we can loosen type checks in the Node.js for the sake of the simplicity.

If that sounds reasonable, I can make changes on the top of your branch and merge this PR :)

@t089
Copy link
ContributorAuthor

Cool, yeah that seems reasonable, feel free to to change the patch accordingly! Thank you.

kateinoigakukun reacted with heart emoji

@kateinoigakukunkateinoigakukun marked this pull request as ready for reviewOctober 24, 2025 06:13
Copy link
Member

@kateinoigakukunkateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks!

@kateinoigakukunkateinoigakukun merged commit84243a4 intoswiftwasm:mainOct 24, 2025
9 checks passed
@kateinoigakukunkateinoigakukun changed the titleAdd--platform option topackage jsAdd--default-platform option topackage jsOct 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@MaxDesiatovMaxDesiatovMaxDesiatov left review comments

@kateinoigakukunkateinoigakukunkateinoigakukun approved these changes

Assignees

No one assigned

Labels

dependenciesPull requests that update a dependency fileenhancementNew feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@t089@MaxDesiatov@kateinoigakukun

[8]ページ先頭

©2009-2025 Movatter.jp