@fluixi/compiler 1.0.0-alpha.83 → 1.0.0-alpha.85
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/analyze/expr-shape.cjs +62 -1
- package/dist/analyze/expr-shape.d.cts +14 -0
- package/dist/analyze/expr-shape.d.ts +2 -2
- package/dist/analyze/expr-shape.js +1 -1
- package/dist/analyze/expr-shape.mjs +41 -1
- package/dist/analyze/intrinsics.cjs +80 -1
- package/dist/analyze/intrinsics.d.cts +66 -0
- package/dist/analyze/intrinsics.d.ts +7 -7
- package/dist/analyze/intrinsics.d.ts.map +1 -1
- package/dist/analyze/intrinsics.js +3 -3
- package/dist/analyze/intrinsics.mjs +59 -1
- package/dist/analyze/paren.cjs +134 -0
- package/dist/analyze/paren.d.cts +23 -0
- package/dist/analyze/paren.d.ts +24 -0
- package/dist/analyze/paren.d.ts.map +1 -0
- package/dist/analyze/paren.js +168 -0
- package/dist/analyze/paren.mjs +113 -0
- package/dist/analyze/props-destructure.cjs +226 -1
- package/dist/analyze/props-destructure.d.cts +83 -0
- package/dist/analyze/props-destructure.d.ts +3 -3
- package/dist/analyze/props-destructure.d.ts.map +1 -1
- package/dist/analyze/props-destructure.js +4 -4
- package/dist/analyze/props-destructure.mjs +205 -1
- package/dist/analyze/reactive-bindings.cjs +190 -1
- package/dist/analyze/reactive-bindings.d.cts +42 -0
- package/dist/analyze/reactive-bindings.d.ts +1 -1
- package/dist/analyze/reactive-bindings.js +2 -2
- package/dist/analyze/reactive-bindings.mjs +167 -1
- package/dist/analyze/reactive-expr.cjs +38 -1
- package/dist/analyze/reactive-expr.d.cts +38 -0
- package/dist/analyze/reactive-expr.d.ts +4 -4
- package/dist/analyze/reactive-expr.d.ts.map +1 -1
- package/dist/analyze/reactive-expr.js +2 -2
- package/dist/analyze/reactive-expr.mjs +17 -1
- package/dist/analyze/static-graph.cjs +811 -1
- package/dist/analyze/static-graph.d.cts +102 -0
- package/dist/analyze/static-graph.d.ts +1 -1
- package/dist/analyze/static-graph.d.ts.map +1 -1
- package/dist/analyze/static-graph.js +11 -11
- package/dist/analyze/static-graph.mjs +793 -1
- package/dist/babel-TGY76XJ7.mjs +636 -0
- package/dist/chunk-4PLHS2FP.mjs +158 -0
- package/dist/chunk-6DB5FXS4.mjs +1718 -0
- package/dist/chunk-F74GFKSL.mjs +16 -0
- package/dist/chunk-G6QC2WRJ.mjs +11 -0
- package/dist/chunk-RUDJDZAA.mjs +1078 -0
- package/dist/codegen/backend.cjs +18 -1
- package/dist/codegen/backend.d.cts +35 -0
- package/dist/codegen/backends/imperative.cjs +542 -1
- package/dist/codegen/backends/imperative.d.cts +11 -0
- package/dist/codegen/backends/imperative.d.ts +1 -1
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +24 -20
- package/dist/codegen/backends/imperative.mjs +519 -1
- package/dist/codegen/contract.cjs +52 -1
- package/dist/codegen/contract.d.cts +24 -0
- package/dist/codegen/contract.d.ts +2 -2
- package/dist/codegen/contract.js +2 -2
- package/dist/codegen/contract.mjs +31 -1
- package/dist/codegen/partial-template.cjs +176 -1
- package/dist/codegen/partial-template.d.cts +61 -0
- package/dist/codegen/partial-template.d.ts +4 -4
- package/dist/codegen/partial-template.js +0 -0
- package/dist/codegen/partial-template.mjs +153 -1
- package/dist/codegen/serialize-static.cjs +125 -1
- package/dist/codegen/serialize-static.d.cts +38 -0
- package/dist/codegen/serialize-static.d.ts +3 -3
- package/dist/codegen/serialize-static.js +6 -6
- package/dist/codegen/serialize-static.mjs +104 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
- package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
- package/dist/frontend/babel/build-ir-lit.d.ts +2 -2
- package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
- package/dist/frontend/babel/build-ir.cjs +1524 -1
- package/dist/frontend/babel/build-ir.d.cts +35 -0
- package/dist/frontend/babel/build-ir.d.ts +2 -2
- package/dist/frontend/babel/build-ir.js +2 -2
- package/dist/frontend/babel/build-ir.mjs +1495 -1
- package/dist/frontend/babel/index.cjs +2186 -1
- package/dist/frontend/babel/index.d.cts +33 -0
- package/dist/frontend/babel/index.d.ts +1 -1
- package/dist/frontend/babel/index.js +1 -1
- package/dist/frontend/babel/index.mjs +2156 -1
- package/dist/frontend/babel/lower-template.cjs +1507 -1
- package/dist/frontend/babel/lower-template.d.cts +23 -0
- package/dist/frontend/babel/lower-template.d.ts +1 -1
- package/dist/frontend/babel/lower-template.js +2 -2
- package/dist/frontend/babel/lower-template.mjs +1478 -1
- package/dist/frontend/babel/plugin.cjs +2132 -1
- package/dist/frontend/babel/plugin.d.cts +95 -0
- package/dist/frontend/babel/plugin.d.ts +5 -5
- package/dist/frontend/babel/plugin.d.ts.map +1 -1
- package/dist/frontend/babel/plugin.js +14 -14
- package/dist/frontend/babel/plugin.mjs +2103 -1
- package/dist/frontend/babel/server-functions.cjs +110 -1
- package/dist/frontend/babel/server-functions.d.cts +10 -0
- package/dist/frontend/babel/server-functions.mjs +89 -1
- package/dist/frontend/babel/types.cjs +18 -1
- package/dist/frontend/babel/types.d.cts +33 -0
- package/dist/frontend/types.cjs +18 -1
- package/dist/frontend/types.d.cts +25 -0
- package/dist/frontend/vocabulary.cjs +98 -0
- package/dist/frontend/vocabulary.d.cts +79 -0
- package/dist/frontend/vocabulary.d.ts +80 -0
- package/dist/frontend/vocabulary.d.ts.map +1 -0
- package/dist/frontend/vocabulary.js +124 -0
- package/dist/frontend/vocabulary.mjs +77 -0
- package/dist/index.cjs +1595 -14
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +1575 -14
- package/dist/integrations.cjs +4312 -26
- package/dist/integrations.d.cts +215 -0
- package/dist/integrations.d.ts +9 -9
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +29 -8
- package/dist/integrations.mjs +536 -18
- package/dist/ir/nodes.cjs +18 -1
- package/dist/ir/nodes.d.cts +168 -0
- package/dist/ir/nodes.d.ts +6 -6
- package/dist/lower/compile-template.cjs +1356 -1
- package/dist/lower/compile-template.d.cts +69 -0
- package/dist/lower/compile-template.d.ts +3 -3
- package/dist/lower/compile-template.js +1 -1
- package/dist/lower/compile-template.mjs +1336 -1
- package/dist/lower/jsx.cjs +529 -1
- package/dist/lower/jsx.d.cts +25 -0
- package/dist/lower/jsx.d.ts +1 -1
- package/dist/lower/jsx.d.ts.map +1 -1
- package/dist/lower/jsx.js +6 -5
- package/dist/lower/jsx.mjs +506 -1
- package/dist/lower/template.cjs +1061 -1
- package/dist/lower/template.d.cts +53 -0
- package/dist/lower/template.d.ts +3 -3
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +12 -11
- package/dist/lower/template.mjs +1042 -1
- package/dist/lower/text.cjs +42 -1
- package/dist/lower/text.d.cts +10 -0
- package/dist/lower/text.d.ts +2 -2
- package/dist/lower/text.d.ts.map +1 -1
- package/dist/lower/text.js +2 -2
- package/dist/lower/text.mjs +21 -1
- package/dist/optimize/analyze-static.cjs +112 -1
- package/dist/optimize/analyze-static.d.cts +39 -0
- package/dist/optimize/analyze-static.d.ts +2 -2
- package/dist/optimize/analyze-static.js +2 -2
- package/dist/optimize/analyze-static.mjs +91 -1
- package/dist/optimize/collapse-strategies.cjs +90 -1
- package/dist/optimize/collapse-strategies.d.cts +30 -0
- package/dist/optimize/collapse-strategies.d.ts +3 -3
- package/dist/optimize/collapse-strategies.mjs +67 -1
- package/dist/options.cjs +33 -1
- package/dist/options.d.cts +39 -0
- package/dist/options.d.ts +2 -2
- package/dist/options.mjs +12 -1
- package/dist/resolve/builtins.cjs +73 -1
- package/dist/resolve/builtins.d.cts +68 -0
- package/dist/resolve/builtins.d.ts +8 -8
- package/dist/resolve/builtins.d.ts.map +1 -1
- package/dist/resolve/builtins.js +4 -4
- package/dist/resolve/builtins.mjs +53 -1
- package/dist/resolve/component-globals.cjs +234 -14
- package/dist/resolve/component-globals.d.cts +80 -0
- package/dist/resolve/component-globals.d.ts +5 -5
- package/dist/resolve/component-globals.js +10 -10
- package/dist/resolve/component-globals.mjs +211 -14
- package/dist/resolve/component-resolver.cjs +80 -1
- package/dist/resolve/component-resolver.d.cts +68 -0
- package/dist/resolve/component-resolver.d.ts +3 -3
- package/dist/resolve/component-resolver.d.ts.map +1 -1
- package/dist/resolve/component-resolver.js +3 -3
- package/dist/resolve/component-resolver.mjs +59 -1
- package/dist/resolve/load-directive.cjs +93 -1
- package/dist/resolve/load-directive.d.cts +53 -0
- package/dist/resolve/load-directive.d.ts +5 -5
- package/dist/resolve/load-directive.js +6 -6
- package/dist/resolve/load-directive.mjs +72 -1
- package/dist/resolve/resolve-ir.cjs +108 -1
- package/dist/resolve/resolve-ir.d.cts +53 -0
- package/dist/resolve/resolve-ir.d.ts +6 -6
- package/dist/resolve/resolve-ir.d.ts.map +1 -1
- package/dist/resolve/resolve-ir.js +1 -1
- package/dist/resolve/resolve-ir.mjs +85 -1
- package/dist/resolve/write-globals.cjs +319 -14
- package/dist/resolve/write-globals.d.cts +30 -0
- package/dist/resolve/write-globals.js +2 -2
- package/dist/resolve/write-globals.mjs +298 -14
- package/dist/server-fns-ZYWQTSZU.mjs +78 -0
- package/dist/server-functions-PCERFA7A.mjs +82 -0
- package/dist/transform/bindings.cjs +71 -1
- package/dist/transform/bindings.d.cts +16 -0
- package/dist/transform/bindings.d.ts +1 -1
- package/dist/transform/bindings.js +1 -1
- package/dist/transform/bindings.mjs +50 -1
- package/dist/transform/index.cjs +2732 -8
- package/dist/transform/index.d.cts +15 -0
- package/dist/transform/index.mjs +3773 -17
- package/dist/transform/intrinsics.cjs +216 -3
- package/dist/transform/intrinsics.d.cts +21 -0
- package/dist/transform/intrinsics.js +1 -1
- package/dist/transform/intrinsics.mjs +193 -3
- package/dist/transform/props.cjs +441 -3
- package/dist/transform/props.d.cts +45 -0
- package/dist/transform/props.d.ts +1 -1
- package/dist/transform/props.d.ts.map +1 -1
- package/dist/transform/props.js +4 -4
- package/dist/transform/props.mjs +1482 -12
- package/dist/transform/server-fn-id.cjs +35 -1
- package/dist/transform/server-fn-id.d.cts +9 -0
- package/dist/transform/server-fn-id.d.ts +1 -1
- package/dist/transform/server-fn-id.js +2 -2
- package/dist/transform/server-fn-id.mjs +14 -1
- package/dist/transform/server-fns.cjs +114 -2
- package/dist/transform/server-fns.d.cts +12 -0
- package/dist/transform/server-fns.js +3 -3
- package/dist/transform/server-fns.mjs +1155 -11
- package/dist/transform/source-locations.cjs +330 -1
- package/dist/transform/source-locations.d.cts +43 -0
- package/dist/transform/source-locations.d.ts +1 -1
- package/dist/transform/source-locations.js +5 -5
- package/dist/transform/source-locations.mjs +307 -1
- package/dist/transform/templates.cjs +2701 -7
- package/dist/transform/templates.d.cts +69 -0
- package/dist/transform/templates.d.ts +2 -2
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +7 -7
- package/dist/transform/templates.mjs +3743 -16
- package/dist/transform-RWDTQUF5.mjs +893 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/dist/babel-VXKH6MRQ.mjs +0 -1
- package/dist/chunk-3SAEGOMQ.mjs +0 -1
- package/dist/chunk-5KMMN5QP.mjs +0 -1
- package/dist/chunk-IBRM4W7I.mjs +0 -10
- package/dist/chunk-OHHZCYIQ.mjs +0 -1
- package/dist/chunk-YKZ54NVE.mjs +0 -1
- package/dist/server-fns-6QM243HC.mjs +0 -2
- package/dist/server-functions-E3LKCZ4R.mjs +0 -1
- package/dist/transform-C4ZXRVGP.mjs +0 -8
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bundler integrations for the Fluixi compiler.
|
|
3
|
+
* @module @fluixi/compiler/integrations
|
|
4
|
+
*
|
|
5
|
+
* vite, webpack, rollup and esbuild adapters. Each is a few lines around
|
|
6
|
+
* `compileModule`, which rewrites the source in place, JSX and `` html`` `` both
|
|
7
|
+
* lower to the shared IR and the imperative backend. fluixi re-exports
|
|
8
|
+
* createVitePlugin from here.
|
|
9
|
+
*
|
|
10
|
+
* `babel: true` routes through the babel front-end instead, for a project whose
|
|
11
|
+
* own babel plugins have to see the output. It is the only thing that needs
|
|
12
|
+
* @babel/core, and it says so rather than degrading: source that was not compiled
|
|
13
|
+
* is source whose templates never became DOM calls, and a build that ships it
|
|
14
|
+
* looks successful until the page is opened.
|
|
15
|
+
*/
|
|
16
|
+
export interface CompilerOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
19
|
+
* used in a template without an import. See `createComponentResolver`.
|
|
20
|
+
*/
|
|
21
|
+
resolve?: readonly ComponentResolverRule[];
|
|
22
|
+
/**
|
|
23
|
+
* Where to write the ambient declarations for the components `resolve` supplies.
|
|
24
|
+
*
|
|
25
|
+
* Relative to the project root; `false` turns generation off. Without this file every
|
|
26
|
+
* resolved tag is a `Cannot find name` error in the editor and in `tsc`, because the
|
|
27
|
+
* import only exists after compilation. Committing it is intended, it is what makes a
|
|
28
|
+
* fresh clone type-check before anyone runs the dev server.
|
|
29
|
+
*
|
|
30
|
+
* It must be covered by `include` in tsconfig.json, which for the default means adding
|
|
31
|
+
* `"fluixi.d.ts"` alongside `"src"`. A file TypeScript does not read looks exactly like
|
|
32
|
+
* one that was never generated, so a mismatch is reported rather than left to puzzle
|
|
33
|
+
* over.
|
|
34
|
+
*
|
|
35
|
+
* @default 'fluixi.d.ts'
|
|
36
|
+
*/
|
|
37
|
+
globals?: string | false;
|
|
38
|
+
/** Clone static subtrees from a `<template>` instead of building them element by element. */
|
|
39
|
+
templateClone?: boolean;
|
|
40
|
+
/** Also clone subtrees whose structure is static but which contain dynamic holes. */
|
|
41
|
+
partialTemplates?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to generate source maps
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
sourceMaps?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to delegate events
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
delegateEvents?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to generate dev-mode code with additional checks
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
development?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Where the JSX *types* come from, and the `jsxImportSource` handed to esbuild
|
|
59
|
+
* and TypeScript. The compiler never emits `jsx()` calls itself, this is for
|
|
60
|
+
* type resolution and for any JSX the Fluixi transform does not consume.
|
|
61
|
+
* @default '@fluixi/jsx'
|
|
62
|
+
*/
|
|
63
|
+
importSource?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Authoring syntaxes to compile: 'jsx', 'lit' (only `` html`...` `` templates),
|
|
66
|
+
* or 'both' (default). Both lower to the same IR and the same backend.
|
|
67
|
+
* @default 'both'
|
|
68
|
+
*/
|
|
69
|
+
format?: 'jsx' | 'lit' | 'both';
|
|
70
|
+
/**
|
|
71
|
+
* Record where each reactive node is created, and serve the running app's graph to a tool
|
|
72
|
+
* that asks for it. Development only: a build never carries either.
|
|
73
|
+
*
|
|
74
|
+
* On by default when the dev server is running and @fluixi/devtools is installed. The
|
|
75
|
+
* marks are what turn `m5` into `double @ src/app.tsx:6`, and the endpoint is what an
|
|
76
|
+
* editor or a graph panel reads.
|
|
77
|
+
*
|
|
78
|
+
* `{ external: true }` marks dependencies too: node_modules and anything outside the
|
|
79
|
+
* project. That is for working on the framework itself: the graph then shows which nodes
|
|
80
|
+
* a library created and which the application did, at the cost of a mark per node in code
|
|
81
|
+
* you are not editing.
|
|
82
|
+
*/
|
|
83
|
+
devtools?: boolean | {
|
|
84
|
+
external?: boolean;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Compile through babel instead of rewriting the source directly.
|
|
88
|
+
*
|
|
89
|
+
* The default path parses once and splices the emitted code over the spans it
|
|
90
|
+
* replaces: nothing is reprinted, edits carry a source map, and types are left
|
|
91
|
+
* for esbuild to strip. Babel is kept for the cases that need to sit inside its
|
|
92
|
+
* pipeline: a `babel.config.js` with other plugins that have to see the
|
|
93
|
+
* output. It needs `@babel/core` and friends installed; they are optional peers.
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
babel?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Tag name marking a lit template for compilation (when `format` includes lit).
|
|
99
|
+
* @default 'html'
|
|
100
|
+
*/
|
|
101
|
+
litTag?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Rewrite a component's destructured props into property reads, so
|
|
104
|
+
* `function Card({ title })` keeps updating instead of reading `title` once.
|
|
105
|
+
* Applies to JSX and html`` alike: it rewrites the function body before either is
|
|
106
|
+
* compiled. A pattern it can't prove is left as written, so `splitProps` keeps
|
|
107
|
+
* working wherever it's still needed.
|
|
108
|
+
*
|
|
109
|
+
* Turn it off for a package that ships its source to be compiled by the consumer ,
|
|
110
|
+
* rewriting there would bake property reads into what you publish.
|
|
111
|
+
*
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
propsDestructure?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Module emitted runtime symbols are imported from in 'imperative' mode.
|
|
117
|
+
* @default '@fluixi/dom'
|
|
118
|
+
*/
|
|
119
|
+
signalModule?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Module control-flow components are imported from in 'imperative' mode.
|
|
122
|
+
* @default '@fluixi/dom'
|
|
123
|
+
*/
|
|
124
|
+
controlFlowModule?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Module the router components (Router/Outlet/…) are auto-imported from.
|
|
127
|
+
* @default '@fluixi/core/router'
|
|
128
|
+
*/
|
|
129
|
+
routerModule?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Where reactive primitives (createMemo) are imported from in 'imperative' mode.
|
|
132
|
+
* @default '@fluixi/reactive/signal'
|
|
133
|
+
*/
|
|
134
|
+
reactiveModule?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Helper for creating a Babel plugin
|
|
138
|
+
*/
|
|
139
|
+
export declare function createBabelPlugin(options?: CompilerOptions): Promise<{
|
|
140
|
+
name: string;
|
|
141
|
+
plugin: ((api: object, options: import("./frontend/babel/plugin.cjs").PluginOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<import("@babel/core").PluginPass>) | null;
|
|
142
|
+
getOptions(): {
|
|
143
|
+
reactiveModule?: string | undefined;
|
|
144
|
+
routerModule?: string | undefined;
|
|
145
|
+
controlFlowModule?: string | undefined;
|
|
146
|
+
signalModule?: string | undefined;
|
|
147
|
+
litTag?: string | undefined;
|
|
148
|
+
partialTemplates?: boolean | undefined;
|
|
149
|
+
templateClone?: boolean | undefined;
|
|
150
|
+
resolve?: readonly ComponentResolverRule[] | undefined;
|
|
151
|
+
format?: "both" | "jsx" | "lit" | undefined;
|
|
152
|
+
importSource: string;
|
|
153
|
+
development: boolean;
|
|
154
|
+
delegateEvents: boolean;
|
|
155
|
+
};
|
|
156
|
+
}>;
|
|
157
|
+
/**
|
|
158
|
+
* Helper for creating a TypeScript transformer
|
|
159
|
+
*/
|
|
160
|
+
export declare function createTypeScriptTransformer(options?: CompilerOptions): (context: any) => (sourceFile: any) => any;
|
|
161
|
+
/**
|
|
162
|
+
* Create a Vite plugin for JSX transformation
|
|
163
|
+
*/
|
|
164
|
+
export declare function createVitePlugin<T>(options?: CompilerOptions): T;
|
|
165
|
+
/**
|
|
166
|
+
* Create a Webpack loader for JSX transformation
|
|
167
|
+
*/
|
|
168
|
+
export declare function createWebpackLoader(options?: CompilerOptions): (this: any, source: string) => Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Create a Rollup plugin for JSX transformation
|
|
171
|
+
*/
|
|
172
|
+
export declare function createRollupPlugin(options?: CompilerOptions): {
|
|
173
|
+
name: string;
|
|
174
|
+
transform(code: string, id: string): Promise<import("./transform/templates.cjs").TransformResult | {
|
|
175
|
+
code: string;
|
|
176
|
+
map: {
|
|
177
|
+
version: number;
|
|
178
|
+
sources: string[];
|
|
179
|
+
names: string[];
|
|
180
|
+
sourceRoot?: string | undefined;
|
|
181
|
+
sourcesContent?: string[] | undefined;
|
|
182
|
+
mappings: string;
|
|
183
|
+
file: string;
|
|
184
|
+
} | null | undefined;
|
|
185
|
+
} | null>;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Create an ESBuild plugin for JSX transformation
|
|
189
|
+
*/
|
|
190
|
+
export declare function createESBuildPlugin(options?: CompilerOptions): {
|
|
191
|
+
name: string;
|
|
192
|
+
setup(build: any): void;
|
|
193
|
+
};
|
|
194
|
+
export type { ServerFnTransformOptions } from './frontend/babel/server-functions.cjs';
|
|
195
|
+
import type { ComponentResolverRule } from './resolve/component-resolver.cjs';
|
|
196
|
+
/**
|
|
197
|
+
* Vite plugin for `"use server"`: applies the transform (client→RPC stub, server→register
|
|
198
|
+
* the body), and provides `virtual:fluixi-server-fns`, side-effect imports of every
|
|
199
|
+
* module that defines a server function. The server entry imports it so ALL server
|
|
200
|
+
* functions register at startup (including those in lazy routes, which would otherwise
|
|
201
|
+
* register only when their chunk loads → an RPC registry miss). The client never imports
|
|
202
|
+
* it. `enforce:'pre'` so it runs on the raw source before other transforms.
|
|
203
|
+
*/
|
|
204
|
+
export declare function serverFunctionsVitePlugin<T = any>(options?: {
|
|
205
|
+
babel?: boolean;
|
|
206
|
+
}): T;
|
|
207
|
+
declare const _default: {
|
|
208
|
+
createBabelPlugin: typeof createBabelPlugin;
|
|
209
|
+
createTypeScriptTransformer: typeof createTypeScriptTransformer;
|
|
210
|
+
createVitePlugin: typeof createVitePlugin;
|
|
211
|
+
createWebpackLoader: typeof createWebpackLoader;
|
|
212
|
+
createRollupPlugin: typeof createRollupPlugin;
|
|
213
|
+
createESBuildPlugin: typeof createESBuildPlugin;
|
|
214
|
+
};
|
|
215
|
+
export default _default;
|
package/dist/integrations.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module @fluixi/compiler/integrations
|
|
4
4
|
*
|
|
5
5
|
* vite, webpack, rollup and esbuild adapters. Each is a few lines around
|
|
6
|
-
* `compileModule`, which rewrites the source in place
|
|
6
|
+
* `compileModule`, which rewrites the source in place, JSX and `` html`` `` both
|
|
7
7
|
* lower to the shared IR and the imperative backend. fluixi re-exports
|
|
8
8
|
* createVitePlugin from here.
|
|
9
9
|
*
|
|
@@ -24,7 +24,7 @@ export interface CompilerOptions {
|
|
|
24
24
|
*
|
|
25
25
|
* Relative to the project root; `false` turns generation off. Without this file every
|
|
26
26
|
* resolved tag is a `Cannot find name` error in the editor and in `tsc`, because the
|
|
27
|
-
* import only exists after compilation. Committing it is intended
|
|
27
|
+
* import only exists after compilation. Committing it is intended, it is what makes a
|
|
28
28
|
* fresh clone type-check before anyone runs the dev server.
|
|
29
29
|
*
|
|
30
30
|
* It must be covered by `include` in tsconfig.json, which for the default means adding
|
|
@@ -56,7 +56,7 @@ export interface CompilerOptions {
|
|
|
56
56
|
development?: boolean;
|
|
57
57
|
/**
|
|
58
58
|
* Where the JSX *types* come from, and the `jsxImportSource` handed to esbuild
|
|
59
|
-
* and TypeScript. The compiler never emits `jsx()` calls itself
|
|
59
|
+
* and TypeScript. The compiler never emits `jsx()` calls itself, this is for
|
|
60
60
|
* type resolution and for any JSX the Fluixi transform does not consume.
|
|
61
61
|
* @default '@fluixi/jsx'
|
|
62
62
|
*/
|
|
@@ -69,13 +69,13 @@ export interface CompilerOptions {
|
|
|
69
69
|
format?: 'jsx' | 'lit' | 'both';
|
|
70
70
|
/**
|
|
71
71
|
* Record where each reactive node is created, and serve the running app's graph to a tool
|
|
72
|
-
* that asks for it. Development only
|
|
72
|
+
* that asks for it. Development only: a build never carries either.
|
|
73
73
|
*
|
|
74
74
|
* On by default when the dev server is running and @fluixi/devtools is installed. The
|
|
75
75
|
* marks are what turn `m5` into `double @ src/app.tsx:6`, and the endpoint is what an
|
|
76
76
|
* editor or a graph panel reads.
|
|
77
77
|
*
|
|
78
|
-
* `{ external: true }` marks dependencies too
|
|
78
|
+
* `{ external: true }` marks dependencies too: node_modules and anything outside the
|
|
79
79
|
* project. That is for working on the framework itself: the graph then shows which nodes
|
|
80
80
|
* a library created and which the application did, at the cost of a mark per node in code
|
|
81
81
|
* you are not editing.
|
|
@@ -89,7 +89,7 @@ export interface CompilerOptions {
|
|
|
89
89
|
* The default path parses once and splices the emitted code over the spans it
|
|
90
90
|
* replaces: nothing is reprinted, edits carry a source map, and types are left
|
|
91
91
|
* for esbuild to strip. Babel is kept for the cases that need to sit inside its
|
|
92
|
-
* pipeline
|
|
92
|
+
* pipeline: a `babel.config.js` with other plugins that have to see the
|
|
93
93
|
* output. It needs `@babel/core` and friends installed; they are optional peers.
|
|
94
94
|
* @default false
|
|
95
95
|
*/
|
|
@@ -102,11 +102,11 @@ export interface CompilerOptions {
|
|
|
102
102
|
/**
|
|
103
103
|
* Rewrite a component's destructured props into property reads, so
|
|
104
104
|
* `function Card({ title })` keeps updating instead of reading `title` once.
|
|
105
|
-
* Applies to JSX and html`` alike
|
|
105
|
+
* Applies to JSX and html`` alike: it rewrites the function body before either is
|
|
106
106
|
* compiled. A pattern it can't prove is left as written, so `splitProps` keeps
|
|
107
107
|
* working wherever it's still needed.
|
|
108
108
|
*
|
|
109
|
-
* Turn it off for a package that ships its source to be compiled by the consumer
|
|
109
|
+
* Turn it off for a package that ships its source to be compiled by the consumer ,
|
|
110
110
|
* rewriting there would bake property reads into what you publish.
|
|
111
111
|
*
|
|
112
112
|
* @default true
|
|
@@ -195,7 +195,7 @@ export type { ServerFnTransformOptions } from './frontend/babel/server-functions
|
|
|
195
195
|
import type { ComponentResolverRule } from './resolve/component-resolver.js';
|
|
196
196
|
/**
|
|
197
197
|
* Vite plugin for `"use server"`: applies the transform (client→RPC stub, server→register
|
|
198
|
-
* the body), and provides `virtual:fluixi-server-fns
|
|
198
|
+
* the body), and provides `virtual:fluixi-server-fns`, side-effect imports of every
|
|
199
199
|
* module that defines a server function. The server entry imports it so ALL server
|
|
200
200
|
* functions register at startup (including those in lazy routes, which would otherwise
|
|
201
201
|
* register only when their chunk loads → an RPC registry miss). The client never imports
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../src/integrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC3C;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,6FAA6F;IAC7F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAEhC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAE5C;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,cAA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E,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAoD7E;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,CAAC,CAqCvF;;;;;;;;;AAED,wBAOE"}
|
package/dist/integrations.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module @fluixi/compiler/integrations
|
|
4
4
|
*
|
|
5
5
|
* vite, webpack, rollup and esbuild adapters. Each is a few lines around
|
|
6
|
-
* `compileModule`, which rewrites the source in place
|
|
6
|
+
* `compileModule`, which rewrites the source in place, JSX and `` html`` `` both
|
|
7
7
|
* lower to the shared IR and the imperative backend. fluixi re-exports
|
|
8
8
|
* createVitePlugin from here.
|
|
9
9
|
*
|
|
@@ -161,7 +161,7 @@ export function createVitePlugin(options = {}) {
|
|
|
161
161
|
if (!babel) {
|
|
162
162
|
// No silent fallback. This front-end compiles through babel; without it
|
|
163
163
|
// there is no transform, and emitting the source unchanged would ship a
|
|
164
|
-
// build whose JSX and html`` templates were never compiled
|
|
164
|
+
// build whose JSX and html`` templates were never compiled, a failure
|
|
165
165
|
// that looks exactly like success until the page is opened.
|
|
166
166
|
throw new Error(`[fluixi] @babel/core is required to compile ${id} but could not be loaded. ` +
|
|
167
167
|
`Install it alongside @fluixi/compiler.`);
|
|
@@ -189,7 +189,7 @@ export function createVitePlugin(options = {}) {
|
|
|
189
189
|
]);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
// Only our custom babel plugin handles JSX
|
|
192
|
+
// Only our custom babel plugin handles JSX, never @babel/preset-react, which
|
|
193
193
|
// rewrites spreads with Object.assign and breaks store-proxy reactivity.
|
|
194
194
|
if (babelPlugin && babelPlugin.plugin) {
|
|
195
195
|
plugins.push([babelPlugin.plugin, babelPlugin.getOptions()]);
|
|
@@ -285,7 +285,7 @@ const reported = new Set();
|
|
|
285
285
|
* All of these build cleanly and fail at runtime, which is why they are worth printing: an
|
|
286
286
|
* unresolved tag renders nothing, a `load:` it cannot act on ships the chunk eagerly, and a
|
|
287
287
|
* props pattern the rewrite refused reads its value once instead of tracking it. None leaves
|
|
288
|
-
* a trace anywhere else
|
|
288
|
+
* a trace anywhere else: the last one is a stale value on screen and nothing in the build.
|
|
289
289
|
*
|
|
290
290
|
* `console.warn`, deliberately, not a plugin's `this.warn`: that only exists in the
|
|
291
291
|
* rollup/vite context, and this runs for the esbuild and webpack adapters too. A
|
|
@@ -407,6 +407,27 @@ import { readdirSync, readFileSync } from 'node:fs';
|
|
|
407
407
|
import { join as _join } from 'node:path';
|
|
408
408
|
const SERVER_FNS_VMOD = 'virtual:fluixi-server-fns';
|
|
409
409
|
/** Recursively find source files containing the `"use server"` directive under `dir`. */
|
|
410
|
+
/**
|
|
411
|
+
* Whether a file actually carries a `"use server"` directive.
|
|
412
|
+
*
|
|
413
|
+
* Every module this matches is side-effect imported into the server bundle, so a false
|
|
414
|
+
* positive does more than waste a line: it runs that file on the server. A plain
|
|
415
|
+
* `includes('use server')` matched the words wherever they appeared, and a client entry
|
|
416
|
+
* that merely *mentioned* the directive in a comment was imported into the SSR graph and
|
|
417
|
+
* called `startClient` there, which fails with `document is not defined` from a line
|
|
418
|
+
* nobody wrote.
|
|
419
|
+
*
|
|
420
|
+
* Comments are stripped before the test rather than parsed around, because the answer
|
|
421
|
+
* only has to be good enough to decide whether the real transform should look at the
|
|
422
|
+
* file. A directive inside a string literal still matches, which costs an extra import
|
|
423
|
+
* and nothing else.
|
|
424
|
+
*/
|
|
425
|
+
function hasServerDirective(source) {
|
|
426
|
+
const withoutComments = source
|
|
427
|
+
.replace(/\/\*[\s\S]*?\*\//g, ' ')
|
|
428
|
+
.replace(/(^|[^:])\/\/[^\n]*/g, '$1');
|
|
429
|
+
return /(^|[\s;{(,])['"]use server['"]/.test(withoutComments);
|
|
430
|
+
}
|
|
410
431
|
function findServerFnModules(dir, out = []) {
|
|
411
432
|
let entries;
|
|
412
433
|
try {
|
|
@@ -423,11 +444,11 @@ function findServerFnModules(dir, out = []) {
|
|
|
423
444
|
findServerFnModules(full, out);
|
|
424
445
|
else if (/\.[jt]sx?$/.test(e.name)) {
|
|
425
446
|
try {
|
|
426
|
-
if (readFileSync(full, 'utf8')
|
|
447
|
+
if (hasServerDirective(readFileSync(full, 'utf8')))
|
|
427
448
|
out.push(full);
|
|
428
449
|
}
|
|
429
450
|
catch {
|
|
430
|
-
/* unreadable
|
|
451
|
+
/* unreadable: skip */
|
|
431
452
|
}
|
|
432
453
|
}
|
|
433
454
|
}
|
|
@@ -435,7 +456,7 @@ function findServerFnModules(dir, out = []) {
|
|
|
435
456
|
}
|
|
436
457
|
/**
|
|
437
458
|
* Vite plugin for `"use server"`: applies the transform (client→RPC stub, server→register
|
|
438
|
-
* the body), and provides `virtual:fluixi-server-fns
|
|
459
|
+
* the body), and provides `virtual:fluixi-server-fns`, side-effect imports of every
|
|
439
460
|
* module that defines a server function. The server entry imports it so ALL server
|
|
440
461
|
* functions register at startup (including those in lazy routes, which would otherwise
|
|
441
462
|
* register only when their chunk loads → an RPC registry miss). The client never imports
|
|
@@ -461,7 +482,7 @@ export function serverFunctionsVitePlugin(options = {}) {
|
|
|
461
482
|
// First wire the request-context bridge (server-only), then side-effect import each
|
|
462
483
|
// server-fn module so its top-level $$registerServerFn(...) runs, then re-export the
|
|
463
484
|
// dispatcher so the host can route /_server through THIS module graph (sharing the
|
|
464
|
-
// registry the imports populated)
|
|
485
|
+
// registry the imports populated), apps don't need to re-export it from entry-server.
|
|
465
486
|
const setup = `import '@fluixi/start/server-fn-setup';\n`;
|
|
466
487
|
const imports = mods.map((m) => `import ${JSON.stringify(m)};`).join('\n');
|
|
467
488
|
const dispatcher = `\nexport { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';\n`;
|