vike 0.4.259-commit-f6ecfb2 → 0.4.260-commit-8a30a91
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/dist/node/vite/plugins/pluginStripPointerImportAttribute.js +31 -10
- package/dist/node/vite/shared/getMagicString.d.ts +1 -1
- package/dist/node/vite/shared/getMagicString.js +3 -0
- package/dist/server/runtime/renderPageServer/html/injectAssets/injectHtmlTags.js +3 -1
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/assertViteVersion.js +1 -1
- package/package.json +10 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { pluginStripPointerImportAttribute };
|
|
2
|
+
import { getImportStatements } from '../shared/parseEsModule.js';
|
|
2
3
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
3
4
|
import '../assertEnvVite.js';
|
|
4
5
|
// Match `with { type: 'vike:pointer' }` (with optional whitespace variations)
|
|
@@ -14,18 +15,38 @@ function pluginStripPointerImportAttribute() {
|
|
|
14
15
|
},
|
|
15
16
|
},
|
|
16
17
|
handler(code, id) {
|
|
17
|
-
|
|
18
|
-
if (!runtimeAttrRE.test(code))
|
|
19
|
-
return;
|
|
20
|
-
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
21
|
-
runtimeAttrRE.lastIndex = 0;
|
|
22
|
-
let match;
|
|
23
|
-
while ((match = runtimeAttrRE.exec(code)) !== null) {
|
|
24
|
-
magicString.remove(match.index, match.index + match[0].length);
|
|
25
|
-
}
|
|
26
|
-
return getMagicStringResult();
|
|
18
|
+
return stripPointerImportAttributes(code, id);
|
|
27
19
|
},
|
|
28
20
|
},
|
|
29
21
|
},
|
|
30
22
|
];
|
|
31
23
|
}
|
|
24
|
+
async function stripPointerImportAttributes(code, id) {
|
|
25
|
+
// Fast path: skip parsing when there is nothing to strip
|
|
26
|
+
runtimeAttrRE.lastIndex = 0;
|
|
27
|
+
if (!runtimeAttrRE.test(code))
|
|
28
|
+
return;
|
|
29
|
+
// Restrict stripping to genuine `import` statements, so that we don't touch occurrences
|
|
30
|
+
// inside string literals/comments (e.g. documentation code examples).
|
|
31
|
+
// https://github.com/brillout/docpress/issues/167
|
|
32
|
+
let importStatements;
|
|
33
|
+
try {
|
|
34
|
+
importStatements = await getImportStatements(code);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Not parsable as an ES module (e.g. a raw Markdown file) => leave it untouched
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
41
|
+
for (const { ss, se } of importStatements)
|
|
42
|
+
stripAttribute(magicString, code, ss, se);
|
|
43
|
+
return getMagicStringResult();
|
|
44
|
+
}
|
|
45
|
+
function stripAttribute(magicString, code, start, end) {
|
|
46
|
+
const region = code.slice(start, end);
|
|
47
|
+
runtimeAttrRE.lastIndex = 0;
|
|
48
|
+
let match;
|
|
49
|
+
while ((match = runtimeAttrRE.exec(region)) !== null) {
|
|
50
|
+
magicString.remove(start + match.index, start + match.index + match[0].length);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -9,6 +9,9 @@ function getMagicString(code, id) {
|
|
|
9
9
|
return undefined;
|
|
10
10
|
return {
|
|
11
11
|
code: magicString.toString(),
|
|
12
|
+
// magic-string@1's SourceMap.sourcesContent is typed as (string | null)[], whereas Rollup's
|
|
13
|
+
// ExistingRawSourceMap expects string[]. We never pass `includeContent`, so sourcesContent is
|
|
14
|
+
// always undefined at runtime and this cast is safe.
|
|
12
15
|
map: magicString.generateMap({ hires: true, source: id }),
|
|
13
16
|
};
|
|
14
17
|
};
|
|
@@ -99,7 +99,9 @@ function injectBreakLines(htmlFragment, before, after) {
|
|
|
99
99
|
const whitespaceExtra = paddingParent ? ' ' : '';
|
|
100
100
|
const whitespace = `${paddingParent}${whitespaceExtra}`;
|
|
101
101
|
const padding = `\n${whitespace}`;
|
|
102
|
-
|
|
102
|
+
// Match whole tags, and whole raw text elements (their content isn't markup): injecting a line break inside `<script>document.write('<div>')</script>` or inside an attribute value would corrupt it. https://github.com/vikejs/vike/issues/3457
|
|
103
|
+
const tagRE = /<(script|style|textarea|title)\b[^>]*>[\s\S]*?<\/\1>|<[^\/][^>]*>/gi;
|
|
104
|
+
htmlFragment = htmlFragment.replace(tagRE, (match) => `${padding}${match}`);
|
|
103
105
|
if (isBlankLine) {
|
|
104
106
|
assert(htmlFragment.startsWith(padding), { htmlFragment });
|
|
105
107
|
htmlFragment = whitespaceExtra + htmlFragment.slice(padding.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.260-commit-8a30a91";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.260-commit-8a30a91';
|
|
@@ -2,7 +2,7 @@ export { assertViteVersion };
|
|
|
2
2
|
export { viteVersionMin };
|
|
3
3
|
import { assertVersion } from './assertVersion.js';
|
|
4
4
|
const viteVersionMin = '6.3.0';
|
|
5
|
-
//
|
|
5
|
+
// package.json#peerDependencies isn't enough, as users often ignore it
|
|
6
6
|
function assertViteVersion(viteVersion) {
|
|
7
7
|
// - This assertion isn't reliable: the user may still use a Vite version older than 6.0.0 — see https://github.com/vitejs/vite/pull/19355
|
|
8
8
|
// - TO-DO/eventually: let's also use this.meta.viteVersion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.260-commit-8a30a91",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -128,23 +128,23 @@
|
|
|
128
128
|
"@brillout/json-serializer": "^0.5.25",
|
|
129
129
|
"@brillout/picocolors": "^1.0.31",
|
|
130
130
|
"@brillout/vite-plugin-server-entry": "0.7.19",
|
|
131
|
-
"@universal-deploy/store": "^0.2.
|
|
132
|
-
"@universal-deploy/vite": "^0.1.
|
|
131
|
+
"@universal-deploy/store": "^0.2.2",
|
|
132
|
+
"@universal-deploy/vite": "^0.1.11",
|
|
133
133
|
"@universal-middleware/core": "^0.4.18",
|
|
134
|
-
"@universal-middleware/node": "^0.2.
|
|
134
|
+
"@universal-middleware/node": "^0.2.2",
|
|
135
135
|
"cac": "^6.0.0",
|
|
136
136
|
"convert-route": "^1.1.1",
|
|
137
137
|
"es-module-lexer": "^1.0.0",
|
|
138
138
|
"esbuild": ">=0.19.0",
|
|
139
139
|
"json5": "^2.0.0",
|
|
140
|
-
"magic-string": "^
|
|
141
|
-
"picomatch": "^4.0.
|
|
142
|
-
"semver": "^7.8.
|
|
140
|
+
"magic-string": "^1.1.0",
|
|
141
|
+
"picomatch": "^4.0.5",
|
|
142
|
+
"semver": "^7.8.5",
|
|
143
143
|
"sirv": "^3.0.2",
|
|
144
144
|
"source-map-support": "^0.5.0",
|
|
145
145
|
"tinyglobby": "^0.2.17",
|
|
146
146
|
"vite": ">=6.3.0",
|
|
147
|
-
"vite-plugin-wrapper": "^0.1.
|
|
147
|
+
"vite-plugin-wrapper": "^0.1.1"
|
|
148
148
|
},
|
|
149
149
|
"peerDependencies": {
|
|
150
150
|
"react-streaming": ">=0.3.42",
|
|
@@ -259,11 +259,11 @@
|
|
|
259
259
|
"./fetch.js"
|
|
260
260
|
],
|
|
261
261
|
"devDependencies": {
|
|
262
|
-
"@brillout/release-me": "^0.4.
|
|
262
|
+
"@brillout/release-me": "^0.4.16",
|
|
263
263
|
"@types/babel__core": "^7.20.5",
|
|
264
264
|
"@types/estree": "^1.0.5",
|
|
265
265
|
"@types/node": "^20.10.5",
|
|
266
|
-
"@types/picomatch": "^4.0.
|
|
266
|
+
"@types/picomatch": "^4.0.3",
|
|
267
267
|
"@types/semver": "^7.7.1",
|
|
268
268
|
"@types/source-map-support": "^0.5.10",
|
|
269
269
|
"react-streaming": "^0.4.20",
|