Skip to content
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

[Feature]: extensionAlias support #15354

Closed
sibelius opened this issue Oct 22, 2024 · 5 comments
Closed

[Feature]: extensionAlias support #15354

sibelius opened this issue Oct 22, 2024 · 5 comments

Comments

@sibelius
Copy link

🚀 Feature Proposal

Similar to webpack/rpsack extensionAlias

https://webpack.js.org/configuration/resolve/#resolveextensionalias

webpack/webpack#13252 (comment)

Be able to resolve import "myFile.js" to myFile.ts, to enable ESM

Motivation

ESM requires file extensions, so we need to import using .js, but this breaks jest that it is looking for .ts file instead

Example

import "myFile.js" to myFile.ts, to enable ESM

Pitch

solve another ESM problem and make module resolution faster

/** @type {import("next").NextConfig} */
const nextConfig = {
  experimental: {
    // Remove .js from import specifiers, because
    // Next.js and webpack do not yet support
    // TypeScript-style module resolution out of the box
    // https://github.com/webpack/webpack/issues/13252#issuecomment-1171080020
    // https://github.com/vercel/next.js/pull/45423
    // https://github.com/vercel/next.js/issues/58805
    // https://github.com/vercel/next.js/issues/54550
    extensionAlias: {
      '.js': ['.ts', '.tsx', '.js', '.jsx'],
      '.jsx': ['.tsx', '.jsx'],
      '.mjs': ['.mts', '.mjs'],
      '.cjs': ['.cts', '.cjs'],
    },
  },
}

@karlhorky
Copy link
Contributor

karlhorky commented Oct 22, 2024

Alternative

Hey @sibelius ! 👋 Long time no see, hope everything's good with you.

Considering that part of the TypeScript 5.7+ ecosystem is moving to fully-specified import specifiers with *.ts* extensions (motivated by Node.js type stripping), would allowImportingTsExtensions from TypeScript 5.0 with .ts file extensions work for you?

I wrote a bit in a similar issue over here:

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 21, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants