Skip to content

Add Platform Option to CLI Commands for Module Bundling #16

@jircdev

Description

@jircdev

Currently, BeyondJS works efficiently with modules and bundles, providing a seamless experience for developers. However, to enhance its capabilities further, I propose adding a new option to the CLI commands that allows developers to specify the target platform for code generation.

Issue Details:
When creating a new module using BeyondJS CLI, we want to introduce the "platform" option in the module.json . This option would allow developers to choose specific platforms for which the code will be generated. If the "platform" property is included in the module.json, the developer must specify all properties corresponding to the chosen platforms.

Nowadays, BeyondJS is not asking for taget platforms, so if the user need to specify one requires to open the module.json and set it manually. However, if the "platform" property is omitted, BeyondJS will automatically generate code for all supported platforms.

Example:
Below is an example of how the module.json file could be structured with the "platform" option:

// module.json
{
	"name": "subpath-name",
	"platforms": ["node"],
	"bundle": "ts",
	"files": "*"
}

In this example, the developer has specified that the code should be generated for both Node.js platform. Any platform-specific properties or configurations required by the modules will need to be provided in the module.json file.

Supported Platform Types:
The "platforms" property should support the following platform types:

  • web
  • ios
  • android
  • node
  • deno
  • backend
  • bun

Default Behavior:
If the "platform" property is not provided in the module.json file, BeyondJS will automatically assume that the module should support all platforms and generate the code accordingly.

Why is this feature valuable:
By introducing the "platform" option, developers can easily tailor their module code to specific platforms. This flexibility enhances code efficiency and ensures that modules are optimized for the target platforms. It also aligns with best practices for modular development and scalable solutions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions