@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.
- package/lib/private/BuildApp.d.ts +3 -1
- package/lib/private/BuildApp.js +7 -2
- package/lib/private/frontend/Module.d.ts +1 -0
- package/lib/private/frontend/Module.js +5 -2
- package/lib/private/frontend/bundle-server.d.ts +1 -0
- package/lib/private/frontend/bundle-server.js +1 -1
- package/package.json +1 -1
|
@@ -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;
|
package/lib/private/BuildApp.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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",
|
|
35
|
+
conditions: ["node", "default", ...init.conditions],
|
|
36
36
|
resolveExtensions: [".ts", ".js", ...extensions],
|
|
37
37
|
plugins: [plugin],
|
|
38
38
|
stdin: {
|