@rpcbase/vite 0.115.0 → 0.116.0
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
CHANGED
|
@@ -300,8 +300,17 @@ function inferIsSsrTransform(transformOptions) {
|
|
|
300
300
|
if (!transformOptions || typeof transformOptions !== "object") return false;
|
|
301
301
|
return transformOptions.ssr === true;
|
|
302
302
|
}
|
|
303
|
+
function isPrunableModelsFilePath(filePath) {
|
|
304
|
+
const normalized = filePath.replaceAll("\\", "/");
|
|
305
|
+
const parts = normalized.split("/");
|
|
306
|
+
if (parts.includes("node_modules")) return false;
|
|
307
|
+
if (parts.length < 2) return false;
|
|
308
|
+
if (!parts.some((part, index) => part === "models" && index < parts.length - 1)) return false;
|
|
309
|
+
if (normalized.endsWith(".d.ts")) return false;
|
|
310
|
+
const ext = path$1.posix.extname(normalized);
|
|
311
|
+
return ext === ".ts" || ext === ".tsx" || ext === ".mts" || ext === ".cts";
|
|
312
|
+
}
|
|
303
313
|
function pruneModelsForClientPlugin() {
|
|
304
|
-
const modelsDir = `${path$1.resolve(process.cwd(), "src/models")}${path$1.sep}`;
|
|
305
314
|
const prune = createTransformSource();
|
|
306
315
|
return {
|
|
307
316
|
name: "lz-models-prune-for-browser",
|
|
@@ -309,7 +318,7 @@ function pruneModelsForClientPlugin() {
|
|
|
309
318
|
transform(code, id, transformOptions) {
|
|
310
319
|
if (inferIsSsrTransform(transformOptions)) return;
|
|
311
320
|
const filePath = id.split("?", 1)[0] ?? id;
|
|
312
|
-
if (!filePath
|
|
321
|
+
if (!isPrunableModelsFilePath(filePath)) return;
|
|
313
322
|
const nextCode = prune({ code, filePath });
|
|
314
323
|
if (!nextCode) return;
|
|
315
324
|
return { code: nextCode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/prune-models-for-client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/prune-models-for-client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA2BlC,wBAAgB,0BAA0B,IAAI,MAAM,CAiBnD"}
|