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

dynamic import and ?raw not work after build #8160

Closed
7 tasks done
kitiho opened this issue May 13, 2022 · 1 comment
Closed
7 tasks done

dynamic import and ?raw not work after build #8160

kitiho opened this issue May 13, 2022 · 1 comment

Comments

@kitiho
Copy link

kitiho commented May 13, 2022

Describe the bug

I wanna use route param to be part of import path, and this TS file , I just want it be plain string, so I can render it like code by shikijs.

const questionIndex = route.params.id
const question = leetCodeQuestions.find(item => item.index === questionIndex)
onMounted(async() => {
  const { default: code } = await import(`../../constants/question-resolutions/${questionIndex}.ts?raw`)
})

It works in dev environment, but error after build.
image

Reproduction

https://github.com/kitiho/ki-algorithm/blob/master/src/pages/question/%5Bid%5D.vue

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 29.61 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.1/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Safari: 15.4
  npmPackages:
    @vitejs/plugin-vue: ^2.3.1 => 2.3.1 
    vite: ^2.9.1 => 2.9.1

Used Package Manager

pnpm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented May 13, 2022

Duplicate of #6992

@bluwy bluwy marked this as a duplicate of #6992 May 13, 2022
@bluwy bluwy closed this as completed May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants