@vizejs/vite-plugin 0.0.1-alpha.69 → 0.0.1-alpha.71
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/index.js +7 -29
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { glob } from "tinyglobby";
|
|
4
|
-
import
|
|
4
|
+
import * as native from "@vizejs/native";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
|
|
7
7
|
//#region src/hmr.ts
|
|
@@ -118,35 +118,12 @@ ${output}`;
|
|
|
118
118
|
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/compiler.ts
|
|
121
|
-
const
|
|
122
|
-
let compileSfc = null;
|
|
123
|
-
let compileSfcBatchWithResults = null;
|
|
124
|
-
function loadNative() {
|
|
125
|
-
if (compileSfc) return compileSfc;
|
|
126
|
-
try {
|
|
127
|
-
const native = require("@vizejs/native");
|
|
128
|
-
compileSfc = native.compileSfc;
|
|
129
|
-
return compileSfc;
|
|
130
|
-
} catch (e) {
|
|
131
|
-
throw new Error(`Failed to load @vizejs/native. Make sure it's installed and built:\n${String(e)}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function loadNativeBatch() {
|
|
135
|
-
if (compileSfcBatchWithResults) return compileSfcBatchWithResults;
|
|
136
|
-
try {
|
|
137
|
-
const native = require("@vizejs/native");
|
|
138
|
-
compileSfcBatchWithResults = native.compileSfcBatchWithResults;
|
|
139
|
-
return compileSfcBatchWithResults;
|
|
140
|
-
} catch (e) {
|
|
141
|
-
throw new Error(`Failed to load @vizejs/native. Make sure it's installed and built:\n${String(e)}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
121
|
+
const { compileSfc, compileSfcBatchWithResults } = native;
|
|
144
122
|
function compileFile(filePath, cache, options, source) {
|
|
145
|
-
const compile = loadNative();
|
|
146
123
|
const content = source ?? fs.readFileSync(filePath, "utf-8");
|
|
147
124
|
const scopeId = generateScopeId(filePath);
|
|
148
125
|
const hasScoped = /<style[^>]*\bscoped\b/.test(content);
|
|
149
|
-
const result =
|
|
126
|
+
const result = compileSfc(content, {
|
|
150
127
|
filename: filePath,
|
|
151
128
|
sourceMap: options.sourceMap,
|
|
152
129
|
ssr: options.ssr,
|
|
@@ -173,12 +150,11 @@ function compileFile(filePath, cache, options, source) {
|
|
|
173
150
|
* Returns per-file results with content hashes for HMR.
|
|
174
151
|
*/
|
|
175
152
|
function compileBatch(files, cache, options) {
|
|
176
|
-
const compile = loadNativeBatch();
|
|
177
153
|
const inputs = files.map((f) => ({
|
|
178
154
|
path: f.path,
|
|
179
155
|
source: f.source
|
|
180
156
|
}));
|
|
181
|
-
const result =
|
|
157
|
+
const result = compileSfcBatchWithResults(inputs, { ssr: options.ssr });
|
|
182
158
|
for (const fileResult of result.results) {
|
|
183
159
|
if (fileResult.errors.length === 0) cache.set(fileResult.path, {
|
|
184
160
|
code: fileResult.code,
|
|
@@ -306,9 +282,11 @@ function vize(options = {}) {
|
|
|
306
282
|
else if (id.startsWith("/") && !fs.existsSync(id)) resolved = path.resolve(root, id.slice(1));
|
|
307
283
|
else if (path.isAbsolute(id)) resolved = id;
|
|
308
284
|
else if (importer) {
|
|
309
|
-
|
|
285
|
+
let realImporter = importer.startsWith(VIRTUAL_PREFIX) ? virtualToReal.get(importer) ?? importer.slice(VIRTUAL_PREFIX.length) : importer;
|
|
286
|
+
if (realImporter.endsWith(".vue.ts")) realImporter = realImporter.slice(0, -3);
|
|
310
287
|
resolved = path.resolve(path.dirname(realImporter), id);
|
|
311
288
|
} else resolved = path.resolve(root, id);
|
|
289
|
+
if (!path.isAbsolute(resolved)) resolved = path.resolve(root, resolved);
|
|
312
290
|
return path.normalize(resolved);
|
|
313
291
|
}
|
|
314
292
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.71",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"provenance": true,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"tinyglobby": "^0.2.0",
|
|
47
|
-
"@vizejs/native": "0.0.1-alpha.
|
|
47
|
+
"@vizejs/native": "0.0.1-alpha.71"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown",
|