Skip to content

module: add --experimental-transform-types flag - #54283

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
marco-ippolito:feat/enable-transformations
Aug 12, 2024
Merged

module: add --experimental-transform-types flag#54283
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
marco-ippolito:feat/enable-transformations

Conversation

@marco-ippolito

@marco-ippolitomarco-ippolito commented Aug 9, 2024

Copy link
Copy Markdown
Member

With the new flag --experimental-transform-types it is possible to enable the transformation of TypeScript-only syntax into JavaScript code.
This feature allows Node.js to support TypeScript syntax such as Enum and namespace.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/typescript

@marco-ippolitomarco-ippolito changed the title module: add --experimental-enable-transformation for strip-types[WIP] module: add --experimental-enable-transformation for strip-typesAug 9, 2024
@nodejs-github-botnodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 9, 2024
@marco-ippolitomarco-ippolito added wip Issues and PRs that are still a work in progress. strip-types Issues or PRs related to strip-types support labels Aug 9, 2024
@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch from 29040a6 to c5da92eCompareAugust 9, 2024 11:20
@marco-ippolito
marco-ippolito marked this pull request as ready for review August 9, 2024 11:20
@marco-ippolitomarco-ippolito changed the title [WIP] module: add --experimental-enable-transformation for strip-typesmodule: add --experimental-enable-transformation for strip-typesAug 9, 2024
@marco-ippolitomarco-ippolito removed the wip Issues and PRs that are still a work in progress. label Aug 9, 2024

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment threaddoc/api/cli.md Outdated
@marco-ippolitomarco-ippolito added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 9, 2024
@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch 2 times, most recently from de62233 to 7343717CompareAugust 9, 2024 12:15
Comment threaddoc/api/cli.md Outdated

@legendecaslegendecas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we also add a test case that --experimental-enable-transformation doesn't eliminate unused imports, like this example?

@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch from 7343717 to b67230fCompareAugust 9, 2024 12:58
Comment threadtest/fixtures/typescript/ts/transformation/test-unused-import.ts Outdated
Comment threaddoc/api/cli.md Outdated
@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch from b67230f to e0ac82eCompareAugust 9, 2024 13:27
@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch from e0ac82e to 3578d86CompareAugust 9, 2024 13:35
@marco-ippolitomarco-ippolito changed the title module: add --experimental-enable-transformation for strip-typesmodule: add --experimental-enable--type-transform for strip-typesAug 9, 2024
@marco-ippolitomarco-ippolito changed the title module: add --experimental-enable--type-transform for strip-typesmodule: add --experimental-enable-type-transform for strip-typesAug 9, 2024
@marco-ippolito
marco-ippolitoforce-pushed the feat/enable-transformations branch from 3578d86 to 6b155bdCompareAugust 9, 2024 13:37

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, on closer look I have a change request: I think --experimental-enable-type-transform should imply --enable-source-maps.

(I'm +1 on the feature)

@marco-ippolito

Copy link
Copy Markdown
MemberAuthor

Actually, on closer look I have a change request: I think --experimental-enable-type-transform should imply --enable-source-maps.

(I'm +1 on the feature)

Probably makes more sense, otherwise location will be always wrong

Comment threaddoc/api/typescript.md Outdated
@marco-ippolitomarco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 12, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 12, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@marco-ippolitomarco-ippolito added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Aug 12, 2024
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 12, 2024
@nodejs-github-bot
nodejs-github-bot merged commit 0301309 into nodejs:mainAug 12, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0301309

@statianzo

Copy link
Copy Markdown

Has there been discussion around writing out the result of typescript transformation?

It would allow package creators to publish TS -> JS consistent with the transformations node is doing internally. Given transformations don't apply to node_modules, packages authored using TS will require additional tooling to apply before the ability to publish. If publishers opt for tsc it wouldn't exactly match the calling the .ts from node directly.

Happy to post this comment elsewhere if more suitable.

@marco-ippolito

marco-ippolito commented Aug 12, 2024

Copy link
Copy Markdown
MemberAuthor

Has there been discussion around writing out the result of typescript transformation?

It would allow package creators to publish TS -> JS consistent with the transformations node is doing internally. Given transformations don't apply to node_modules, packages authored using TS will require additional tooling to apply before the ability to publish. If publishers opt for tsc it wouldn't exactly match the calling the .ts from node directly.

Happy to post this comment elsewhere if more suitable.

We have a repository for this kind of discussion nodejs/typescript

@Bnaya

Copy link
Copy Markdown

Sorry if i'm later to the party :)
Does it supports only the features that are supported by typescript's isolatedModules, or also the cross-file features?

@jakebailey

Copy link
Copy Markdown
Member

No, this is just isolatedModules. Node.js is not shipping a type checker that can perform that kind of analysis.

@targos

Copy link
Copy Markdown
Member

I optimistically pushed it to v22.x-staging but tests failed, so I took it out: https://github.com/nodejs/node/actions/runs/10382663326/job/28746123871

@marco-ippolito

Copy link
Copy Markdown
MemberAuthor

I optimistically pushed it to v22.x-staging but tests failed, so I took it out: https://github.com/nodejs/node/actions/runs/10382663326/job/28746123871

It requires backport I think, to imply the experimental-detect-module

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

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.notable-changePRs with changes that should be highlighted in changelogs.semver-minorPRs that contain new features and should be released in the next minor version.strip-typesIssues or PRs related to strip-types support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

20 participants

@marco-ippolito@nodejs-github-bot@mcollina@legendecas@robpalme@statianzo@Bnaya@jakebailey@targos@ShogunPanda@jasnell@benjamingr@anonrig@khaosdoctor@magic-akari@himself65@aduh95@mertcanaltin@avivkeller@VoltrexKeyva