reactivated 0.35.0 → 0.36.0-a1901
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/build.client.mjs +11 -5
- package/dist/build.client.mjs.map +1 -1
- package/dist/build.renderer.mjs +8 -4
- package/dist/build.renderer.mjs.map +1 -1
- package/dist/conf.d.ts +20 -0
- package/dist/conf.js +12 -0
- package/dist/conf.js.map +1 -0
- package/dist/eslintrc.js +0 -5
- package/dist/eslintrc.js.map +1 -1
- package/dist/generator.mjs +20 -0
- package/dist/generator.mjs.map +1 -1
- package/dist/renderer.js +14 -7
- package/dist/renderer.js.map +1 -1
- package/package.json +3 -12
- package/src/build.client.mts +63 -45
- package/src/build.renderer.mts +55 -38
- package/src/conf.tsx +23 -0
- package/src/eslintrc.tsx +0 -5
- package/src/generator.mts +21 -0
- package/src/renderer.tsx +22 -8
- package/dist/linaria.d.mts +0 -14
- package/dist/linaria.mjs +0 -122
- package/dist/linaria.mjs.map +0 -1
- package/src/linaria.mts +0 -168
package/dist/build.client.mjs
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import linaria from "./linaria.mjs";
|
|
3
2
|
import { vanillaExtractPlugin } from "@vanilla-extract/esbuild-plugin";
|
|
4
3
|
import * as esbuild from "esbuild";
|
|
5
4
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
5
|
+
import { produce } from "immer";
|
|
6
6
|
const entryNames = process.argv.slice(2);
|
|
7
7
|
const entryPoints = Object.fromEntries(entryNames.map((entry) => [entry, `./client/${entry}.tsx`]));
|
|
8
8
|
const production = process.env.NODE_ENV === "production";
|
|
9
9
|
const identifiers = production ? "short" : "debug";
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const customConfigurationImport = await import(`${process.cwd()}/node_modules/_reactivated/conf.mjs`);
|
|
12
|
+
const getOptions = customConfigurationImport?.default?.build?.client != null
|
|
13
|
+
? customConfigurationImport.default.build.client
|
|
14
|
+
: (options) => { };
|
|
10
15
|
const env = {
|
|
11
16
|
NODE_ENV: production ? "production" : "development",
|
|
12
17
|
BUILD_VERSION: process.env.BUILD_VERSION,
|
|
13
18
|
TAG_VERSION: process.env.TAG_VERSION,
|
|
14
19
|
};
|
|
15
20
|
esbuild
|
|
16
|
-
.context({
|
|
21
|
+
.context(produce({
|
|
17
22
|
entryPoints,
|
|
18
23
|
bundle: true,
|
|
19
24
|
// We use terser to minify because esbuild breaks safari sourcemaps.
|
|
@@ -30,7 +35,9 @@ esbuild
|
|
|
30
35
|
define: {
|
|
31
36
|
// You need both. The one from the stringified JSON is not picked
|
|
32
37
|
// up during the build process.
|
|
33
|
-
"process.env.NODE_ENV": production
|
|
38
|
+
"process.env.NODE_ENV": production
|
|
39
|
+
? '"production"'
|
|
40
|
+
: '"development"',
|
|
34
41
|
process: JSON.stringify({ env }),
|
|
35
42
|
// Redux persist needs this.
|
|
36
43
|
global: "{}",
|
|
@@ -54,9 +61,8 @@ esbuild
|
|
|
54
61
|
// Instead of set it manually instead of relying on minification
|
|
55
62
|
// settings.
|
|
56
63
|
vanillaExtractPlugin({ identifiers }),
|
|
57
|
-
linaria({ sourceMap: true, esbuildOptions: { sourcemap: "inline" } }),
|
|
58
64
|
],
|
|
59
|
-
})
|
|
65
|
+
}, (draftState) => getOptions(draftState)))
|
|
60
66
|
.then(async (context) => {
|
|
61
67
|
if (production === false) {
|
|
62
68
|
context.watch();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.client.mjs","sourceRoot":"","sources":["../src/build.client.mts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"build.client.mjs","sourceRoot":"","sources":["../src/build.client.mts"],"names":[],"mappings":";AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC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B,gBAAgB,EAAE,IAAI;IACtB,QAAQ,EAAE,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAChD,MAAM,EAAE;QACJ,iEAAiE;QACjE,+BAA+B;QAC/B,sBAAsB,EAAE,UAAU;YAC9B,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,eAAe;QACrB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,GAAG,EAAC,CAAC;QAE9B,4BAA4B;QAC5B,MAAM,EAAE,IAAI;KACf;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,MAAM;KACnB;IACD,OAAO,EAAE;QACL,+BAA+B;QAE3B,gBACH,CAAC,OAAO,EAAE;QACX,4DAA4D;QAC5D,gEAAgE;QAChE,UAAU;QACV,gEAAgE;QAChE,YAAY;QACZ,oBAAoB,CAAC,EAAC,WAAW,EAAC,CAAC;KACtC;CACJ,EACD,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CACzC,CACJ;KACA,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,UAAU,KAAK,KAAK,EAAE;QACtB,OAAO,CAAC,KAAK,EAAE,CAAC;KACnB;SAAM;QACH,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,EAAE,CAAC;KAClB;AACL,CAAC,CAAC,CAAC"}
|
package/dist/build.renderer.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import linaria from "./linaria.mjs";
|
|
3
2
|
import { vanillaExtractPlugin } from "@vanilla-extract/esbuild-plugin";
|
|
4
3
|
import * as esbuild from "esbuild";
|
|
5
4
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
6
5
|
import path from "path";
|
|
7
6
|
import { createRequire } from "module";
|
|
7
|
+
import { produce } from "immer";
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const customConfigurationImport = await import(`${process.cwd()}/node_modules/_reactivated/conf.mjs`);
|
|
8
10
|
let server = null;
|
|
9
11
|
const CACHE_KEY = `${process.cwd()}/node_modules/_reactivated/renderer.js`;
|
|
10
12
|
const production = process.env.NODE_ENV === "production";
|
|
@@ -19,8 +21,11 @@ const restartServer = async () => {
|
|
|
19
21
|
delete require.cache[CACHE_KEY];
|
|
20
22
|
server = require(CACHE_KEY).server;
|
|
21
23
|
};
|
|
24
|
+
const getOptions = customConfigurationImport?.default?.build?.renderer != null
|
|
25
|
+
? customConfigurationImport.default.build.renderer
|
|
26
|
+
: (options) => { };
|
|
22
27
|
esbuild
|
|
23
|
-
.context({
|
|
28
|
+
.context(produce({
|
|
24
29
|
stdin: {
|
|
25
30
|
contents: `
|
|
26
31
|
export {server, currentTime} from "reactivated/dist/renderer";
|
|
@@ -48,7 +53,6 @@ esbuild
|
|
|
48
53
|
// Instead of set it manually instead of relying on minification
|
|
49
54
|
// settings.
|
|
50
55
|
vanillaExtractPlugin({ identifiers }),
|
|
51
|
-
linaria({ sourceMap: true }),
|
|
52
56
|
{
|
|
53
57
|
name: "restartServer",
|
|
54
58
|
setup: (build) => {
|
|
@@ -60,7 +64,7 @@ esbuild
|
|
|
60
64
|
},
|
|
61
65
|
},
|
|
62
66
|
],
|
|
63
|
-
})
|
|
67
|
+
}, (draftState) => getOptions(draftState)))
|
|
64
68
|
.then(async (context) => {
|
|
65
69
|
if (production === false) {
|
|
66
70
|
context.watch();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.renderer.mjs","sourceRoot":"","sources":["../src/build.renderer.mts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"build.renderer.mjs","sourceRoot":"","sources":["../src/build.renderer.mts"],"names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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BuildOptions } from "esbuild";
|
|
3
|
+
export type Options = {
|
|
4
|
+
build?: {
|
|
5
|
+
client?: (options: BuildOptions) => void;
|
|
6
|
+
renderer?: (options: BuildOptions) => void;
|
|
7
|
+
};
|
|
8
|
+
render?: (content: JSX.Element) => Promise<JSX.Element>;
|
|
9
|
+
};
|
|
10
|
+
export declare const configure: (options: Options) => Options;
|
|
11
|
+
declare const _default: (customConfigurationImport: {
|
|
12
|
+
default?: Options;
|
|
13
|
+
} | null) => {
|
|
14
|
+
build: {
|
|
15
|
+
client: (options: BuildOptions) => void;
|
|
16
|
+
renderer: (options: BuildOptions) => void;
|
|
17
|
+
};
|
|
18
|
+
render: (content: JSX.Element) => Promise<JSX.Element>;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
package/dist/conf.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const configure = (options) => options;
|
|
2
|
+
export default (customConfigurationImport) => {
|
|
3
|
+
const customConfiguration = customConfigurationImport?.default ?? {};
|
|
4
|
+
return {
|
|
5
|
+
build: {
|
|
6
|
+
client: customConfiguration.build?.client ?? ((options) => { }),
|
|
7
|
+
renderer: customConfiguration.build?.renderer ?? ((options) => { }),
|
|
8
|
+
},
|
|
9
|
+
render: customConfiguration.render ?? ((content) => Promise.resolve(content)),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=conf.js.map
|
package/dist/conf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conf.js","sourceRoot":"","sources":["../src/conf.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC;AAEvD,eAAe,CAAC,yBAAqD,EAAE,EAAE;IACrE,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,OAAO,IAAI,EAAE,CAAC;IAErE,OAAO;QACH,KAAK,EAAE;YACH,MAAM,EAAE,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,GAAE,CAAC,CAAC;YAC9D,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,QAAQ,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,GAAE,CAAC,CAAC;SACrE;QACD,MAAM,EAAE,mBAAmB,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KAC9D,CAAC;AACxB,CAAC,CAAC"}
|
package/dist/eslintrc.js
CHANGED
package/dist/eslintrc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintrc.js","sourceRoot":"","sources":["../src/eslintrc.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACX,OAAO,EAAE,CAAC,iBAAiB,CAAC;KAC/B;IACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,CAAC;IACjD,QAAQ,EAAE;QACN,KAAK,EAAE;YACH,OAAO,EAAE,QAAQ;SACpB;QACD,iBAAiB,EAAE,YAAY;KAClC;IACD,KAAK,EAAE;QACH,cAAc,EAAE,CAAC,OAAO,EAAE,EAAC,qBAAqB,EAAE,IAAI,EAAC,CAAC;QAExD,kCAAkC;QAClC,kBAAkB,EAAE,CAAC;QACrB,cAAc,EAAE,CAAC;QACjB,sBAAsB,EAAE,CAAC;QAEzB,gEAAgE;QAChE,wDAAwD;QACxD,4BAA4B,EAAE,CAAC;QAC/B,mCAAmC,EAAE,CAAC;QAEtC,6BAA6B,EAAE,CAAC,OAAO,CAAC;QACxC,cAAc,EAAE,CAAC,OAAO,CAAC;QACzB,cAAc,EAAE;YACZ,OAAO;YACP;gBACI,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sBAAsB;QACtB,wBAAwB;KAC3B;CACJ,CAAC"}
|
package/dist/generator.mjs
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "fs";
|
|
3
|
+
import * as esbuild from "esbuild";
|
|
4
|
+
import path from "path";
|
|
3
5
|
// Must be above the compile import as get-stdin used by
|
|
4
6
|
// json-schema-to-typescript messes up the descriptor even if unused.
|
|
5
7
|
const stdinBuffer = fs.readFileSync(0);
|
|
6
8
|
const { compile } = await import("json-schema-to-typescript");
|
|
7
9
|
import { Project, Scope, StructureKind, VariableDeclarationKind, Writers, } from "ts-morph";
|
|
10
|
+
const CONF_INPUT_FILE = "./client/reactivated.config.tsx";
|
|
11
|
+
const CONF_OUTPUT_FILE = "./node_modules/_reactivated/conf.mjs";
|
|
12
|
+
if (fs.existsSync(CONF_INPUT_FILE)) {
|
|
13
|
+
await esbuild.build({
|
|
14
|
+
entryPoints: [CONF_INPUT_FILE],
|
|
15
|
+
bundle: false,
|
|
16
|
+
outfile: CONF_OUTPUT_FILE,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
fs.mkdirSync(path.dirname(CONF_OUTPUT_FILE), { recursive: true });
|
|
21
|
+
fs.writeFileSync(CONF_OUTPUT_FILE, "");
|
|
22
|
+
}
|
|
8
23
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
9
24
|
const { urls: possibleEmptyUrls, templates, interfaces, rpc: uncastedRpc, types, values, } = schema;
|
|
10
25
|
const rpc = uncastedRpc;
|
|
@@ -213,6 +228,7 @@ if (Object.keys(urls).length !== 0) {
|
|
|
213
228
|
}
|
|
214
229
|
sourceFile.addStatements("export type UUID = `${string}-${string}-${string}-${string}-${string}`;");
|
|
215
230
|
sourceFile.addStatements(`
|
|
231
|
+
export {configure} from "reactivated/dist/conf";
|
|
216
232
|
export const rpc = new RPC(typeof window != "undefined" ? rpcUtils.defaultRequester : null as any);
|
|
217
233
|
import React from "react"
|
|
218
234
|
import createContext from "reactivated/dist/context";
|
|
@@ -222,6 +238,10 @@ import * as rpcUtils from "reactivated/dist/rpc";
|
|
|
222
238
|
import {constants} from "./constants";
|
|
223
239
|
export {constants};
|
|
224
240
|
|
|
241
|
+
export function classNames(...classes: (string | undefined | null | false)[]) {
|
|
242
|
+
return classes.filter(Boolean).join(" ");
|
|
243
|
+
}
|
|
244
|
+
|
|
225
245
|
// Note: this needs strict function types to behave correctly with excess properties etc.
|
|
226
246
|
export type Checker<P, U extends (React.FunctionComponent<P> | React.ComponentClass<P>)> = {};
|
|
227
247
|
|
package/dist/generator.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.mjs","sourceRoot":"","sources":["../src/generator.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.mjs","sourceRoot":"","sources":["../src/generator.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE5D,OAAO,EAEH,OAAO,EACP,KAAK,EAEL,aAAa,EAEb,uBAAuB,EAEvB,OAAO,GAQV,MAAM,UAAU,CAAC;AAElB,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAC1D,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAEhE,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;IAChC,MAAM,OAAO,CAAC,KAAK,CAAC;QAChB,WAAW,EAAE,CAAC,eAAe,CAAC;QAC9B,MAAM,EAAE,KAAK;QACb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;kBAGtD,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;SACF;KACJ;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;QACxC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,UAAU,CAAC,IAAI,CAAC;;;kBAGN,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;KACN;IAED,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAErC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
package/dist/renderer.js
CHANGED
|
@@ -36,23 +36,30 @@ export const renderPage = ({ html, helmet, context, props, }) => {
|
|
|
36
36
|
};
|
|
37
37
|
const PATHS = ["/", "/form/"];
|
|
38
38
|
export const render = async ({ context, props, }) => {
|
|
39
|
+
const defaultConfiguration = {
|
|
40
|
+
render: (content) => Promise.resolve(content),
|
|
41
|
+
};
|
|
42
|
+
let customConfiguration = null;
|
|
43
|
+
try {
|
|
44
|
+
customConfiguration = await import(
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
"_reactivated/conf");
|
|
47
|
+
}
|
|
48
|
+
catch (error) { }
|
|
39
49
|
// @ts-ignore
|
|
40
50
|
const { Provider, getTemplate } = await import("_reactivated/index.tsx");
|
|
41
51
|
try {
|
|
42
52
|
const Template = getTemplate(context);
|
|
43
53
|
const helmetContext = {};
|
|
44
|
-
const
|
|
54
|
+
const content = (React.createElement(HelmetProvider, { context: helmetContext },
|
|
45
55
|
React.createElement(Provider, { value: context },
|
|
46
56
|
React.createElement(Template, { ...props }))));
|
|
47
57
|
const { helmet } = helmetContext;
|
|
58
|
+
const rendered = ReactDOMServer.renderToString(await (customConfiguration?.default?.render?.(content) ??
|
|
59
|
+
defaultConfiguration.render(content)));
|
|
48
60
|
return {
|
|
49
61
|
status: "success",
|
|
50
|
-
rendered
|
|
51
|
-
html: rendered,
|
|
52
|
-
helmet,
|
|
53
|
-
props,
|
|
54
|
-
context,
|
|
55
|
-
}),
|
|
62
|
+
rendered,
|
|
56
63
|
};
|
|
57
64
|
}
|
|
58
65
|
catch (error) {
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAGH,cAAc,GAEjB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAGH,cAAc,GAEjB,MAAM,oBAAoB,CAAC;AAK5B,+FAA+F;AAC/F,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,GAMR,EAAE,EAAE;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS;QACzC,CAAC,CAAC,UAAU,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG;QACxC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO;;QAEH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE;;kBAEtB,WAAW;;;;2CAIc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CACxD,IAAI,EACJ,SAAS,CACZ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CAAC,OAAO,EAAE,CAAC;IAEjC,IAAI,OAAO,IAAI,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,EAAE,CAAC;KACrB;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,YAAY,CAAC,CAAC;KACzD;SAAM;QACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;KACzE;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactivated",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0-a1901",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
7
7
|
"./dist/renderer": "./dist/renderer.js",
|
|
8
8
|
"./dist/forms": "./dist/forms/index.js",
|
|
9
9
|
"./dist/context": "./dist/context.js",
|
|
10
|
-
"./dist/
|
|
11
|
-
"./dist/
|
|
10
|
+
"./dist/conf": "./dist/conf.js",
|
|
11
|
+
"./dist/rpc": "./dist/rpc.js"
|
|
12
12
|
},
|
|
13
13
|
"typings": "dist/index.d.ts",
|
|
14
14
|
"scripts": {
|
|
@@ -25,14 +25,6 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@babel/core": "^7.21.8",
|
|
29
|
-
"@babel/preset-react": "^7.18.6",
|
|
30
|
-
"@babel/preset-typescript": "^7.21.5",
|
|
31
|
-
"@linaria/babel-preset": "^4.4.5",
|
|
32
|
-
"@linaria/core": "^4.2.10",
|
|
33
|
-
"@linaria/esbuild": "^4.2.11",
|
|
34
|
-
"@linaria/react": "^4.3.8",
|
|
35
|
-
"@linaria/shaker": "^4.2.11",
|
|
36
28
|
"@types/react": "^18.0.12",
|
|
37
29
|
"@types/react-dom": "^18.0.5",
|
|
38
30
|
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
@@ -43,7 +35,6 @@
|
|
|
43
35
|
"@vanilla-extract/esbuild-plugin": "^2.2.2",
|
|
44
36
|
"@vanilla-extract/recipes": "^0.4.0",
|
|
45
37
|
"@vanilla-extract/sprinkles": "^1.6.0",
|
|
46
|
-
"babel-plugin-module-resolver": "^5.0.0",
|
|
47
38
|
"esbuild": "^0.17.19",
|
|
48
39
|
"esbuild-plugin-import-glob": "^0.1.1",
|
|
49
40
|
"eslint": "^8.40.0",
|
package/src/build.client.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria.mjs";
|
|
4
3
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
4
|
import * as esbuild from "esbuild";
|
|
6
5
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
6
|
+
import {produce} from "immer";
|
|
7
7
|
|
|
8
8
|
const entryNames = process.argv.slice(2);
|
|
9
9
|
|
|
@@ -14,6 +14,16 @@ const entryPoints = Object.fromEntries(
|
|
|
14
14
|
const production = process.env.NODE_ENV === "production";
|
|
15
15
|
const identifiers = production ? "short" : "debug";
|
|
16
16
|
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const customConfigurationImport: {default?: Options} | null = await import(
|
|
19
|
+
`${process.cwd()}/node_modules/_reactivated/conf.mjs`
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const getOptions =
|
|
23
|
+
customConfigurationImport?.default?.build?.client != null
|
|
24
|
+
? customConfigurationImport.default.build.client
|
|
25
|
+
: (options: esbuild.BuildOptions) => {};
|
|
26
|
+
|
|
17
27
|
const env = {
|
|
18
28
|
NODE_ENV: production ? "production" : "development",
|
|
19
29
|
BUILD_VERSION: process.env.BUILD_VERSION,
|
|
@@ -21,51 +31,59 @@ const env = {
|
|
|
21
31
|
};
|
|
22
32
|
|
|
23
33
|
esbuild
|
|
24
|
-
.context(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
.context(
|
|
35
|
+
produce(
|
|
36
|
+
{
|
|
37
|
+
entryPoints,
|
|
38
|
+
bundle: true,
|
|
39
|
+
// We use terser to minify because esbuild breaks safari sourcemaps.
|
|
40
|
+
// It's likely a Safari bug, but terser seems to work for some reason.
|
|
41
|
+
minify: false,
|
|
42
|
+
// Related to sourcemaps as well in Safari.
|
|
43
|
+
legalComments: "none",
|
|
44
|
+
platform: "browser",
|
|
45
|
+
outdir: "./static/dist",
|
|
46
|
+
sourcemap: true,
|
|
47
|
+
target: "es2018",
|
|
48
|
+
preserveSymlinks: true,
|
|
49
|
+
external: ["moment", "@client/generated/images"],
|
|
50
|
+
define: {
|
|
51
|
+
// You need both. The one from the stringified JSON is not picked
|
|
52
|
+
// up during the build process.
|
|
53
|
+
"process.env.NODE_ENV": production
|
|
54
|
+
? '"production"'
|
|
55
|
+
: '"development"',
|
|
56
|
+
process: JSON.stringify({env}),
|
|
43
57
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
// Redux persist needs this.
|
|
59
|
+
global: "{}",
|
|
60
|
+
},
|
|
61
|
+
loader: {
|
|
62
|
+
".gif": "file",
|
|
63
|
+
".jpeg": "file",
|
|
64
|
+
".jpg": "file",
|
|
65
|
+
".png": "file",
|
|
66
|
+
".svg": "file",
|
|
67
|
+
".ttf": "file",
|
|
68
|
+
".woff": "file",
|
|
69
|
+
".woff2": "file",
|
|
70
|
+
},
|
|
71
|
+
plugins: [
|
|
72
|
+
// ESM imports make this weird.
|
|
73
|
+
(
|
|
74
|
+
ImportGlobPlugin as unknown as {default: () => esbuild.Plugin}
|
|
75
|
+
).default(),
|
|
76
|
+
// We manually pass in identifiers because the client is not
|
|
77
|
+
// minified by esbuild but the renderer is, so class names could
|
|
78
|
+
// differ.
|
|
79
|
+
// Instead of set it manually instead of relying on minification
|
|
80
|
+
// settings.
|
|
81
|
+
vanillaExtractPlugin({identifiers}),
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
(draftState) => getOptions(draftState),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
69
87
|
.then(async (context) => {
|
|
70
88
|
if (production === false) {
|
|
71
89
|
context.watch();
|
package/src/build.renderer.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria.mjs";
|
|
4
3
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
4
|
import * as esbuild from "esbuild";
|
|
6
5
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -8,6 +7,13 @@ import http from "http";
|
|
|
8
7
|
import fs from "fs";
|
|
9
8
|
import path from "path";
|
|
10
9
|
import {createRequire} from "module";
|
|
10
|
+
import type {Options} from "./conf";
|
|
11
|
+
import {produce} from "immer";
|
|
12
|
+
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const customConfigurationImport: {default?: Options} | null = await import(
|
|
15
|
+
`${process.cwd()}/node_modules/_reactivated/conf.mjs`
|
|
16
|
+
);
|
|
11
17
|
|
|
12
18
|
let server: http.Server | null = null;
|
|
13
19
|
|
|
@@ -28,48 +34,59 @@ const restartServer = async () => {
|
|
|
28
34
|
server = require(CACHE_KEY).server;
|
|
29
35
|
};
|
|
30
36
|
|
|
37
|
+
const getOptions =
|
|
38
|
+
customConfigurationImport?.default?.build?.renderer != null
|
|
39
|
+
? customConfigurationImport.default.build.renderer
|
|
40
|
+
: (options: esbuild.BuildOptions) => {};
|
|
41
|
+
|
|
31
42
|
esbuild
|
|
32
|
-
.context(
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
.context(
|
|
44
|
+
produce(
|
|
45
|
+
{
|
|
46
|
+
stdin: {
|
|
47
|
+
contents: `
|
|
35
48
|
export {server, currentTime} from "reactivated/dist/renderer";
|
|
36
49
|
`,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
minify: production,
|
|
41
|
-
bundle: true,
|
|
42
|
-
platform: "node",
|
|
43
|
-
outfile: "./node_modules/_reactivated/renderer.js",
|
|
44
|
-
sourcemap: true,
|
|
45
|
-
target: "es2018",
|
|
46
|
-
preserveSymlinks: true,
|
|
47
|
-
// Needed so _reactivated is included in renderer.tsx regardless
|
|
48
|
-
// of the location of reactivated being in the cwd node_modules or
|
|
49
|
-
// above as in monorepos.
|
|
50
|
-
nodePaths: [`${process.cwd()}/node_modules`],
|
|
51
|
-
plugins: [
|
|
52
|
-
// ESM imports make this weird.
|
|
53
|
-
(ImportGlobPlugin as unknown as {default: () => esbuild.Plugin}).default(),
|
|
54
|
-
// We manually pass in identifiers because the client is not
|
|
55
|
-
// minified by esbuild but the renderer is, so class names could
|
|
56
|
-
// differ.
|
|
57
|
-
// Instead of set it manually instead of relying on minification
|
|
58
|
-
// settings.
|
|
59
|
-
vanillaExtractPlugin({identifiers}),
|
|
60
|
-
linaria({sourceMap: true}),
|
|
61
|
-
{
|
|
62
|
-
name: "restartServer",
|
|
63
|
-
setup: (build) => {
|
|
64
|
-
if (production === false) {
|
|
65
|
-
build.onEnd((result) => {
|
|
66
|
-
restartServer();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
50
|
+
resolveDir: process.cwd(),
|
|
51
|
+
loader: "ts",
|
|
69
52
|
},
|
|
53
|
+
minify: production,
|
|
54
|
+
bundle: true,
|
|
55
|
+
platform: "node",
|
|
56
|
+
outfile: "./node_modules/_reactivated/renderer.js",
|
|
57
|
+
sourcemap: true,
|
|
58
|
+
target: "es2018",
|
|
59
|
+
preserveSymlinks: true,
|
|
60
|
+
// Needed so _reactivated is included in renderer.tsx regardless
|
|
61
|
+
// of the location of reactivated being in the cwd node_modules or
|
|
62
|
+
// above as in monorepos.
|
|
63
|
+
nodePaths: [`${process.cwd()}/node_modules`],
|
|
64
|
+
plugins: [
|
|
65
|
+
// ESM imports make this weird.
|
|
66
|
+
(
|
|
67
|
+
ImportGlobPlugin as unknown as {default: () => esbuild.Plugin}
|
|
68
|
+
).default(),
|
|
69
|
+
// We manually pass in identifiers because the client is not
|
|
70
|
+
// minified by esbuild but the renderer is, so class names could
|
|
71
|
+
// differ.
|
|
72
|
+
// Instead of set it manually instead of relying on minification
|
|
73
|
+
// settings.
|
|
74
|
+
vanillaExtractPlugin({identifiers}),
|
|
75
|
+
{
|
|
76
|
+
name: "restartServer",
|
|
77
|
+
setup: (build) => {
|
|
78
|
+
if (production === false) {
|
|
79
|
+
build.onEnd((result) => {
|
|
80
|
+
restartServer();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
70
86
|
},
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
(draftState) => getOptions(draftState),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
73
90
|
.then(async (context) => {
|
|
74
91
|
if (production === false) {
|
|
75
92
|
context.watch();
|
package/src/conf.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {BuildOptions} from "esbuild";
|
|
2
|
+
|
|
3
|
+
export type Options = {
|
|
4
|
+
build?: {
|
|
5
|
+
client?: (options: BuildOptions) => void;
|
|
6
|
+
renderer?: (options: BuildOptions) => void;
|
|
7
|
+
};
|
|
8
|
+
render?: (content: JSX.Element) => Promise<JSX.Element>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const configure = (options: Options) => options;
|
|
12
|
+
|
|
13
|
+
export default (customConfigurationImport: {default?: Options} | null) => {
|
|
14
|
+
const customConfiguration = customConfigurationImport?.default ?? {};
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
build: {
|
|
18
|
+
client: customConfiguration.build?.client ?? ((options) => {}),
|
|
19
|
+
renderer: customConfiguration.build?.renderer ?? ((options) => {}),
|
|
20
|
+
},
|
|
21
|
+
render: customConfiguration.render ?? ((content) => Promise.resolve(content)),
|
|
22
|
+
} satisfies Options;
|
|
23
|
+
};
|
package/src/eslintrc.tsx
CHANGED
package/src/generator.mts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import * as generated from "./generated";
|
|
5
|
+
import * as esbuild from "esbuild";
|
|
6
|
+
import path from "path";
|
|
5
7
|
|
|
6
8
|
// Must be above the compile import as get-stdin used by
|
|
7
9
|
// json-schema-to-typescript messes up the descriptor even if unused.
|
|
@@ -28,6 +30,20 @@ import {
|
|
|
28
30
|
StatementStructures,
|
|
29
31
|
} from "ts-morph";
|
|
30
32
|
|
|
33
|
+
const CONF_INPUT_FILE = "./client/reactivated.config.tsx";
|
|
34
|
+
const CONF_OUTPUT_FILE = "./node_modules/_reactivated/conf.mjs";
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(CONF_INPUT_FILE)) {
|
|
37
|
+
await esbuild.build({
|
|
38
|
+
entryPoints: [CONF_INPUT_FILE],
|
|
39
|
+
bundle: false,
|
|
40
|
+
outfile: CONF_OUTPUT_FILE,
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
fs.mkdirSync(path.dirname(CONF_OUTPUT_FILE), {recursive: true});
|
|
44
|
+
fs.writeFileSync(CONF_OUTPUT_FILE, "");
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
32
48
|
const {
|
|
33
49
|
urls: possibleEmptyUrls,
|
|
@@ -280,6 +296,7 @@ sourceFile.addStatements(
|
|
|
280
296
|
);
|
|
281
297
|
|
|
282
298
|
sourceFile.addStatements(`
|
|
299
|
+
export {configure} from "reactivated/dist/conf";
|
|
283
300
|
export const rpc = new RPC(typeof window != "undefined" ? rpcUtils.defaultRequester : null as any);
|
|
284
301
|
import React from "react"
|
|
285
302
|
import createContext from "reactivated/dist/context";
|
|
@@ -289,6 +306,10 @@ import * as rpcUtils from "reactivated/dist/rpc";
|
|
|
289
306
|
import {constants} from "./constants";
|
|
290
307
|
export {constants};
|
|
291
308
|
|
|
309
|
+
export function classNames(...classes: (string | undefined | null | false)[]) {
|
|
310
|
+
return classes.filter(Boolean).join(" ");
|
|
311
|
+
}
|
|
312
|
+
|
|
292
313
|
// Note: this needs strict function types to behave correctly with excess properties etc.
|
|
293
314
|
export type Checker<P, U extends (React.FunctionComponent<P> | React.ComponentClass<P>)> = {};
|
|
294
315
|
|
package/src/renderer.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
HelmetServerState,
|
|
12
12
|
} from "react-helmet-async";
|
|
13
13
|
|
|
14
|
+
import {Options} from "./conf";
|
|
14
15
|
import {Settings} from "./models";
|
|
15
16
|
|
|
16
17
|
// TODO: WHAT DOES THIS NEED TO BE? Even 100k was super fragile and a 10 choice field broke it.
|
|
@@ -81,6 +82,19 @@ export const render = async ({
|
|
|
81
82
|
context: any;
|
|
82
83
|
props: any;
|
|
83
84
|
}): Promise<Result> => {
|
|
85
|
+
const defaultConfiguration = {
|
|
86
|
+
render: (content) => Promise.resolve(content),
|
|
87
|
+
} satisfies Options;
|
|
88
|
+
|
|
89
|
+
let customConfiguration: {default?: Options} | null = null;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
customConfiguration = await import(
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
"_reactivated/conf"
|
|
95
|
+
);
|
|
96
|
+
} catch (error: unknown) {}
|
|
97
|
+
|
|
84
98
|
// @ts-ignore
|
|
85
99
|
const {Provider, getTemplate} = await import("_reactivated/index.tsx");
|
|
86
100
|
|
|
@@ -88,24 +102,24 @@ export const render = async ({
|
|
|
88
102
|
const Template = getTemplate(context);
|
|
89
103
|
const helmetContext = {} as FilledContext;
|
|
90
104
|
|
|
91
|
-
const
|
|
105
|
+
const content = (
|
|
92
106
|
<HelmetProvider context={helmetContext}>
|
|
93
107
|
<Provider value={context}>
|
|
94
108
|
<Template {...props} />
|
|
95
109
|
</Provider>
|
|
96
|
-
</HelmetProvider
|
|
110
|
+
</HelmetProvider>
|
|
97
111
|
);
|
|
98
112
|
|
|
99
113
|
const {helmet} = helmetContext;
|
|
100
114
|
|
|
115
|
+
const rendered = ReactDOMServer.renderToString(
|
|
116
|
+
await (customConfiguration?.default?.render?.(content) ??
|
|
117
|
+
defaultConfiguration.render(content)),
|
|
118
|
+
);
|
|
119
|
+
|
|
101
120
|
return {
|
|
102
121
|
status: "success",
|
|
103
|
-
rendered
|
|
104
|
-
html: rendered,
|
|
105
|
-
helmet,
|
|
106
|
-
props,
|
|
107
|
-
context,
|
|
108
|
-
}),
|
|
122
|
+
rendered,
|
|
109
123
|
};
|
|
110
124
|
} catch (error) {
|
|
111
125
|
return {status: "error", error};
|
package/dist/linaria.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
import type { Plugin, TransformOptions } from "esbuild";
|
|
7
|
-
import type { PluginOptions, Preprocessor } from "@linaria/babel-preset";
|
|
8
|
-
type EsbuildPluginOptions = {
|
|
9
|
-
sourceMap?: boolean;
|
|
10
|
-
preprocessor?: Preprocessor;
|
|
11
|
-
esbuildOptions?: TransformOptions;
|
|
12
|
-
} & Partial<PluginOptions>;
|
|
13
|
-
export default function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest }?: EsbuildPluginOptions): Plugin;
|
|
14
|
-
export {};
|
package/dist/linaria.mjs
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
import fs from "fs";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { transformSync } from "esbuild";
|
|
9
|
-
import { slugify, transform } from "@linaria/babel-preset";
|
|
10
|
-
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
11
|
-
export default function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest } = {}) {
|
|
12
|
-
let options = esbuildOptions;
|
|
13
|
-
return {
|
|
14
|
-
name: "linaria",
|
|
15
|
-
setup(build) {
|
|
16
|
-
const cssLookup = new Map();
|
|
17
|
-
const asyncResolve = async (token, importer) => {
|
|
18
|
-
const context = path.isAbsolute(importer)
|
|
19
|
-
? path.dirname(importer)
|
|
20
|
-
: path.join(process.cwd(), path.dirname(importer));
|
|
21
|
-
const result = await build.resolve(token, {
|
|
22
|
-
kind: "entry-point",
|
|
23
|
-
resolveDir: context,
|
|
24
|
-
});
|
|
25
|
-
if (result.errors.length > 0) {
|
|
26
|
-
throw new Error(`Cannot resolve ${token}`);
|
|
27
|
-
}
|
|
28
|
-
return result.path;
|
|
29
|
-
};
|
|
30
|
-
build.onResolve({ filter: /\.linaria\.css$/ }, (args) => {
|
|
31
|
-
return {
|
|
32
|
-
namespace: "linaria",
|
|
33
|
-
path: args.path,
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
build.onLoad({ filter: /.*/, namespace: "linaria" }, (args) => {
|
|
37
|
-
return {
|
|
38
|
-
contents: cssLookup.get(args.path),
|
|
39
|
-
loader: "css",
|
|
40
|
-
resolveDir: path.basename(args.path),
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
build.onLoad({ filter: /\.(js|jsx|ts|tsx)$/ }, async (args) => {
|
|
44
|
-
const rawCode = fs.readFileSync(args.path, "utf8");
|
|
45
|
-
const { ext, name: filename } = path.parse(args.path);
|
|
46
|
-
const loader = ext.replace(/^\./, "");
|
|
47
|
-
if (nodeModulesRegex.test(args.path)) {
|
|
48
|
-
return {
|
|
49
|
-
loader,
|
|
50
|
-
contents: rawCode,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (!options) {
|
|
54
|
-
options = {};
|
|
55
|
-
if ("jsxFactory" in build.initialOptions) {
|
|
56
|
-
options.jsxFactory = build.initialOptions.jsxFactory;
|
|
57
|
-
}
|
|
58
|
-
if ("jsxFragment" in build.initialOptions) {
|
|
59
|
-
options.jsxFragment = build.initialOptions.jsxFragment;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const transformed = transformSync(rawCode, {
|
|
63
|
-
...options,
|
|
64
|
-
sourcefile: args.path,
|
|
65
|
-
sourcemap: sourceMap,
|
|
66
|
-
loader,
|
|
67
|
-
});
|
|
68
|
-
let { code } = transformed;
|
|
69
|
-
if (sourceMap) {
|
|
70
|
-
const esbuildMap = Buffer.from(transformed.map).toString("base64");
|
|
71
|
-
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
72
|
-
}
|
|
73
|
-
const babelOptions = {
|
|
74
|
-
presets: [
|
|
75
|
-
["@babel/preset-env", { targets: { node: "v12.13.0" } }],
|
|
76
|
-
["@babel/preset-typescript", { allowNamespaces: true }],
|
|
77
|
-
],
|
|
78
|
-
plugins: [
|
|
79
|
-
[
|
|
80
|
-
"module-resolver",
|
|
81
|
-
{
|
|
82
|
-
root: ["./"],
|
|
83
|
-
alias: {
|
|
84
|
-
"@client": "./client",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
const result = await transform(code, {
|
|
91
|
-
filename: args.path,
|
|
92
|
-
preprocessor,
|
|
93
|
-
pluginOptions: { ...rest, babelOptions },
|
|
94
|
-
}, asyncResolve);
|
|
95
|
-
if (!result.cssText) {
|
|
96
|
-
return {
|
|
97
|
-
contents: code,
|
|
98
|
-
loader,
|
|
99
|
-
resolveDir: path.dirname(args.path),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
let { cssText } = result;
|
|
103
|
-
const slug = slugify(cssText);
|
|
104
|
-
const cssFilename = `${filename}_${slug}.linaria.css`;
|
|
105
|
-
let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`;
|
|
106
|
-
if (sourceMap && result.cssSourceMapText) {
|
|
107
|
-
const map = Buffer.from(result.cssSourceMapText).toString("base64");
|
|
108
|
-
cssText += `/*# sourceMappingURL=data:application/json;base64,${map}*/`;
|
|
109
|
-
const linariaMap = Buffer.from(JSON.stringify(result.sourceMap)).toString("base64");
|
|
110
|
-
contents += `/*# sourceMappingURL=data:application/json;base64,${linariaMap}*/`;
|
|
111
|
-
}
|
|
112
|
-
cssLookup.set(cssFilename, cssText);
|
|
113
|
-
return {
|
|
114
|
-
contents,
|
|
115
|
-
loader,
|
|
116
|
-
resolveDir: path.dirname(args.path),
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=linaria.mjs.map
|
package/dist/linaria.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linaria.mjs","sourceRoot":"","sources":["../src/linaria.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAG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I,cAAc,CAAC;gBAEtD,IAAI,QAAQ,GAAG,UAAU,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;gBAEvE,IAAI,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE;oBACtC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACpE,OAAO,IAAI,qDAAqD,GAAG,IAAI,CAAC;oBACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CACnC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACrB,QAAQ,IAAI,qDAAqD,UAAU,IAAI,CAAC;iBACnF;gBAED,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;gBAEpC,OAAO;oBACH,QAAQ;oBACR,MAAM;oBACN,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;iBACtC,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/src/linaria.mts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from "fs";
|
|
8
|
-
import path from "path";
|
|
9
|
-
|
|
10
|
-
import type {Plugin, TransformOptions, Loader} from "esbuild";
|
|
11
|
-
import {transformSync} from "esbuild";
|
|
12
|
-
|
|
13
|
-
import type {PluginOptions, Preprocessor} from "@linaria/babel-preset";
|
|
14
|
-
import {slugify, transform} from "@linaria/babel-preset";
|
|
15
|
-
|
|
16
|
-
type EsbuildPluginOptions = {
|
|
17
|
-
sourceMap?: boolean;
|
|
18
|
-
preprocessor?: Preprocessor;
|
|
19
|
-
esbuildOptions?: TransformOptions;
|
|
20
|
-
} & Partial<PluginOptions>;
|
|
21
|
-
|
|
22
|
-
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
23
|
-
|
|
24
|
-
export default function linaria({
|
|
25
|
-
sourceMap,
|
|
26
|
-
preprocessor,
|
|
27
|
-
esbuildOptions,
|
|
28
|
-
...rest
|
|
29
|
-
}: EsbuildPluginOptions = {}): Plugin {
|
|
30
|
-
let options = esbuildOptions;
|
|
31
|
-
return {
|
|
32
|
-
name: "linaria",
|
|
33
|
-
setup(build) {
|
|
34
|
-
const cssLookup = new Map<string, string>();
|
|
35
|
-
|
|
36
|
-
const asyncResolve = async (
|
|
37
|
-
token: string,
|
|
38
|
-
importer: string,
|
|
39
|
-
): Promise<string> => {
|
|
40
|
-
const context = path.isAbsolute(importer)
|
|
41
|
-
? path.dirname(importer)
|
|
42
|
-
: path.join(process.cwd(), path.dirname(importer));
|
|
43
|
-
|
|
44
|
-
const result = await build.resolve(token, {
|
|
45
|
-
kind: "entry-point",
|
|
46
|
-
resolveDir: context,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (result.errors.length > 0) {
|
|
50
|
-
throw new Error(`Cannot resolve ${token}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return result.path;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
build.onResolve({filter: /\.linaria\.css$/}, (args) => {
|
|
57
|
-
return {
|
|
58
|
-
namespace: "linaria",
|
|
59
|
-
path: args.path,
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
build.onLoad({filter: /.*/, namespace: "linaria"}, (args) => {
|
|
64
|
-
return {
|
|
65
|
-
contents: cssLookup.get(args.path),
|
|
66
|
-
loader: "css",
|
|
67
|
-
resolveDir: path.basename(args.path),
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
build.onLoad({filter: /\.(js|jsx|ts|tsx)$/}, async (args) => {
|
|
72
|
-
const rawCode = fs.readFileSync(args.path, "utf8");
|
|
73
|
-
const {ext, name: filename} = path.parse(args.path);
|
|
74
|
-
const loader = ext.replace(/^\./, "") as Loader;
|
|
75
|
-
|
|
76
|
-
if (nodeModulesRegex.test(args.path)) {
|
|
77
|
-
return {
|
|
78
|
-
loader,
|
|
79
|
-
contents: rawCode,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!options) {
|
|
84
|
-
options = {};
|
|
85
|
-
if ("jsxFactory" in build.initialOptions) {
|
|
86
|
-
options.jsxFactory = build.initialOptions.jsxFactory;
|
|
87
|
-
}
|
|
88
|
-
if ("jsxFragment" in build.initialOptions) {
|
|
89
|
-
options.jsxFragment = build.initialOptions.jsxFragment;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const transformed = transformSync(rawCode, {
|
|
94
|
-
...options,
|
|
95
|
-
sourcefile: args.path,
|
|
96
|
-
sourcemap: sourceMap,
|
|
97
|
-
loader,
|
|
98
|
-
});
|
|
99
|
-
let {code} = transformed;
|
|
100
|
-
|
|
101
|
-
if (sourceMap) {
|
|
102
|
-
const esbuildMap = Buffer.from(transformed.map).toString("base64");
|
|
103
|
-
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const babelOptions = {
|
|
107
|
-
presets: [
|
|
108
|
-
["@babel/preset-env", {targets: {node: "v12.13.0"}}],
|
|
109
|
-
["@babel/preset-typescript", {allowNamespaces: true}],
|
|
110
|
-
],
|
|
111
|
-
plugins: [
|
|
112
|
-
[
|
|
113
|
-
"module-resolver",
|
|
114
|
-
{
|
|
115
|
-
root: ["./"],
|
|
116
|
-
alias: {
|
|
117
|
-
"@client": "./client",
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
],
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const result = await transform(
|
|
125
|
-
code,
|
|
126
|
-
{
|
|
127
|
-
filename: args.path,
|
|
128
|
-
preprocessor,
|
|
129
|
-
pluginOptions: {...rest, babelOptions},
|
|
130
|
-
},
|
|
131
|
-
asyncResolve,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
if (!result.cssText) {
|
|
135
|
-
return {
|
|
136
|
-
contents: code,
|
|
137
|
-
loader,
|
|
138
|
-
resolveDir: path.dirname(args.path),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let {cssText} = result;
|
|
143
|
-
|
|
144
|
-
const slug = slugify(cssText);
|
|
145
|
-
const cssFilename = `${filename}_${slug}.linaria.css`;
|
|
146
|
-
|
|
147
|
-
let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`;
|
|
148
|
-
|
|
149
|
-
if (sourceMap && result.cssSourceMapText) {
|
|
150
|
-
const map = Buffer.from(result.cssSourceMapText).toString("base64");
|
|
151
|
-
cssText += `/*# sourceMappingURL=data:application/json;base64,${map}*/`;
|
|
152
|
-
const linariaMap = Buffer.from(
|
|
153
|
-
JSON.stringify(result.sourceMap),
|
|
154
|
-
).toString("base64");
|
|
155
|
-
contents += `/*# sourceMappingURL=data:application/json;base64,${linariaMap}*/`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
cssLookup.set(cssFilename, cssText);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
contents,
|
|
162
|
-
loader,
|
|
163
|
-
resolveDir: path.dirname(args.path),
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}
|