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

Vue mode exposes build environment file path #492

Open
metzg opened this issue May 19, 2024 · 0 comments
Open

Vue mode exposes build environment file path #492

metzg opened this issue May 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@metzg
Copy link

metzg commented May 19, 2024

hi,

Thank you for the useful plugin.

When using Vue, the hmrId property in the compiled code is still present when building for production, and contains the full path of the source markdown file, adding extra bytes of payload and possibly exposing internal information.

Relevant line in the source code:

content.addContext(compiledVueCode.replace('\nexport function render(', '\nfunction vueRender(') + `\nconst VueComponent = { render: vueRender }\nVueComponent.__hmrId = ${JSON.stringify(id)}\nconst VueComponentWith = (components) => ({ components, render: vueRender })\n`)

Production build result (line breaks added for readability):

import{o as i,c as n,F as a,a as e}from"./index-C12kFbxv.js";const m={title:"Hello world"},l=e("h1",null,"Hello world",-1),r=e("p",null,"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",-1),u=e("p",null,[e("img",{src:"favicon.ico",alt:"hi"})],-1);function o(t,s){return i(),n(a,null,[l,r,u],64)}const c={render:o};
c.__hmrId="/home/will/playground/md-test/src/content/blog/hello.md";
const p=t=>({components:t,render:o});export{c as VueComponent,p as VueComponentWith,m as attributes};

If I understand this right, the hmr id could be removed when there is no hmr by checking for import.meta.hot.

@hmsk hmsk added the bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants