Skip to content

Hard code for runtimeModuleName #10454

Description

@TomokiMiyauci

Vue version

3.4.21

Link to minimal reproduction

No

Steps to reproduce

import { compileScript, parse } from "vue/compiler-sfc";

const { descriptor } = parse(`<script setup lang="ts">
console.log(1);
</script>`);

const result = compileScript(descriptor, {
  id: descriptor.filename,
  templateOptions: {
    compilerOptions: {
      runtimeModuleName: "npm:vue",
    },
  },
});

console.log(result.content);

What is expected?

The output will be overwritten with the specified specifier.

What is actually happening?

The output will look like this:

import { defineComponent as _defineComponent } from 'vue'

export default /*#__PURE__*/_defineComponent({
  setup(__props, { expose: __expose }) {
  __expose();

console.log(1);
...

System Info

No response

Any additional comments?

Perhaps the following code needs to be modified:

ctx.s.prepend(
`import { ${[...ctx.helperImports]
.map(h => `${h} as _${h}`)
.join(', ')} } from 'vue'\n`,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions