Skip to content

update: JS compiler features - #5884

Open
Danil Pavlov (danil-pavlov) wants to merge 2 commits into
masterfrom
js-compiler-upd
Open

Danil Pavlov (danil-pavlov) wants to merge 2 commits into
masterfrom
js-compiler-upd

Conversation

@danil-pavlov

@danil-pavlov Danil Pavlov (danil-pavlov) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
  • KT-89578 Improve Kotlin/JS IR compiler page


To change the granularity, set the `kotlin.js.ir.output.granularity` property in your `gradle.properties` file:

```none

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't gradle.properties use a different syntax? The // text becomes part of the value, rather than a comment.

Comment thread docs/topics/js/js-ir-compiler.md Outdated
To change the granularity, set the `kotlin.js.ir.output.granularity` property in your `gradle.properties` file:

```none
kotlin.js.ir.output.granularity=whole-program // 'per-module' is the default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
kotlin.js.ir.output.granularity=whole-program // 'per-module' is the default
# Default: per-module
kotlin.js.ir.output.granularity=whole-program

Comment thread docs/topics/js/js-ir-compiler.md Outdated
@@ -4,6 +4,74 @@ Kotlin/JS includes compiler features to optimize code for performance, size, and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we update the intro to cover the expanded scope?

Comment thread docs/topics/js/js-ir-compiler.md Outdated
This works through the compilation process, which transforms Kotlin code into an intermediate representation (IR) before
generating the JavaScript code.

## Configure output JavaScript versions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we duplicate the instructions here, if they are already covered in https://kotlinlang.org/docs/js-project-setup.html#set-an-ecmascript-target? Maybe crosslink instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's just a feature overview of the compiler with links to additional info in the corresponding pages


## Configure output JavaScript versions

The Kotlin/JS compiler can generate JavaScript for the ES5, ES2015, and ES2020 versions of the ECMAScript standard.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Kotlin/JS compiler can generate JavaScript for the ES5, ES2015, and ES2020 versions of the ECMAScript standard.
The Kotlin/JS compiler can generate JavaScript for the ES5, ES2015, and ES2020 versions of the ECMAScript standard. Choose the newest version supported by your target environment.

Comment thread docs/topics/js/js-ir-compiler.md Outdated
You can choose how the compiler outputs `.js` files in your project:

* **Per module** (default). The compiler outputs a separate `.js` file for each project module.
* **Whole program**. The compiler compiles the whole project into a single `.js` file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* **Whole program**. The compiler compiles the whole project into a single `.js` file.
* **Whole program:** generates a single `.js` file for the whole program.

Comment thread docs/topics/js/js-ir-compiler.md Outdated

* **Per module** (default). The compiler outputs a separate `.js` file for each project module.
* **Whole program**. The compiler compiles the whole project into a single `.js` file.
* **Per file**. The compiler generates one (or two, if the file contains exported declarations) `.js` file per each Kotlin file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* **Per file**. The compiler generates one (or two, if the file contains exported declarations) `.js` file per each Kotlin file.
* **Per file:** generates one `.js` file for each Kotlin file, or two if the file contains exported declarations.

```none
kotlin.js.ir.output.granularity=whole-program // 'per-module' is the default
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we mention that it's availavle for ES2015 or ES2020 only?


## Configure output granularity

You can choose how the compiler outputs `.js` files in your project:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can subsequent bundling change how that output is divided into files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't go into such details here

Comment thread docs/topics/js/js-ir-compiler.md Outdated
kotlin.js.ir.output.granularity=whole-program // 'per-module' is the default
```

For more details, including the requirements for the per-file mode, see [Configure output granularity](js-project-setup.md#configure-output-granularity).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
For more details, including the requirements for the per-file mode, see [Configure output granularity](js-project-setup.md#configure-output-granularity).
For configuration details, see [Configure output granularity](js-project-setup.md#configure-output-granularity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants