Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard code for runtimeModuleName #10454

Closed
TomokiMiyauci opened this issue Mar 4, 2024 · 0 comments · Fixed by #10457
Closed

Hard code for runtimeModuleName #10454

TomokiMiyauci opened this issue Mar 4, 2024 · 0 comments · Fixed by #10457

Comments

@TomokiMiyauci
Copy link

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`,

Doctor-wu added a commit to Doctor-wu/core that referenced this issue Mar 5, 2024
yyx990803 pushed a commit that referenced this issue Mar 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant