For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/rspeedy/rspeedy.resolve.extensions.md.
Rspeedy logo
Rspeedy
  • English
  • Home > @lynx-js/rspeedy > Resolve > extensions

    Resolve.extensions property

    Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions.

    Signature:

    extensions?: string[] | undefined;

    Default Value

    ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json', '.cjs']

    For example, if importing './index', Rsbuild will try to resolve using the following order:

    • ./index.ts

    • ./index.tsx

    • ./index.mjs

    • ./index.js

    • ./index.jsx

    • ./index.json

    • ./index.cjs

    Remarks

    The difference between resolve.extensions and tools.rspack.resolve.extensions:

    resolve.extensions: Completely overrides Rspeedy's default resolution.

    tools.rspack.resolve.extensions: Merges with the default configuration using [webpack-merge](https://github.com/survivejs/webpack-merge).

    Example

    export default {
      resolve: {
        extensions: ['.ts', '.tsx', '.js'],
      },
    }
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.