@bakery-framework/plugin-vue 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/compile.ts +8 -9
- package/src/handler.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakery-framework/plugin-vue",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Bakery vue plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bakery",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vue": "^3.5.38"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@bakery-framework/core": "^2.2.
|
|
46
|
+
"@bakery-framework/core": "^2.2.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"bun": ">=1.4.0"
|
package/src/compile.ts
CHANGED
|
@@ -138,15 +138,14 @@ export async function compileScriptBlock(
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
// The blocks go to Vue as written, TypeScript included: `compileScript`
|
|
142
|
+
// reads TypeScript, and `compileText` below takes the types out of what it
|
|
143
|
+
// returns. A plain `<script lang="ts">` beside `<script setup>` used to be
|
|
144
|
+
// transpiled first and written back into `descriptor.script.content`, but
|
|
145
|
+
// Vue edits the whole file by the block's original offsets, so a rewritten
|
|
146
|
+
// block put its edits in the wrong places: an `export default` of options
|
|
147
|
+
// came out as `returnconst __default__ = MIT)` over the lines around it,
|
|
148
|
+
// and the module failed to parse.
|
|
150
149
|
const { compileScript } = await loadCompiler()
|
|
151
150
|
const result = compileScript(descriptor, {
|
|
152
151
|
id,
|
package/src/handler.ts
CHANGED
|
@@ -351,11 +351,17 @@ export async function componentScript(options: {
|
|
|
351
351
|
code = code.replace(RX_SERVER_DATA_TOKEN, () => serverData)
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
// One element per component, holding every block, joined as `componentCss`
|
|
355
|
+
// joins them for a page. The element is per component so a module evaluated
|
|
356
|
+
// again replaces its styles rather than stacking a second copy; writing each
|
|
357
|
+
// block into it in turn, as this did, kept only the last block.
|
|
354
358
|
if (!isRootScript) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
+
const css = compiled.styles
|
|
360
|
+
.map(style => style.code)
|
|
361
|
+
.filter(Boolean)
|
|
362
|
+
.join('\n\n')
|
|
363
|
+
if (css) {
|
|
364
|
+
code += `;\n(function(){var k='__vu_css_${id}';var s=document.getElementById(k)||(function(){var el=document.createElement('style');el.id=k;document.head.appendChild(el);return el})();s.textContent=${JSON.stringify(css)}})()`
|
|
359
365
|
}
|
|
360
366
|
}
|
|
361
367
|
|