Skip to content

Explicit URL imports import the module when used with javascript files #16648

@kallekankaanpaa

Description

@kallekankaanpaa

Describe the bug

When trying to import the URL of a javascript file with the explicit URL import as described in the documentation the javascript module is imported rather than just the URL of the module.

This only happens when running the code with npm run dev the bundle built with npm run build works as expected.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ubhupq?file=main.js

Steps to reproduce

  1. npm install
  2. npm run dev

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 2.81 GB / 7.62 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.2 - ~/.nvm/versions/node/v20.12.2/bin/npm

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    inconsistencyInconsistency between dev & buildp2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions