vike 0.4.259-commit-f6ecfb2 → 0.4.260
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.
|
@@ -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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.260";
|
|
@@ -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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.260",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"json5": "^2.0.0",
|
|
140
140
|
"magic-string": "^0.30.17",
|
|
141
141
|
"picomatch": "^4.0.4",
|
|
142
|
-
"semver": "^7.8.
|
|
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",
|