Skip to content

Remix doesn't import .mjs files, when defined without extension. #10604

@ericfennis

Description

@ericfennis

Reproduction

  1. Create an .mjs file with some js
  2. Import like you normally would import something, like import MyModule from "./my-module";
  3. See it throws an error. "Cannot find module"

System Info

System:
    OS: macOS 14.7.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 2.62 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.7.0 - ~/.nvm/versions/node/v23.7.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v23.7.0/bin/npm
    pnpm: 9.15.3 - ~/.nvm/versions/node/v23.7.0/bin/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
  Browsers:
    Chrome: 135.0.7049.116
    Safari: 18.1
  npmPackages:
    @remix-run/dev: ^2.16.5 => 2.16.5 
    @remix-run/node: ^2.16.5 => 2.16.5 
    @remix-run/react: ^2.16.5 => 2.16.5 
    @remix-run/serve: ^2.16.5 => 2.16.5 
    vite: ^6.0.0 => 6.3.4

Used Package Manager

pnpm

Expected Behavior

Remix should import .mjs files if it won't find a .js file.

Actual Behavior

Throws error: "Cannot find module"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions