Skip to content

Add option to embed entire @babel/runtime #11663

@marco-a

Description

@marco-a

Feature Request

  • I would like to work on this feature!

Is your feature request related to a problem?
This is a feature requested based on this issue.
I would like babel to have an option to embed the entire @babel/runtime in the transpiled code so no external dependencies are needed to run the code.
It is possible to embed some of the runtime by setting the flag helpers to false.
However, no option exist to embed the entire runtime.

Describe the solution you'd like
That @babel/plugin-transform-runtime accepts a new option called embed.
When set to true, babel will automatically embed all external dependencies in the transpiled code:

{ "plugins": [ [ "@babel/plugin-transform-runtime", { "embed": true } ] ] }

Describe alternatives you've considered.
It is possible to embed the dependencies yourself by using a bundler like webpack.
However this adds unnecessary complexity for a simple project.

Documentation, Adoption, Migration Strategy
If you can, explain how users will be able to use this and how it might be documented. Maybe a mock-up?


embed

boolean, defaults to false.

Tells babel whether or not to embed all runtime dependencies.
If set to true babel will create output code that does not depend on any external dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions