-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rewriteImportExtensions
option to TS preset
#15913
Add rewriteImportExtensions
option to TS preset
#15913
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55407/ |
Yes please! I understand Typescript's reasoning for not doing this, but I think they're wrong. I really would like to be able to tell users to do the obvious thing instead of something which feels like a dumb hack. Do note that there's some edge cases here - in particular, this will break if the user is importing (and not bundling) a package whose name ends in |
Good idea. |
) { | ||
const { source } = path.node; | ||
if (source) { | ||
source.value = source.value.replace(/(\.[mc]?)ts$/, "$1js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source.value = source.value.replace(/(\.[mc]?)ts$/, "$1js"); | |
source.value = source.value.replace(/(\/.+?\.[mc]?)ts$/, "$1js"); |
To cover the edge case mentioned by @bakkot, unless the import is specified as import "/tmp/soundcloud.ts"
, which we can't tackle without resolving it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!source.includes("@"))
We may also want to exclude @
, such as @org/mod.ts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would only special-case import specifiers that contain no \
or /
, because the only way a specifier without /
could work is if it maps to a folder (using Node.js' resolution algorithm) or to a file without any rewriting (using an import map).
For example, I have a project with an import map that includes the following:
{
"imports": {
"@/": "./",
"@components/": "./frontend/components/"
As such, @/foo.ts
and @components/foo.ts
both map to files and not to directories (and thus they would need their .ts
extension to be rewritten).
I would prefer to either (in other of preference):
- do nothing, and if somebody has some imports that must not be rewritten they can disable the option for that file
- only ignore imports with no
/
- extract the plugin to its own package, and when it's used directly allow passing a function
originalSpecifier => transformedSpecifier
to allow users to filter and transform however they want
However, before doing (3) I would wait for someone to open an issue with a concrete use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract the plugin to its own package, and when it's used directly allow passing a function originalSpecifier => transformedSpecifier to allow users to filter and transform however they want
We can even allow rewriteImportExtensions
to pass in a function in the future.😉
| t.ExportNamedDeclaration | ||
>, | ||
) { | ||
const { source } = path.node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also early return if importKind
is type
, since they will be stripped by the typescript transform anyway.
1100adf
to
48d5a27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending Babel 8 snapshot updates.
<p>This PR was automatically created by Snyk using the credentials of a real user.</p><br /><h3>Snyk has created this PR to upgrade multiple dependencies.</h3> 👯♂ The following dependencies are linked and will therefore be updated together. </br></br> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. </br></br> Name | Versions | Released on :-------------|:-------------|:------------- **@babel/parser**</br>from 7.22.16 to 7.23.0 | **1 version** ahead of your current version | **22 days ago**</br>on 2023-09-25 **@babel/types**</br>from 7.22.19 to 7.23.0 | **1 version** ahead of your current version | **22 days ago**</br>on 2023-09-25 <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>@babel/parser</b></summary> <ul> <li> <b>7.23.0</b> - <a href="https://snyk.io/redirect/github/babel/babel/releases/tag/v7.23.0">2023-09-25</a></br><h2>v7.23.0 (2023-09-25)</h2> <p>Thanks <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lorenzoferre/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a> and <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/RajShukla1/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/RajShukla1">@ RajShukla1</a> for your first PRs!</p> <h4>🚀 New Feature</h4> <ul> <li><code>babel-plugin-proposal-import-wasm-source</code>, <code>babel-plugin-syntax-import-source</code>, <code>babel-plugin-transform-dynamic-import</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15870" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15870/hovercard">#15870</a> Support transforming <code>import source</code> for wasm (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-helper-module-transforms</code>, <code>babel-helpers</code>, <code>babel-plugin-proposal-import-defer</code>, <code>babel-plugin-syntax-import-defer</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15878" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15878/hovercard">#15878</a> Implement <code>import defer</code> proposal transform support (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-generator</code>, <code>babel-parser</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15845" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15845/hovercard">#15845</a> Implement <code>import defer</code> parsing support (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15829" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15829/hovercard">#15829</a> Add parsing support for the "source phase imports" proposal (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-generator</code>, <code>babel-helper-module-transforms</code>, <code>babel-parser</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-systemjs</code>, <code>babel-traverse</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15682" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15682/hovercard">#15682</a> Add <code>createImportExpressions</code> parser option (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> </ul> </li> <li><code>babel-standalone</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15671" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15671/hovercard">#15671</a> Pass through nonce to the transformed script element (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> </ul> </li> <li><code>babel-helper-function-name</code>, <code>babel-helper-member-expression-to-functions</code>, <code>babel-helpers</code>, <code>babel-parser</code>, <code>babel-plugin-proposal-destructuring-private</code>, <code>babel-plugin-proposal-optional-chaining-assign</code>, <code>babel-plugin-syntax-optional-chaining-assign</code>, <code>babel-plugin-transform-destructuring</code>, <code>babel-plugin-transform-optional-chaining</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15751" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15751/hovercard">#15751</a> Add support for optional chain in assignments (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-helpers</code>, <code>babel-plugin-proposal-decorators</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15895" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15895/hovercard">#15895</a> Implement the "decorator metadata" proposal (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-traverse</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15893" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15893/hovercard">#15893</a> Add <code>t.buildUndefinedNode</code> (<a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a>)</li> </ul> </li> <li><code>babel-preset-typescript</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15913" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15913/hovercard">#15913</a> Add <code>rewriteImportExtensions</code> option to TS preset (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-parser</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15896" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15896/hovercard">#15896</a> Allow TS tuples to have both labeled and unlabeled elements (<a href="https://snyk.io/redirect/github/yukukotani">@ yukukotani</a>)</li> </ul> </li> </ul> <h4>🐛 Bug Fix</h4> <ul> <li><code>babel-plugin-transform-block-scoping</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15962" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15962/hovercard">#15962</a> fix: <code>transform-block-scoping</code> captures the variables of the method in the loop (<a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a>)</li> </ul> </li> </ul> <h4>💅 Polish</h4> <ul> <li><code>babel-traverse</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15797" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15797/hovercard">#15797</a> Expand evaluation of global built-ins in <code>@ babel/traverse</code> (<a href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a>)</li> </ul> </li> <li><code>babel-plugin-proposal-explicit-resource-management</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15985" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15985/hovercard">#15985</a> Improve source maps for blocks with <code>using</code> declarations (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> </ul> <h4>🔬 Output optimization</h4> <ul> <li><code>babel-core</code>, <code>babel-helper-module-transforms</code>, <code>babel-plugin-transform-async-to-generator</code>, <code>babel-plugin-transform-classes</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-function-name</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-umd</code>, <code>babel-plugin-transform-parameters</code>, <code>babel-plugin-transform-react-constant-elements</code>, <code>babel-plugin-transform-react-inline-elements</code>, <code>babel-plugin-transform-runtime</code>, <code>babel-plugin-transform-typescript</code>, <code>babel-preset-env</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15984" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15984/hovercard">#15984</a> Inline <code>exports.XXX =</code> update in simple variable declarations (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> </ul> <h4>Committers: 7</h4> <ul> <li>Babel Bot (<a href="https://snyk.io/redirect/github/babel-bot">@ babel-bot</a>)</li> <li>Huáng Jùnliàng (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> <li>Lorenzo Ferretti (<a href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a>)</li> <li>Nicolò Ribaudo (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> <li>Raj Pawan Shukla (<a href="https://snyk.io/redirect/github/RajShukla1">@ RajShukla1</a>)</li> <li>Yuku Kotani (<a href="https://snyk.io/redirect/github/yukukotani">@ yukukotani</a>)</li> <li><a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a></li> </ul> </li> <li> <b>7.22.16</b> - <a href="https://snyk.io/redirect/github/babel/babel/releases/tag/v7.22.16">2023-09-06</a></br><h2>v7.22.16 (2023-09-06)</h2> <h4>🐛 Bug Fix</h4> <ul> <li><code>babel-parser</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15935" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15935/hovercard">#15935</a> fix: <code>__esModule</code> is missing from published <code>@ babel/parser</code> (<a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a>)</li> </ul> </li> </ul> <h4>🏠 Internal</h4> <ul> <li><code>babel-traverse</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15936" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15936/hovercard">#15936</a> Skip deprecation warning tests when in a folder named <code>@ babel</code> (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> </ul> <h4>Committers: 3</h4> <ul> <li>Huáng Jùnliàng (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> <li>Nicolò Ribaudo (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> <li><a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a></li> </ul> </li> </ul> from <a href="https://snyk.io/redirect/github/babel/babel/releases">@babel/parser GitHub release notes</a> </details> <details> <summary>Package name: <b>@babel/types</b></summary> <ul> <li> <b>7.23.0</b> - <a href="https://snyk.io/redirect/github/babel/babel/releases/tag/v7.23.0">2023-09-25</a></br><h2>v7.23.0 (2023-09-25)</h2> <p>Thanks <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lorenzoferre/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a> and <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/RajShukla1/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/RajShukla1">@ RajShukla1</a> for your first PRs!</p> <h4>🚀 New Feature</h4> <ul> <li><code>babel-plugin-proposal-import-wasm-source</code>, <code>babel-plugin-syntax-import-source</code>, <code>babel-plugin-transform-dynamic-import</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15870" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15870/hovercard">#15870</a> Support transforming <code>import source</code> for wasm (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-helper-module-transforms</code>, <code>babel-helpers</code>, <code>babel-plugin-proposal-import-defer</code>, <code>babel-plugin-syntax-import-defer</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15878" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15878/hovercard">#15878</a> Implement <code>import defer</code> proposal transform support (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-generator</code>, <code>babel-parser</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15845" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15845/hovercard">#15845</a> Implement <code>import defer</code> parsing support (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15829" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15829/hovercard">#15829</a> Add parsing support for the "source phase imports" proposal (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-generator</code>, <code>babel-helper-module-transforms</code>, <code>babel-parser</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-systemjs</code>, <code>babel-traverse</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15682" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15682/hovercard">#15682</a> Add <code>createImportExpressions</code> parser option (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> </ul> </li> <li><code>babel-standalone</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15671" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15671/hovercard">#15671</a> Pass through nonce to the transformed script element (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> </ul> </li> <li><code>babel-helper-function-name</code>, <code>babel-helper-member-expression-to-functions</code>, <code>babel-helpers</code>, <code>babel-parser</code>, <code>babel-plugin-proposal-destructuring-private</code>, <code>babel-plugin-proposal-optional-chaining-assign</code>, <code>babel-plugin-syntax-optional-chaining-assign</code>, <code>babel-plugin-transform-destructuring</code>, <code>babel-plugin-transform-optional-chaining</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15751" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15751/hovercard">#15751</a> Add support for optional chain in assignments (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-helpers</code>, <code>babel-plugin-proposal-decorators</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15895" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15895/hovercard">#15895</a> Implement the "decorator metadata" proposal (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-traverse</code>, <code>babel-types</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15893" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15893/hovercard">#15893</a> Add <code>t.buildUndefinedNode</code> (<a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a>)</li> </ul> </li> <li><code>babel-preset-typescript</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15913" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15913/hovercard">#15913</a> Add <code>rewriteImportExtensions</code> option to TS preset (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> <li><code>babel-parser</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15896" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15896/hovercard">#15896</a> Allow TS tuples to have both labeled and unlabeled elements (<a href="https://snyk.io/redirect/github/yukukotani">@ yukukotani</a>)</li> </ul> </li> </ul> <h4>🐛 Bug Fix</h4> <ul> <li><code>babel-plugin-transform-block-scoping</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15962" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15962/hovercard">#15962</a> fix: <code>transform-block-scoping</code> captures the variables of the method in the loop (<a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a>)</li> </ul> </li> </ul> <h4>💅 Polish</h4> <ul> <li><code>babel-traverse</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15797" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15797/hovercard">#15797</a> Expand evaluation of global built-ins in <code>@ babel/traverse</code> (<a href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a>)</li> </ul> </li> <li><code>babel-plugin-proposal-explicit-resource-management</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15985" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15985/hovercard">#15985</a> Improve source maps for blocks with <code>using</code> declarations (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> </ul> <h4>🔬 Output optimization</h4> <ul> <li><code>babel-core</code>, <code>babel-helper-module-transforms</code>, <code>babel-plugin-transform-async-to-generator</code>, <code>babel-plugin-transform-classes</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-function-name</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-umd</code>, <code>babel-plugin-transform-parameters</code>, <code>babel-plugin-transform-react-constant-elements</code>, <code>babel-plugin-transform-react-inline-elements</code>, <code>babel-plugin-transform-runtime</code>, <code>babel-plugin-transform-typescript</code>, <code>babel-preset-env</code> <ul> <li><a href="https://snyk.io/redirect/github/babel/babel/pull/15984" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/15984/hovercard">#15984</a> Inline <code>exports.XXX =</code> update in simple variable declarations (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> </ul> </li> </ul> <h4>Committers: 7</h4> <ul> <li>Babel Bot (<a href="https://snyk.io/redirect/github/babel-bot">@ babel-bot</a>)</li> <li>Huáng Jùnliàng (<a href="https://snyk.io/redirect/github/JLHwung">@ JLHwung</a>)</li> <li>Lorenzo Ferretti (<a href="https://snyk.io/redirect/github/lorenzoferre">@ lorenzoferre</a>)</li> <li>Nicolò Ribaudo (<a href="https://snyk.io/redirect/github/nicolo-ribaudo">@ nicolo-ribaudo</a>)</li> <li>Raj Pawan Shukla (<a href="https://snyk.io/redirect/github/RajShukla1">@ RajShukla1</a>)</li> <li>Yuku Kotani (<a href="https://snyk.io/redirect/github/yukukotani">@ yukukotani</a>)</li> <li><a href="https://snyk.io/redirect/github/liuxingbaoyu">@ liuxingbaoyu</a></li> </ul> </li> <li> <b>7.22.19</b> - <a href="https://snyk.io/redirect/github/babel/babel/releases/tag/v7.22.19">2023-09-14</a></br><h2>v7.22.19 (2023-09-14)</h2> <p>Re-published 7.22.18, due to a releasing error.</p> </li> </ul> from <a href="https://snyk.io/redirect/github/babel/babel/releases">@babel/types GitHub release notes</a> </details> </details> <hr/> **Note:** *You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.* For more information: <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJkYTdkYzgwNS0xMDczLTQxMWEtYWM1OC1mYTZjMTcyNTJjNzgiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImRhN2RjODA1LTEwNzMtNDExYS1hYzU4LWZhNmMxNzI1MmM3OCJ9fQ==" width="0" height="0"/> 🧐 [View latest project report](https://app.snyk.io/org/woodpile37/project/e5e31077-489f-44c1-b24d-4af9a1a8d603?utm_source=github&utm_medium=referral&page=upgrade-pr) 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/woodpile37/project/e5e31077-489f-44c1-b24d-4af9a1a8d603/settings/integration?utm_source=github&utm_medium=referral&page=upgrade-pr) 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/woodpile37/project/e5e31077-489f-44c1-b24d-4af9a1a8d603/settings/integration?pkg=@babel/parser&pkg=@babel/types&utm_source=github&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) <!--- (snyk:metadata:{"prId":"da7dc805-1073-411a-ac58-fa6c17252c78","prPublicId":"da7dc805-1073-411a-ac58-fa6c17252c78","dependencies":[{"name":"@babel/parser","from":"7.22.16","to":"7.23.0"},{"name":"@babel/types","from":"7.22.19","to":"7.23.0"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/woodpile37/project/e5e31077-489f-44c1-b24d-4af9a1a8d603?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"e5e31077-489f-44c1-b24d-4af9a1a8d603","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":1,"publishedDate":"2023-09-25T08:10:31.822Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]}) --->
Fixes #1, Fixes #2
This PR moves the plugin introduced in #15892 to the TS preset, so that our users can use it too (rather than keeping it just for ourselves :P).
How do you feel about doing this? Technically it's a divergence from
tsc
(which never rewrites imports), but it's opt-in behind an option.It's a quite popular TS feature request (microsoft/TypeScript#55346, microsoft/TypeScript#49083, microsoft/TypeScript#37582, and many others), and now that TS provides the allowImportingTsExtensions option we are in a position of allowing it.