@primate/core 0.3.3 → 0.3.4

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.
@@ -7,9 +7,11 @@ type Loader = (source: string, file: FileRef) => MaybePromise<string>;
7
7
  type Resolver = (basename: string, file: FileRef) => string;
8
8
  export default class BuildApp extends App {
9
9
  #private;
10
- frontends: Map<string, string>;
10
+ frontends: Map<string, string[]>;
11
+ conditions: Set<string>;
11
12
  buildInit(): Promise<void>;
12
13
  get id(): string;
14
+ get frontendExtensions(): string[];
13
15
  get build(): Build;
14
16
  get server_build(): string[];
15
17
  addRoot(root: FileRef): void;
@@ -8,6 +8,7 @@ import cache from "@rcompat/kv/cache";
8
8
  const s = Symbol("primate.Build");
9
9
  export default class BuildApp extends App {
10
10
  frontends = new Map();
11
+ conditions = new Set();
11
12
  #postbuild = [];
12
13
  #roots = [];
13
14
  #server_build = ["route"];
@@ -20,8 +21,12 @@ export default class BuildApp extends App {
20
21
  get id() {
21
22
  return this.#id;
22
23
  }
24
+ get frontendExtensions() {
25
+ return [...this.frontends.values()].flat();
26
+ }
23
27
  get build() {
24
- const extensions = [...this.frontends.values()];
28
+ const extensions = this.frontendExtensions;
29
+ const conditions = this.conditions.values();
25
30
  return cache.get(s, () => new Build({
26
31
  ...(this.config("build")),
27
32
  outdir: this.runpath(location.client).path,
@@ -29,7 +34,7 @@ export default class BuildApp extends App {
29
34
  contents: "",
30
35
  resolveDir: this.root.path,
31
36
  },
32
- conditions: ["style", "browser", "default", "module"],
37
+ conditions: ["style", "browser", "default", "module", ...conditions],
33
38
  resolveExtensions: [".ts", ".js", ...extensions],
34
39
  tsconfigRaw: {
35
40
  compilerOptions: {
@@ -29,6 +29,7 @@ export default abstract class FrontendModule<S = ServerView> extends Module {
29
29
  css?: {
30
30
  filter: RegExp;
31
31
  };
32
+ conditions: string[];
32
33
  static schema: import("pema").ObjectType<{
33
34
  fileExtensions: import("pema").OptionalType<import("pema/array").ArrayType<import("pema/string").StringType>>;
34
35
  spa: import("pema").DefaultType<import("pema/boolean").BooleanType, true>;
@@ -23,6 +23,7 @@ export default class FrontendModule extends Module {
23
23
  root;
24
24
  compile = {};
25
25
  css;
26
+ conditions = [];
26
27
  static schema = pema({
27
28
  fileExtensions: array(string).optional(),
28
29
  spa: boolean.default(true),
@@ -147,9 +148,10 @@ export default class FrontendModule extends Module {
147
148
  }
148
149
  publish(app) {
149
150
  if (this.compile.client) {
150
- const { compile, css, fileExtensions, name, root } = this;
151
+ const { compile, css, fileExtensions, name, root, conditions } = this;
151
152
  if (this.client) {
152
- fileExtensions.forEach(fe => app.frontends.set(name, fe));
153
+ app.frontends.set(name, fileExtensions);
154
+ conditions.forEach(condition => app.conditions.add(condition));
153
155
  }
154
156
  app.build.plugin({
155
157
  name,
@@ -225,6 +227,7 @@ export default class FrontendModule extends Module {
225
227
  extensions: this.fileExtensions,
226
228
  compile: async (s, f) => this.compile.server(s, f),
227
229
  bundle: app.config("bundle"),
230
+ conditions: [...app.conditions],
228
231
  });
229
232
  return bundled;
230
233
  }
@@ -6,6 +6,7 @@ type Init = {
6
6
  extensions: string[];
7
7
  compile: (src: string, file?: FileRef) => Promise<string>;
8
8
  bundle: string[];
9
+ conditions: string[];
9
10
  };
10
11
  export default function bundle_server(init: Init): Promise<string>;
11
12
  export {};
@@ -32,7 +32,7 @@ export default async function bundle_server(init) {
32
32
  platform: "node",
33
33
  format: "esm",
34
34
  target: "esnext",
35
- conditions: ["node", "default", "apekit"],
35
+ conditions: ["node", "default", ...init.conditions],
36
36
  resolveExtensions: [".ts", ".js", ...extensions],
37
37
  plugins: [plugin],
38
38
  stdin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",