Skip to content

Uncaught SyntaxError when using Composition API with Pug: Missing type in import statement #12542

@Nathan7139

Description

@Nathan7139

Vue version

3.4.27

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-pu2hgbvs?file=src%2Fcomponents%2FHelloWorldSetupPug.vue&terminal=dev
or
https://codesandbox.io/p/devbox/fast-cookies-75hgkn?file=%2Fsrc%2Fcomponents%2FHelloWorldSetupPug.vue%3A3%2C8&workspaceId=ws_QsAMR8rV8TbYxEA1u1WzFz

Steps to reproduce

  1. The reproduction includes four files: HelloWorld, HelloWorldSetup, HelloWorldPug, and HelloWorldSetupPug.
    • Setup indicates the use of the Composition API.
    • Pug indicates the use of Pug.
  2. Run the reproduction in a browser with pnpm install && pnpm dev.
  3. Only HelloWorldSetupPug triggers the error, while the other files (HelloWorld, HelloWorldSetup, and HelloWorldPug) work fine.
  4. The error appears when using import { MyType } from "../utils/myUtils" in HelloWorldSetupPug.
  5. Adding type to the import statement (import type { MyType } from "../utils/myUtils") resolves the issue.

What is expected?

All files, including HelloWorldSetupPug, should work without requiring type in the import statement if it is consistent with the behavior of the other files.

What is actually happening?

Only HelloWorldSetupPug throws the following error in the browser:

Uncaught SyntaxError: The requested module '/src/utils/myUtils.ts?t=1734061016288' does not provide an export named 'MyType'

This issue is resolved by adding type to the import statement.

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 65.95 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 8.7.6 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.140
    Safari: 17.6
    Safari Technology Preview: 18.0
  npmPackages:
    vue: ~3.4.27 => 3.4.38

Any additional comments?

  • This issue seems specific to the combination of Pug and the Composition API.
  • The other files (HelloWorld, HelloWorldSetup, and HelloWorldPug) work fine without adding type in the import statement.
  • Is this behavior a bug in the setup or expected based on current configurations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions