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
hmr: vue sfc update not using pug extractor #66
Comments
Okay after doing some tracing it looks like the pug extractor is not actually running when the SFC is changed so it doesn't find the proper token.
On -.i-mdi-close.ml-1.text-grey-300.hover_text-grey-500
+.i-mdi-close-box.ml-1.text-grey-300.hover_text-grey-500
(but no uno pug compile line) Oh! might just be the regex in pug extractor -- So that is one part of the issue, but then the other part is because plugin-vue just emits the template with that query string... |
So I'm not familiar enough with |
I don't have a repo to play with, tried to fix it on 3d308a8, can you verify if it works for you? Thanks |
It just emits the raw pug (template section of the sfc) so i'm not sure this will work because |
Also there might be something wrong with the npm publishing? built |
test % npm init -y
Wrote to /private/tmp/test/package.json:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
tj@tjk-mbp test % npm install --save @unocss/extractor-pug@0.6.2
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.
+ @unocss/extractor-pug@0.6.2
added 1 package from 1 contributor and audited 1 package in 0.873s
1 package is looking for funding
run `npm fund` for details
found 0 vulnerabilities
tj@tjk-mbp test % cat node_modules/@unocss/extractor-pug/dist/index.js
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
var regexVueTemplate = /<template.*?lang=['"]pug['"][^>]*?>\n([\s\S]*?\n)<\/template>/gm;
function extractorPug() {
async function compile(code, id) {
const Pug = await Promise.resolve().then(() => require("pug"));
try {
return Pug.compile(code, { filename: id })();
} catch (e) {
}
}
return {
name: "pug",
order: -1,
async extract(ctx) {
var _a, _b, _c;
if ((_b = ctx.id) == null ? void 0 : _b.match(/\.vue$/)) { |
Oh you have a syntax error I believe in that patch! - if (ctx.id?.match(/\.vue$/ || ctx.id?.match(/\.vue\?vue/))) {
+ if (ctx.id?.match(/\.vue$/) || ctx.id?.match(/\.vue\?vue/)) { EDIT: Why doesn't EDIT 2: it was valid syntax just surprised typescript would not complain... maybe it detects the |
Pug support is very needed. I'm not skilled enough to contribute code, but I hope @tjk can figure it out soon. Thank you for the struggle! |
Amazing!! I was starting on this patch... but taking it real slow. Thank you @antfu |
EDIT: See latest comment with tracing in second comment.
I can put together a minimal repro later unless this is expected?(Refresh fixes the issue -- my stack is loosely based off
vite/packages/playground/ssr-vue
)The text was updated successfully, but these errors were encountered: