@primate/core 0.7.0 → 0.7.2

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,
@@ -52,6 +52,7 @@ export default async function build_server(app) {
52
52
  entryPoints: [app.path.build.join("serve.js").path],
53
53
  outfile: app.path.build.join("server.js").path,
54
54
  bundle: true,
55
+ minify: app.mode === "production",
55
56
  platform: "node",
56
57
  format: "esm",
57
58
  packages: app.mode === "development" ? "external" : undefined,
@@ -60,10 +61,7 @@ export default async function build_server(app) {
60
61
  ".json": "json",
61
62
  },
62
63
  banner: {
63
- js: `
64
- import { createRequire as __createRequire } from "node:module";
65
- const require = __createRequire(import.meta.url);
66
- `,
64
+ js: `import { createRequire as __createRequire } from "node:module";const require = __createRequire(import.meta.url);`,
67
65
  },
68
66
  nodePaths: [app.root.join("node_modules").path],
69
67
  resolveExtensions: app.extensions,
@@ -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,4 @@
1
+ import type { FileRef } from "@rcompat/fs";
2
+ import type { OnResolveArgs } from "esbuild";
3
+ export default function intercept(args: OnResolveArgs, views: FileRef): boolean;
4
+ //# sourceMappingURL=intercept.d.ts.map
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",