Remove babel plugin imports from the tree at build time.

Review Request #14525 — Created July 28, 2025 and submitted

Information

Ink
master

Reviewers

Ink.DialogView introduced an import for babel-plugin-dedent in order
to use dedent in a log call. This resulted in an unwanted dependency
on this module in Ink, which we did not list in package.json. That
resulted in a broken-out-of-the-box experience. While this doesn't
appear to have affected runtime, it could affect consumers that wanted
to build against this.

This module (and babel-plugin-django-gettext) are only used when
building the tree and are no longer needed after the fact. Though Babel
will apply these, it does not automatically remove the imports. If we
had tree-shaking enabled, those imports would have been filtered out.

Tree-shaking has side-effects, but there is a Babel plugin that lets us
explicitly remove imports for the generated source going to Rollup:
babel-plugin-transform-remove-imports.

We now use this plugin and specify both babel-plugin-dedent and
babel-plugin-transform-remove-imports. Rollup no longer sees these
imports and no longer attempts to resolve them.

Built the package and diffed the resulting build against the current
release. Verified that the only changes to the build were that the
imports were gone.

Summary ID
Remove babel plugin imports from the tree at build time.
`Ink.DialogView` introduced an import for `babel-plugin-dedent` in order to use `dedent` in a log call. This resulted in an unwanted dependency on this module in Ink, which we did not list in `package.json`. That resulted in a broken-out-of-the-box experience. While this doesn't appear to have affected runtime, it could affect consumers that wanted to build against this. This module (and `babel-plugin-django-gettext`) are only used when building the tree and are no longer needed after the fact. Though Babel will apply these, it does not automatically remove the imports. If we had tree-shaking enabled, those imports would have been filtered out. Tree-shaking has side-effects, but there is a Babel plugin that lets us explicitly remove imports for the generated source going to Rollup: `babel-plugin-transform-remove-imports`. We now use this plugin and specify both `babel-plugin-dedent` and `babel-plugin-transform-remove-imports`. Rollup no longer sees these imports and no longer attempts to resolve them.
8616bff8228dd5a7cf3a61495807d244eaab316b
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (8da5108)