@primate/core 0.7.0 → 0.7.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import intercept from "#build/shared/intercept";
|
|
1
2
|
import E from "#errors";
|
|
2
3
|
import fs from "@rcompat/fs";
|
|
3
4
|
const body_serializer = {
|
|
@@ -26,6 +27,8 @@ export default function plugin_client_routes(app) {
|
|
|
26
27
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
27
28
|
if (args.pluginData === "primate-client-route-inner")
|
|
28
29
|
return null;
|
|
30
|
+
if (intercept(args, app.path.views))
|
|
31
|
+
return null;
|
|
29
32
|
const result = await build.resolve(args.path, {
|
|
30
33
|
resolveDir: args.resolveDir,
|
|
31
34
|
kind: args.kind,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import intercept from "#build/shared/intercept";
|
|
1
2
|
import fs from "@rcompat/fs";
|
|
2
3
|
const fake_body = {
|
|
3
4
|
"application/json": `{
|
|
@@ -47,10 +48,10 @@ export default function plugin_server_route_client(app) {
|
|
|
47
48
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
48
49
|
if (args.pluginData === "primate-server-route-client-inner")
|
|
49
50
|
return null;
|
|
50
|
-
if (args.namespace === "ignore-failed-check")
|
|
51
|
-
return null;
|
|
52
51
|
if (args.namespace === "primate-server-route-client")
|
|
53
52
|
return null;
|
|
53
|
+
if (intercept(args, app.path.views))
|
|
54
|
+
return null;
|
|
54
55
|
const result = await build.resolve(args.path, {
|
|
55
56
|
resolveDir: args.resolveDir,
|
|
56
57
|
kind: args.kind,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import runtime from "@rcompat/runtime";
|
|
2
|
+
function is_bare(path) {
|
|
3
|
+
return /^[a-z]/.test(path);
|
|
4
|
+
}
|
|
5
|
+
function is_npm_package(path, resolve_dir) {
|
|
6
|
+
if (!path.startsWith("@"))
|
|
7
|
+
return false;
|
|
8
|
+
const parts = path.split("/");
|
|
9
|
+
if (parts.length < 2)
|
|
10
|
+
return false;
|
|
11
|
+
const pkg = parts[0] + "/" + parts[1];
|
|
12
|
+
try {
|
|
13
|
+
runtime.resolve(pkg, resolve_dir);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export default function intercept(args, views) {
|
|
21
|
+
if (!args.resolveDir.startsWith(views.path))
|
|
22
|
+
return true;
|
|
23
|
+
if (is_bare(args.path))
|
|
24
|
+
return true;
|
|
25
|
+
if (is_npm_package(args.path, args.resolveDir))
|
|
26
|
+
return true;
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=intercept.js.map
|